Free download:

Software Wars, the Movie

Soundtrack for the book:


If you enjoyed the free download, a donation of the cost of a newspaper would be appreciated.



The best book explaining free market economics:

The best explanation of how we can build a space elevator in 10 years:


Book explaining a political solution to our economic problems:


PyTorch Should Be Copyleft

Neural networks have started to take off since AlexNet in 2012. We don’t have to call it a software war, but there’s a competition for mindshare and community contributors in neural networks.

Of course, AI needs more than a neural network library, it needs the configuration hyperparameters, training datasets, trained models, test environments, and more.

Most people have heard of Google’s Tensorflow which was released at the end of 2015, but there’s an active codebase called PyTorch which is easier to understand, less of a black box, and more dynamic. Tensorflow does have solutions for some of those limitations (such as Tensorflow-fold, and Tensorflow-Eager) but these new capabilities remove the need for other features and complexity of Tensorflow. Google built a great system for doing static computation graphs before realizing that most people want dynamic graphs. Doh!

And how much do you trust Google, anyway?

PyTorch was created by people from Idiap Research Institute in Switzerland, who went to Facebook and Google. Doh!

I posted a bug report on the PyTorch license, asking for a copyleft one: https://github.com/pytorch/pytorch/issues/5270

I think you should consider a copyleft license. I realize it’s a pain to change the license, but it never gets easier. I read the license and it’s mostly a disclaimer and a warning. There’s nothing in there about protecting the freedom of the users.

There are lots of projects with lax licenses that are successful, so maybe it will work out okay, but the Linux kernel took off because of the copyleft license. It nudges people to give back.

Lax licenses let companies take advantage of the individual contributors. I don’t understand how someone who believes in free software also believes letting big companies turn it back into proprietary software is fine.

I realize lawyers might like that, and proprietary software companies might want it, but this group is more than just those people. It’s great you’ve got 100s of contributors already, but if you know the way corporations work, you should be pushing for copyleft.

My bug was closed within 8 hours with the following response from a Facebook employee:

we’ve definitely thought about this in the past. We have no plans of changing our license.

The bug was closed but I could keep commenting:

When you say “we”, are you talking about Facebook or the random smaller contributors? Given you work for a large company, I hope you realize you could be biased. At the same time, you should know the way large corporations work even better. You won’t be there forever. Copyleft is stronger protection for the software and the users, do you disagree?

When you say “thought”, have you written any of it down with a link you can post for archival purposes? That way if others come along, they’ll have a good answer. I may quote your non-defense of your lax license in my writings if you don’t mind, but I’d prefer if you gave me a bit more.

I just spend several minutes looking for a discussion on PyTorch license, and came up with nothing except another bug report closed with a similar short answer.

Your last dismissive answer could motivate people to create a copyleft fork!

I got one more response:

We = the authors of the project.

“thought” = this is a topic that came up in the past, we discussed it among ourselves. I don’t have it written down, we don’t plan to have it written down.

I wrote one more response:

It don’t know any of these names:
https://www.openhub.net/p/pytorch/contributors

I don’t know who the authors are of this project, and how much is big companies versus academics and small contributors, how much interest there is in making a copyleft version, etc.

BTW, relicensing would get you plenty of news articles. It’s also tough because Facebook doesn’t have the same reputation as the FSF or EFF for protecting user’s freedom. The Tensorflow license is lax also so you don’t have that competitive advantage.

To some it’s a disadvantage, but it did make a difference in the Linux scheme, and you would hope to have your work be relevant for that long, and without a bunch of proprietary re-implementations over time that are charged for. It could also slow software innovation because everyone is mostly improving their secret code on top.

LibreOffice was able to convince a lot of people that a copyleft license was better than the OpenOffice scheme, but I don’t know what people here think. One interesting data point would be to find out what percent of the patches and other work are by small contributors.

Anyway, you’ve got a cool project, and I wish you the best, partially because I don’t trust Google. Tensorflow is just some sample code for others to play with while they advance the state of the art and keep 95% proprietary. It also seems they made a few mistakes in the design and now will carry baggage.

There is a deep learning software wars going on. It’s kind of interesting to almost be on the side of Facebook 😉

It’s a shame that copyleft seems to be losing mindshare. If the contributors who like copyleft lit some torches, and created a fork, or threatened to, it could get the attention of the large corporations and convince them to relicense rather than risk the inefficiencies, bad press, slower progress and loss of relevance. Forks are a bad thing, but copyleft can prevent future forks, and prevent people from taking but not giving back.

Whether a PyTorch fork makes sense depends on a number of factors. The LibreOffice fork was created because people were unhappy about how Sun and then Oracle were working with the community, etc. If the only thing wrong with PyTorch is the lax license, it might become very successful without needing the copyleft nudge.

I wish PyTorch used the AGPL license. Most neural networks are run on servers today, it is hardly used on the Linux desktop. Data is central to AI and that can stay owned by FB and the users of course. The ImageNet dataset created a revolution in computer vision, so let’s never forget that open data sets can be useful.

A license like the GPL wouldn’t even apply to Facebook because the code runs on servers, but it would make a difference in other places where PyTorch could be used. You’d think Facebook could have just agreed to use a LGPL license, and silently laugh as they know the users don’t download their software.

Few people run Linux kernels remotely so the GPL is good enough for it. Perhaps it isn’t worth making a change to the PyTorch license unless they switch to AGPL. Or maybe that’s a good opening bid for those with torches and pitchforks.

AI in Microsoft Office

This is an open letter to the LibreOffice-Discuss alias.

Hi all,

I came across a Microsoft AI video that I thought was interesting and food for thought here. The entire video is long, the link takes you directly to a demo of AI features in Office: https://youtu.be/H_X1ZuM6ZJU?t=1h12m27s

It shows an auto-designer, a better grammar checker, Intranet search and easy copy/paste, nice pen gestures, and analysis of spreadsheets (trends and outliers). He also references some other AI-powered features (quickstarter, researcher, my analytics, ink to math, ink to shape, math assistant)

There’s been a lot of progress in deep learning in the last few years. It is arguably overkill in many situations, but there are a lot of people working on it, and they are making continuous breakthroughs. There are some powerful Python libraries to consider integrating better into LibreOffice (perhaps via extensions) such as scikit-learn, nltk, PyTorch and Keras. There are C/C++ machine learning libraries that could be worth putting into LibreOffice also, and perhaps it has some already with the Calc solver.

It would be interesting to see a Deep Lightproof or other intelligent machine learning features one day. I tried to get the Java-based Language Tool working on my machine and didn’t manage, and it made LibreOffice stutter, and the UI was tiny / unreadable, etc. I don’t know if anyone has talked to them about the benefits of Python 😉

Regards,

Arch Linux on a Lenovo Yoga 900

Warning: this is about 5,500 words with plenty of links, so wait till you’ve got something to drink and some time.

After 3 years running Arch Linux on a Lenovo Yoga 2, I decided to upgrade to a Yoga 900:

Lenovo Yoga 900 Amazon special for $900 – 8GB RAM, 256GB SSD, 3200×1800, Intel Skylake 3.2GHz + Iris Graphics

Dell charges $1650 for a similar XPS 13 although it comes with the next generation of Intel chip. The current model of Yoga is the 910, and that laptop costs $1300. However, I didn’t even consider it because they screwed the pooch on the keyboard. Lots of reviews start with the color and feel of the materials on the outside, but I’m going to start on the keyboard layout.

Keyboard

The Yoga 2 Pro and the Yoga 900 have the same design. It is inferior in several ways compared to the traditional and well-regarded IBM Thinkpad keyboards, but not the worst keyboard out there and I got used to it over the 3 years. Unfortunately, Lenovo made things worse in the 910.

Yoga 2 and Yoga 900 keyboard layout
Yoga 910 keyboard

The problem with the 910 keyboard is that the right-shift key is in the wrong place, and impossible to reach without moving your hand. It is in a different position than every keyboard I’ve ever used going back to 9th grade typing class on the IBM Selectric. I’d expect such a mistake from a company like Asus or Dell, not a company with the legacy of building typewriters that generations of Americans learned and worked on.

Every year the Yoga team has made changes to the layout. Imagine if every year in the 20th century, IBM had changed the layout of their typewriters, and then bragged about the “efficiency” gains. The company wouldn’t even be around today!

I probably could get used to the Yoga 910 page up / page down overloaded with arrow keys, and some of the other changes, but the shift-key is a deal breaker and I’d rather not bother with the others.

There are many ways for Lenovo to truly improve their keyboard, such as making the volume-up key not so close to application-close. And re-thinking whether they really need an easy way to (accidentally) turn off the screen given there is already a way to dim it. And figuring out how to put in an overloaded number pad. Does Lenovo think only businesses deal with numbers?

The 910 keyboard has so many changes, they might not ever go back to their old layouts again. I’m hoping this hardware will last me years. I’d rather have a great keyboard than a computer 10 times faster.

I see in the Yoga 910 reviews on the Lenovo website that some people are returning the computer because of the keyboard. Lenovo should have a policy: if an employee wanted to make an alteration to the keyboard, they should have to write down a very good reason, and then sacrifice one of their fingers in solidarity with the pain it will cause customers. A rule like that would decrease this needless churn. Lenovo went through a lot of work make the Yoga 910, but f*cked it up with the input mechanism.

Overall

The Yoga 2 was generally fast enough for everything I needed to do. An SSD is nice for various reasons, but it is almost overkill on Arch. People who only use Windows might not realize how bloated it is:

In the late 90’s, you’d get a new computer every few years because the processors were doubling in speed every 18 months, and the software was doubling in size frequently as well. Things are very different now. The new Yoga is 30% faster than my Yoga 2 running integer benchmarks. This is a 3.2 GHz machine whereas the old one maxed out at 2.6 GHz so most of the difference is the faster frequency.

Haswell was introduced in 2013, and Skylake was introduced in 2015 so two years of advancement is the other part of the improvements. The big benefit of the new processor is that it is built in 14nm instead of 22nm which means less heat and longer battery life. My old Yoga 2 battery was still giving me about 3.5 hours of battery life with moderate brightness, but this should give me 7.

The Yoga 2 hinge is starting to weaken and fall apart, and there is no way to tighten it, only to try to find one on the Internet or mail it to Lenovo:

The hinge on Yogas is designed to let you lay the device flat, and even fold it back as a tablet, but I found it a heavy and awkward and so never bothered. I’m just happy if I’ll be able to open and close it daily for years.

The Yoga 900 hinge is a more solid watchband design and should last longer:

The only very minor downside is that if you shake it, it sounds like you’ve got broken parts rattling around inside, which usually is something to be worried about for electronics! However, it’s just a false alarm of the 800 pieces sliding.

The Yoga 2 Pro was overall a quite well-built device, but if I hold it in one hand with the screen open, it sags a bit, and sometimes the keyboard backlight goes out. Both Yogas are thin and light, but the 900 feels more solid.

Clickpad

The biggest problem with the Yoga 2 was the Synaptics Clickpad it used. It actually wasn’t the hardware, it was the driver, which is basically unmaintained, and of course had some bugs. It’s a shame because Synaptics could easily afford one engineer to help maintain a few thousand lines of code. They actually wrote another driver, they just never released it freely so it could be included with the kernel.

However, a new library called Libinput was created, and it supports Clickpads and things work well out of the box. The best thing about Libinput is that they fixed the bug where if you have your left finger touching in the mouse-click area, it will now register pointer movements by your right finger. It’s hard to believe, but that basic functionality was broken for many years with Synaptics hardware on Linux.

The Clickpad hardware was still working fine, but it didn’t give any audible click sound anymore. That actually isn’t a problem, but it did make me wonder if it was going to wear out at some point. The old Thinkpads had multiple left and right mouse buttons, so if one broke, you could use the other while you ordered a new part, but since there’s only one button here, there is no backup except to plug a mouse in. (Lenovo expects you to mail in the computer to replace the mouse.)

Kernel Support

When I bought the Haswell laptop, the hardware design was brand new, so I ran into a lot of Linux driver problems initially that took months to resolve. In this generation, Skylake crashing bugs were still being fixed 8 months after the architecture was introduced. And even when those were fixed, there were still problems with power management support, but today these also appear to be improved. The laptop will settle into the lower power C6-C10 states if nothing is going on. (This is verifiable with powertop.)

The power management features are important not only for battery life, but because these very small circuits eventually wear out because of something known as electromigration. Intel even warns that: “Long term reliability cannot be assured unless all the Low-Power Idle States are enabled.” By running in lower power mode, and therefore using the circuits less, they will last longer.

Linux’s Haswell support is very reliable now, but it was definitely flakey for a long time. I wrote about some of the issues at the beginning and after the first year, but I can say finally that things are great for Haswell and Skylake.

Lenovo BIOS Linux Incompatibility

Before I could install Linux on the Yoga 900, I had to flash a new BIOS in Windows. In fact, I had to install 2 BIOSes. The latest Yoga 900 BIOS didn’t include the necessary fix I needed, so after scratching my head for a while I eventually discovered and installed a separate “Linux-only” BIOS update, which also says that Windows is no longer supported by Lenovo: “Are we not merciful?”

As people who followed the Linux news are aware, the Yoga 900 and certain other recent models of Lenovo laptops were impossible to install Linux on, because it couldn’t even detect the hard drive. Lenovo’s first reply was that the laptops didn’t work on Linux because it uses a new RAID controller mode. However, RAID is meant for multiple disks, and this laptop only has one hard drive, and there isn’t even room to install another.

Here’s some more of Lenovo’s official explanation:

“To support our Yoga products and our industry-leading 360-hinge design in the best way possible we have used a storage controller mode that is unfortunately not supported by Linux and as a result, does not allow Linux to be installed.”

I found it funny that the reason for their different storage controller is because of their hinge! It would be like a car company saying they had to change their rims because of their new radio.

This turned into a controversy thanks to the efforts of BaronHK on Reddit who wrote about it, provided information to the media, and contacted his local Attorney General in Illinois. Searching for “Lenovo Yoga Linux compatibility” turns up 300,000 results. Lenovo could be criminally liable for selling a “general purpose” PC that didn’t let you install your own operating system. The default OS is meaningless on a machine that is truly mine.

Hackers got involved, and they eventually discovered via playing with the UEFI settings, that the machine still supported the AHCI controller mode, it was just disabled. In short, Lenovo took away Linux compatibility for no good purpose. Because of all the information people learned, if this case had ever gone to court, Lenovo would have gotten their ass handed to them.

Fortunately, all the news got their attention, and they eventually updated the BIOS. I type this on a Yoga 900 running Linux, so we should celebrate this victory. Let’s hope they learn a lesson, but I’m not optimistic. They ought to offer you an option to choose the operating system for your machine. They would have found this bug long before any customers did. I’d wait an extra week to get a custom computer. They could also do a better job setting up the partitions and letting people customize lots of things, and grabbing all the latest software, rather than using a generic old image which needs lots of updates.

Some people like Lenovo said it was Linux’s fault for not supporting this new RAID driver mode. However, AHCI is a very popular standard, and the Linux kernel team rejected Intel’s code for this hardware as “too ugly to live”! The team also asked Intel for a specification describing the device’s behavior, but wasn’t given this information.

Heat Dissipation

The Yoga 2 could get hot when pushing the CPUs hard. I charred the bottom of the plastic case while compiling LibreOffice on a blanket, which was an eyesore and made me look like a homeless programmer. I tried a metal brush and some turpentine to get the worst of it off, but it didn’t really improve the situation:

This new computer has a metal case which shouldn’t get discolored, and Skylake definitely runs cooler than Haswell. It also seems to do better job of pushing heat out sideways through the hinge, instead of down which could easily be obstructed.

One of the annoying things about the Yoga 2 over time is that the fan blades had collected dust over the years, but it sounded like sand! It was uneven and distracting and made it much louder. I did take the laptop apart and vacuum everything, but the blades are hidden. I’d have to replace the fans. They don’t kick in on the Yoga 2 for typical tasks of word processing and web browsing, but when they do spin up it’s annoying if I’m not wearing headphones.

The Yoga 900 fans are higher pitch, but it is just a smooth whir and not distracting. The Yoga 900 fans seem to run all the time, but at a low speed that is quiet. The sound of my refrigerator and air filter are louder unless the fans crank up under load, and even then it is not a big deal.

Graphics

The Yoga 2 had a great screen, but it also had widely reported issues because the yellow looked like orange. However, everything looked so crisp and all the other colors looked fine. The Yoga 900 screen has fixed the yellow issue. It’s not true 4K, being only 3200×1800, but the pixels are smaller than 4K on a 15.6” monitor, so that it looks very sharp. Some say the screen resolution is fake because it uses “RG/BW Pentile matrix” but to me, high-res pictures look fantastic, and so does the text.

When I first got the Yoga 2, Haswell was still a new chipset, so I saw various Intel graphics display glitches which went away within a couple of months. However, I eventually discovered a memory leak that could crash Linux, and this bug was in there for years.

My computer ran out of RAM a number of times skipping through video in VLC (shift + arrow). The memory didn’t show up as in use by VLC, but my computer ran out of RAM, so clearly it was kernel memory. Eventually I setup a swap file which gave more time, but even then a couple of times it filled up when I wasn’t keeping track. Eventually the bug disappeared, and Linux is very stable right now, but it was there for years.

Everyone says Intel has the best Linux drivers, but they seem like a skunkworks project inside Microsoft. The driver developers working on Linux at Intel are good, there just aren’t enough of them. They should be perfecting the drivers before they release the hardware! Intel produced 113 processors as part of Skylake, with subtle feature differences. That sounds like a lot, but they released 256 chips during the Haswell generation, so maybe things are getting more focused. It could be part of the problem with the drivers is there are too many different models to support. I was told 10 years ago by an Intel employee that they invested 1% into Linux compared to Windows, and today that still seems to be true.

The only performance issue I ran into with the Yoga 2 was that it couldn’t play 4K video reliably. It would often show screen glitches, or just do around 5 frames per second:

The Yoga 2 would even sometimes struggle playing 1920×1080 video, which it was supposed to be able to handle at 60fps. Part of this is probably because I always have other applications like Firefox and LibreOffice running.

The Skylake processor is spec’ed to do 4K video at 60 fps for H.264, VP9, and other codecs. In fact, the processor has a lot of hardware accelerated multimedia capabilities. I tried out hardware encoding of H264 with ffmpeg and found it was 4 times faster while using just 1 CPU. It’s cool to see this feature. Unfortunately, it is a little difficult to setup because you have to use a number of additional command line parameters:

-threads 1 -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -vf format=’nv12|vaapi,hwupload’

I tried to find a way to have ffmpeg remember these for me so I wouldn’t have to type it in every time, but couldn’t. I can’t just pass those in automatically either, as other things need to go before and after. I also discovered that it won’t resize video while using the hardware, and will just ignore the request, so only sometimes can it be used. It would be really great if ffmpeg could figure this out automatically. There is a lot of unused hardware because users don’t know or can’t be bothered. Unfortunately it’s kind of a mess for video encoding and decoding as there are multiple APIs for Linux and Windows.

Skylake does a much better job playing 4K video, but it will still glitch sometimes and briefly drop down to 10 fps. I think part of it is X. I tried playing 4K videos in Wayland, and it was smoother, so I’m hopeful. It is great to see that the OpenGL support has improved. On this hardware, Intel supports version 4.5 which is the latest version from 2014.

My Yoga 900 (-13ISK2) is actually a revised version of the original offering with an Iris 540 graphics co-processor which is supposed to be faster than the stock 520 because of 24 more shader units. However, it can only play SuperTuxKart with moderate settings running 1600×900 at 20 fps, so I wouldn’t say it’s anything to brag about. Speaking of which, the game has improved tremendously over the years and is beautiful now:

There is an Intel team in China working on enabling support for OpenCL using the graphics card. However, I don’t see any mention of people using it in Blender yet, so I wonder the status and whether it is just demoware. Intel’s OpenCL support has been missing for so long, people doing serious work with Blender already use NVidia or AMD cards, and even when Intel finally writes the code there’s not much testing or interest.

One thing that was surprising to me is that I did some experiments on another machine, and found that a quad-core processor is faster than the NVidia 960M for ray-tracing Blender with the Cycles engine. Apparently the 640 CUDA cores aren’t enough to beat 4 Intel CPUs on that task. Newer processors have 2000+ cores and those provide faster performance.

HiDPI

The situation has gotten better for Linux on these high-res screens over the last 3 years, but it still has a ways to go. The good news is that Gnome is almost perfect with HiDPI in current versions. Firefox generally looks great if you set the layout.css.devPixelsPerPx to 2. However because this 13.3” screen’s pixels are so small, I also installed the No-Squint Plus plugin and have it render everything at 120% to make it a bit easier to read.

I was happy to help LibreOffice look better on these screens with some patches that were shipped in April, 2014, and the work has continued since. The biggest issue remaining is that LibreOffice is still doubling the toolbar icons. A number of themes have SVG icons, but they aren’t packaged and shipped with the product. SVGs are much slower to load compared to PNGs and need to be cached. Tomaž Vajngerl has done some more work in this area, but it hasn’t released yet. Even so, LibreOffice looks better than many other Linux apps which don’t have recognizable icons.

Applications are generally improving with regards to detecting and being usable on high-res screens, but even some of the most popular such as Gimp and Audacity and Inkscape are still hard to use. I installed a large custom theme for Gimp, but all the icons are different so even though they are bigger, it takes time to recognize them.

The unfortunate thing about Linux’s 1.5% marketshare is that these sorts of issues don’t get much priority. Many codebases are moving to GTK 3, but in Audacity’s case, it seems to be stalled. I talked in my first review about a long tail of applications that will need improvements but 3 years later, even some of the most popular apps still need work.

SSD

The old hard drive was doing fine because of the various optimizations I did, especially to Firefox. I also kept in mind that the /tmp directory had automatically been setup as a RAM drive, and so I would usually save downloads there first. Sometimes I’d find a 500 MB video I want to grab a short 20 MB clip from, or convert to another format, so by doing it in /tmp I saved a lot of writes. It is more work, and possibly unnecessary, but it is faster to use RAM.

I had written to each cell 25 times over the 3 years, which meant the drive could last for 350 years. The vast majority of the writes were for Arch updates. It got new LibreOffice builds every month, and a new “stable” kernel release every week. It was great to be up to date all the time, but it did cost 100 times more writes compared to running Debian stable. However, each component has their own release cycle so I didn’t worry about it.

The new Samsung drive diagnostics don’t tell the number of times it has written to each cell. In fact, I can’t even find out what cell type it is and how many writes it is specified to handle. I believe the “Percentage Used” value will me the age of the drive, but perhaps it relates only to the number of spare cells. I haven’t found any documentation so I can only guess:

Model Number: SAMSUNG MZVLV256HCHP-000L2
Firmware Updates (0x06): 3 Slots
Available Spare: 100%
Available Spare Threshold: 10%
Percentage Used: 0%
Data Units Written:
198,997 [101 GB]
Data Units Written: 305,302 [156 GB]
Host Read Commands: 3,480,816
Host Write Commands: 10,176,457
Error Information Log Entries: 5

Broken Left-Ctrl Key

One thing I noticed after just a few hours of use is that the left-control key pops off if pressed in the upper-left corner:

Broken Yoga 900 key: Note the tiny cylinder missing in the left box vs the right

The layout of the Yoga 900 keyboard is the same as the Yoga 2 Pro, but the internals are different. The keys of the Yoga 2 Pro cannot be removed and replaced individually, and there is no way to pop off any of the keys without doing permanent damage. The Yoga 900 has the old style Thinkpad keys: which can be detached, and replaced individually.

However, there is a defect and one of the 4 tiny cylinder notches in the hinge was missing so that it only connects to the key top at 3 points. If you don’t press the key in the middle, it will slip off.

I contacted Lenovo about this. Even though the keys are replaceable and serviceable, they will only replace the entire keyboard, and refuse to mail out any parts. They recommend I mail the computer in, or take it to the Geek Squad service center. I knew that mailing it in would take 2 weeks, so I called my local store to ask if they had Yoga keyboard parts in stock. They told me they don’t take the computers apart, they just mail them to Atlanta. There used to be places that could make many repairs to IBM laptops, and stocked the common parts, but that industry is apparently gone.

I noticed this mistake within a couple of hours of using the computer, so I’m pretty sure it was a manufacturing defect. It is such a tiny piece of plastic that was deformed or broke off during assembly.

Even though the computer is under warranty and could be fixed for free, I didn’t want to wait for something so minor, so I just went on the Internet and found a website called laptopkey.com and ordered a replacement key and hinge. It was actually tricky because there are 3 types of hinges! It took me several minutes to figure out which one my computer has because y’all look the same to me:

So I ordered the part, but I read it would arrive in about a week. It was very frustrating because I use left-ctrl all the time when doing copy/paste, skipping through video or by word in text editors, etc. so I thought maybe I could swap the hinge from the right-ctrl, which I never use.

So I tried to remove this key following instructions I found on the Internet: I got my fingernail under the upper left corner, and lifted till it clicked. And then I put my nail under the upper right corner, and did the same thing. But, another one of those tiny pieces of plastic broke off, so now I have two broken hinges. It might not be possible to remove the keys without breaking these very tiny clips. These keyboards are serviceable perhaps only in theory.

So I decided to go old-school and use superglue. I’d rather have the damn key stay on and have no urgent plans to replace them. It was tricky because I needed a small dab of glue about 1mm in diameter: too much in there it could gum up the works.

My experience building R/C airplanes came in handy and I fixed it and now the left-ctrl key is holding on. The right one still slips off but I hardly use it. I was happy again! This is a long sidetrack, but it is important to keep in mind the maintenance of a machine.

Antergos vs. Arch

After 3 years with Arch Linux, I had no interest in trying anything else. The Intel drivers had regressions, but otherwise Arch has been painless to run on a daily basis, and it got a little better every week. It’s exciting to be up to date with everything. I often had packages newer than what was in Ubuntu on their release date. Ubuntu users can find newer software in custom PPAs, but there isn’t any testing or coordination across them, so that people who use multiple often run into problems.

People also complain about Ubuntu upgrades hosing the machine and forcing a re-install, so even though their installation process is quicker, the ongoing maintenance over 3 years isn’t. Every time I’ve read about someone borking an Arch installation, they would always admit it was a user error or something like btrfs corruption.

I wanted to install Antergos, which provides a GUI installer for Arch. However, the setup looked unreadable on my screen, and it didn’t recognize the Clickpad in their minimal install, which is the only one I had space for on my old 1GB USB key. So I decided to just install Arch old-school again. Thankfully, the Yoga still supports legacy BIOS, so I didn’t have to mess with UEFI.

I was sorry I didn’t try out Antergos, because I think it could be a great distro for less technical people or those who want to quickly get into Arch Linux. The Arch wiki is filled with tips for best running Linux. I’d love to have something which setup weekly TRIM for my SSD, Profile-Sync-Daemon, Android support, hardware-accelerated video playback, etc. There are quite a few things that nearly all users would want, and are just a few lines to detect and enable.

Manjaro is a very popular Arch-based distribution with a GUI installer, but having run Arch for 3 years, I trust their packagers to work out issues between components. I’ve read a number of comments on Reddit from people who found their Manjaro installation broken after an update.

My only complaint about my Arch installation now is the ugly unreadable bootloader screen. I just need to copy over the grub.cfg from my old machine.

Arch Install

At first I just wanted to move the hard drive from one laptop to the next so that I wouldn’t even have to install anything, but after taking the computers apart, I noticed the M.2 SSDs are a different shape. I could have done a low-level block copy, but just decided to start fresh. I had installed a lot of random crap over the years, and even when I remembered to un-install it there were all kinds of digital remnants.

The Arch install went quite smoothly this time because the hardware had been around for so long. I still needed to do rfkill unblock wifi, but other than that everything else just worked. Apparently Linux still doesn’t know how to properly read the rfkill information from this model. Fortunately systemd has the ability to restore rfkill values on startup.

Kernel Buglist

One of the things that continues to surprise me is that the Linux buglist is a mess. I know there are all of these people and this great rate of change, but what isn’t changing is the worst case scenario for a bug report. I don’t know why bugs sit around for years, but there clearly is no escalation process.

I wrote an analogy in my last review I think is useful. Imagine if it took an airline 1-2 years to return your lost luggage. Would you use trust that company? In fact, what’s the point of making a new release if you’ve still got thousands of known bugs and hundreds of regressions? If 1% of every Boeing airplane crashed, would they just keep continuing like that for years?

Maybe the Linux Foundation should hire some engineers to work on all the bugs that everyone else seems to be ignoring. There are a lot of people paid to work on Linux, and there are a lot of old bugs – which is usually what amateurs do. In my opinion the kernel would be better off not releasing anything for months until the bug count was under 50. Right now it is 4672. That would be a good reason to increment the major release number.

There is something contradictory about making a new stable release every week, but they’ve been doing it that way for years, and they have critical fixes every time, so they are clearly doing something valuable. The kernel gets better at a great rate, so far be it for me to criticize, but I do think they should try something different.

At least, bugs should get resolved within a specific timeframe. If that is exceeded, than it should escalate up to the maintainer and eventually to Linus. If there is a problem area with a lot of old bugs in a place that no one is working on, then Linus can point this out and crack the whip on the relevant parties. They need to think more like Boeing.

Lenovo

Many Linux users hammer Lenovo for their lack of support on their consumer laptops, but they sometimes build relatively better hardware at a good price. As I wrote years ago, it was obvious not one person at Lenovo had bothered to install Linux on the Yoga 2 before they released it, and it is true for the Yoga 900 because it was impossible.

I think everyone in their company should be dual-booting. It isn’t that hard to setup, and their customers might want it. Lenovo has 60,000 employees. At least, they need to hire a few people on their Yoga team willing to try out this thing called Linux. Windows is painful to use compared to Linux in various ways. Windows runs more applications, but I think half of their users would be happier with a properly configured Linux installation.

While it is bad how Lenovo is still ignoring Linux, their problems apply to more than the software. On many models, the RAM chips are soldered on. In some devices, there are whitelists and only pre-approved cards can be installed. The Yogas don’t have a discrete graphics card, but even Lenovos that do provide no mechanism to upgrade the card, like you can with a desktop. I think someone needs to put a horse head in the bed of the Lenovo CEO.

Conclusion

This Yoga 900 is a good laptop for the price, and it’s a definite step up from the Yoga 2 with the improvements. A similar Apple Macbook Pro is $1500, but it has 40% less pixels.

Windows is adopting some of the best features of Linux, but they still don’t have native support for a package manager with all of the interesting free software components pre-compiled. Installing ffmpeg on Windows is a huge pain because of all the dependent libraries it uses.

Microsoft built a Windows store, which is sort of like a repository, but it doesn’t handle inter-package dependencies, and isn’t setup to manage individual libraries. Microsoft also has a new package manager called NuGet, but it seems to be used mostly for .Net software. It did have a package for ffmpeg, but it didn’t have any dependencies for the codecs so even after installing it, it won’t do anything useful yet.

Last March, Microsoft demonstrated the ability to run Ubuntu command-line applications, which is quite a revolution. (They should have started with Debian.) There’s even a discussion in their buglist to add support for more distros which could be quite tempting.

For me at least, I have no need for Windows apps, and the extra maintenance time. Fixing issues in Windows involves hunting down things in lots of different places. Linux still has a fair number of places to configure a system, but overall it’s much simpler.

I have friends who install 3rd party software on Windows just to keep their drivers up to date, because it grabs code from many more websites than just Microsoft’s. Windows has gotten better over the years, and it has more games and desktop applications, but it is an aging, closed system.

I find Gnome classic a streamlined experience. I wish it wasn’t written in the clunky fad Javascript, and they re-enabled a community around custom themes and color schemes. It’s also still missing some nice features from Gnome 2 and Windows 10, and could be a bit more stable. Gnome 3.0 in 2011 was a big step backwards, but six years later we’re up to Gnome 3.22, and things are mature again.

Gnome Classic is one of the best GUIs, but there are a number of good ones and all are getting better. This machine is working quite well now and I’m just going to sit back and keep waiting for the HiDPI and other improvements! I’m definitely looking forward to neural networks inside the grammar checker of LibreOffice.

1+ Year Running Arch Linux on a Lenovo Yoga 2

In October 2013, I bought a Lenovo Yoga 2 Pro:
Promotional picture of a Yoga 2 Pro.
After 5 years with a Thinkpad, I was ready to upgrade to a prettier model. I wrote a long, but still incomplete review, and it became the most popular article on my website. It has apparently become one of Lenovo’s best-selling models because I’ve seen advertisements for it during NFL football games.

So, I decided to write an update after long-term daily use. Things have gotten better, but numerous challenges remain, and there have been some regressions. If you read the Linux newswires, you might think the biggest remaining challenge holding back Linux is systemd. While the drama and arguments are interesting, it has been the least of my worries. My biggest daily frustration is the drivers.

What if it took an airline 1-2 years to return your lost luggage? Or, imagine Linux as a big estate, where the developers are the maintenance staff. Everyone is discussing their specific features, such as the design of the Italian ceramic tile in the 4th swimming pool, but there is no toilet paper in the guest bathroom. This is a known problem, but it sits with the other 2,736 active bugs and 402 regressions. The biggest Linux discussion is about Linus’s sarcasm, not whether there is anything lacking in the quality of the release process. The Linux kernel is already very high quality, but with thousands of active bugs, there are bound to be millions of unhappy users. My machine alone experienced 10 of them — I had 10 reasons to be unhappy.

You can’t just look at patches, you also need to look at bugs – the patches that are missing. The value of a bug list is that it helps you find the areas of the code that the programmers are ignoring, that need more resources.

I would suggest goals such as having all bugs resolved within 1-2 releases. Many sit around for 10+ months today. Not all bugs have to be fixed, but from going through the active list, most of them seem like they need to be, and a lot of them are scary looking.

Other than the hardware-specific issues, I’ve been amazed by how well Arch Linux works, given that it doesn’t have release cycles, or a big team with a lot of money supporting and marketing it. I’ve heard only 30 developers maintain the core Arch packages, with most of them having a full-time job doing something else! At the same time, it shouldn’t be a total surprise things work so well because free software doesn’t just fall off a turnip truck:

With notable exceptions and regressions, every free codebase is getting better every day.

I still run Debian on my server, but I think Arch is a great OS for the desktop where things are evolving so quickly, and each component has its own release cycle. A lot of average Linux users don’t talk much about Arch, but all the big software teams are aware because they find bugs months before the other distros, and have knowledgeable testers. Arch, because of its setup process and superb wiki, creates more competent users. Not everyone needs to know how to use the command line, but everyone reading this review should!

While it might seem scary to not have a huge full-time team behind an operating system, in truth, the bigger distributions also have more users and so that your particular bug isn’t likely to get much attention. Nearly every major free software codebase has thousands of active bugs. It can take years to get something fixed.

While things are getting better every day, you can still have risks of regressions, but you are not really stuck in Arch. You can always downgrade to a previous version of the software: “pacman -U pkgname-oldver.pkg.tar.gz”. The package manager will also automatically downgrade any components that depend on the newer package.

The install process that I wrote about in my first review was a little complicated, but it was also an interesting and enjoyable learning experience. In general, the only ongoing maintenance I now do is to run “pacman -Syu”. This downloads all the newest software and installs it. There is no new release to celebrate, you are always up to date. I expect to be able to run this installation for years without having to bother doing it again.

The only tricky thing I had to deal with was getting my Android phone connected. I’m not sure how it is handled on other distros because I never had this phone until I got Arch, but I can say it was a pain. The problem is that my LG G2 didn’t support the extremely popular USB mass storage protocol. Even the iPhone supports it! Instead they force you to use MTP, which is a crappy standard created by Microsoft. Samsung at least offers you a choice. Unfortunately, while there are multiple implementations of MTP on Linux, some didn’t work for my phone. Eventually I got it working by using the gvfs-mtp package.

Kernel

I’ve not yet had a problem with my machine not booting, but I did have a regression with my Intel wireless driver that was almost a catastrophe because a laptop without Internet is basically useless as a work machine. The wifi-menu command broke with my Intel card. It should bring up something like this:netctl

Instead, it just returned:

Scanning for networks… failed

No networks found

This is a command I ran every time I turned on the computer or wanted to switch to a new Internet hotspot. I never actually proved whether it was a kernel bug or a wifi-menu bug, but I suspect it was a quirk of the Intel driver, and this command wasn’t broken for all network cards for so many months. It would have been a huge problem to have no networking, except that the command “netctl start wlp1s0-MyHomeNetwork” worked, so even though scanning was broken, I could still start profiles.

As a side note, I should be using the GUI Network Manager:

It is the de-facto wireless GUI on Linux, but it was broken for my machine because it thought my wireless card was disabled. The kernel was giving out invalid rfkill information for this model. The Ideapad_laptop kernel module was returning invalid wireless data for this machine until 1 year after it was released. This is a few thousand lines of code that Lenovo should be helping to maintain, but does not. It is sort of amazing that a company with 54,000 employees can’t afford even one to help maintain even the most basic Linux support.

Meanwhile, my mouse is the most frustrating issue. I’ll talk more about it later, but the reason the official Linux driver is so buggy is because Synaptics wrote a driver, but never released it publicly. It is that sort of mentality that has been killing Linux on the desktop.

I’ve had a number of other random kernel issues. Resume has been flakey. It didn’t work at the beginning, and then it got better, but periodically it gets worse again. For a while, I never closed my screen because I didn’t trust it would come back. Sometimes, it would come back, but Gnome wouldn’t let me login!

For a while, the laptop speakers never worked after a reboot until I plugged something into the headphone jack, and then removed it. It was fine when I bought the machine, but broke for about 6 months. The sound’s maximum allowed volume was much too high initially, and sometimes the fader magically moves on startup, so I have to go into the options and re-set it.

Initially my machine was generating about 70 MB of kernel spew per day of spurious error messages. So I configured systemd to just write them all to RAM. This isn’t necessary anymore as the logs look better now. For example, the constant USB “errors” I wrote about in my first review have gone away.

Overheating

The Yoga blows hot air out of the bottom of the machine, compared to my old Thinkpad, which ventilated out of the sides. The downside of the new design is that you have to be careful what you place the computer on. One time I was building LibreOffice while it was on a blanket and it overheated and charred the bottom.

20150327_135649-2

Fortunately, it didn’t ruin any of the electronics. It would be interesting to know whether the Linux power management prevented the computer from dying, or whether I had pulled it away in time. However, I’m not going to do any more testing! When doing CPU-intensive work, I now place this laptop on a metal plate.

Graphics

I’ve been very happy with the 13-inch 3200×1800 screen. Eventually I was able to remove the “acpi_backlight=vendor” kernel hack I mentioned in my first review, and then the brightness keys worked.

The random screen dirt bugs were fixed by Intel a few months after my review. Sometimes I’d have up to 50 8×4 black rectangles randomly scattered all over my screen. I presume nearly everyone at Intel are running Windows because a number of bugs don’t get fixed until after they’ve shipped the hardware out to customers. This means the kernel developers need to balance their time between supporting the upcoming hardware, and making it actually work on hardware that customers already have.

Clearly they are not creating the hardware and the Linux drivers concurrently, in a holistic fashion. Part of the reason the drivers are buggy is because of issues in the hardware that weren’t found until after it was shipped. In one bug fix, the Intel driver developer wrote: “There seems to be no clear rationale for these flushes.”

There are 4K videos on Youtube, but they are extremely jittery and suck all the CPU as the GPU is not being used. I don’t play many videogames, but it is a shame that the driver only supports OpenGL version 3.3, which was released in 2010, whereas the current standard is 4.4.

I installed Steam and played Portal 2 at ¼ resolution: 1600×900, and it looked great and didn’t stutter. I tried Blender and discovered that it can’t use Intel’s GPU for rendering. It took hours to render these 3200×1800 Arch wallpapers. Intel has implemented the OpenCL API for Linux, but the drivers use the CPU only. This is in the process of being fixed, but it still isn’t yet.

I had to double-check this fact because it made no sense to me that an API designed for GPUs would be implemented only on CPUs, but that is the current state in the Intel Linux world. People give Intel a lot of credit for doing well with graphics drivers, but a big part of that is that they look good only by comparing to AMD and NVidia, which have historically been terrible. You get the sense that Linux is publicly “supported” by Intel, but that the Linux laptop team is still a skunkworks project. I heard from an Intel employee 9 years ago that Linux had 1% of the investments that Windows had, and I suspect it is about the same today.

Mouse

The mouse was extremely annoying when I first got the computer. As I wrote in my initial review, I was briefly sorry I didn’t keep Windows around because it is hard to concentrate on an idea while having to also focus on the mouse.

The good news is that it is less flakey. It use to jump violently all over the screen while typing, but now it just hovers in small circles. Sometimes the mouse still disappears; I’ll want to move it a few inches, and it will instead end up on the edge of the screen, out of sight.

With the old Trackpad, it used to be okay to gently rest your finger on the left or right mouse button, while you moved the pointer with other other hand, but now you cannot! With the current Linux driver, when there is a finger in the “soft button” area, the driver currently ignores all touches and movements, not just those in the fake button area.

For now, I’ve retrained my muscle memory. I just hold my finger above the click area until I need to use it. It took several weeks to be able to do it without thinking. I’ve seen configurations that are supposed to work better for this trackpad, but there is no UI, so you can’t easily just try things and test. I created a petition a couple of months after my review to encourage Synaptics to improve the Linux mouse drivers. Even after a year of deliberating, they are still thinking about what to do. It is a shame a company with 500 employees can’t even decide to maintain a driver for their hardware, that is less than 10,000 lines, and is already mostly written.

Keyboard

I’ve gotten used to the keyboard, but it is still difficult in various ways. After a couple of weeks, my fingers adjusted to the swapped left Fn and Ctrl keys, but whenever I go back to another layout, I get frustrated again. I wish the keys could have a bit more depth to travel, and be curved, like their old keyboards, but it isn’t a huge problem. I don’t understand why a $1,000 laptop can’t have a quality keyboard. The computer is 1.5 centimeters thick. I’d be happy to allocate more space for a better keyboard and battery.

I’ve generally gotten used to the new locations on the keyboard, although I need to look down to find special keys (such as Page Up). There are various negative issues when they combined the Function keys and IBM’s other special buttons.

The first problem is that the special keys are not broken up into groups like they used to be. I used to know that the volume increase button was the last button in a special group. It was easy to find, and I wouldn’t accidentally press any other buttons. Now I either have to count over to the 4th button, or look at the keys, which often involves moving my fingers out of the way.

Some of the keys are overloaded such that the F4 button is mapped to close, so instead of having to hit Alt-F4 as I used to, I can just hit the F4 button. This is one example of saving a keystroke. But it is actually also a problem because the button is right next to the volume increase button, and so I’ve sometimes closed the application when I meant to make the song or video louder.

Most of the other special buttons I don’t use. One of the buttons turns off the screen backlight. Hitting that accidentally can be confusing and I can’t really imagine the use case for it. It is also more difficult now because some things like F5 and F11 which I use somewhat frequently, require two fingers. One other little issue I ran into is that the print screen key is right next to the backspace key and so I sometimes overshoot and press it instead. I have created 100s of screenshots over the year. I don’t think the classic Thinkpad keyboard was perfect, but it was definitely better.

HiDPI

The HiDPI support has improved, especially in Gnome, but it still has a long way to go when you consider the long tail of applications. Gnome since version 3.14 has fixed almost all of the HiDPI issues I wrote about in my first review. However, Gnome 3.16 still has a few problems:

The scrollbars in all Gtk2 apps are too narrow. You can manually tweak this by opening the file: usr/share/themes/Adwaita/gtk-2.0/gtkrc and doubling the ‘slider-width’ from 13 to 26. A bug was filed against Gnome, but nothing has been done yet.

There was a HiDPI regression in Gnome 3.16. The desktop icons are huge, as if the computer is to be used by a 5 year old. They looked fine in Gnome 3.10-3.14. Fortunately this can be fixed by the File – Preferences menu in the file manager, but it disrupted my existing desktop icon arrangement and I had to redo it.

I wish that Gnome 3.x had more themes, and allowed for multiple color schemes. I read a funny quote on Slashdot: “KDE looks like a widget factory exploded on your desktop. Of course, GNOME looks like they’re experiencing a widget shortage, perhaps due to a widget factory somewhere being out of production due to an explosion.”

I learned after my review that Firefox can enable HiDPI support if you set: layout.css.devPixelsPerPx to 2 in about:config. I still use the NoSquint plugin so I can tweak the text size of individual pages, but it is nice that websites look pretty good automatically, and this tweak also makes Firefox’s own UI elements larger and nicer, whereas the plugin doesn’t.

I did a couple weeks of coding to help LibreOffice 4.2.3 look better on HiDPI screens, and the work has continued since. You can read my writeups about it here: Part 1: Writing, Part 2: Shipping. There are numerous other important applications out that still need basic fixes in applications such as Gimp, Audacity, VLC, and Inkscape. A few programs like Blender allow you set the DPI of the UI so even though it doesn’t look good out of the box, you can quickly fix it. It is easy to fetch the DPI on Linux via “xrdb -query”. People with these screens, report issues in your favorite apps, or send patches! Scaling the toolbar buttons in LibreOffice was just a few lines of code and by itself made a huge difference. 16×16 icons look like dead bugs on my screen. A lot of applications are waiting until they port to Gtk3 to fix their HiDPI issues, but it isn’t necessary, nor sufficient!

Wear

The hard drive is doing fine, writing to each cell 10 times since my first review. At the current rate, the drive should last 300 years. According to their calculations, I’m writing on average 5 gigabytes a day. Most of my HD writes are for new software from Arch, but that has only averaged 1.7 gigabytes a week of uncompressed files. That is about 120 gigabytes, whereas I’ve supposedly written 2.5 Terabytes! Where the extra writes are coming from is a mystery, but not a big problem.

One of the reasons I wanted a new laptop was that the florescent bulb on my 2008 laptop was getting very dim. This LED is more efficient, and will last a long time without degrading.

The battery is doing fine and gives about 3.5 hours with moderate brightness. I wish I could set the maximum recharge to 90% which would make the battery last much longer. It is not good to have a battery fully charged for long periods of time. Furthermore, I almost never need that last 10%. Unfortunately, such advanced battery features are not yet enabled in Linux. Within a year or so I’ll have to buy a Torx T-5 screwdriver to open the machine up and replace the battery. Otherwise, I expect this laptop will last me 5 years. I wouldn’t even consider buying the new Yoga 3 Pro, as they took away all the function keys. There is even more unused space on the machine as it is now just a 5-row keyboard. The world of Idiocracy inches closer.

Conclusion

This machine overall works better than when I first got it, considering the software improvements. I hope things improve further in the next year, especially with regards to HiDPI.

In spite of my problems, I’m very glad I don’t need to mess with the Windows or Mac world. They are more bloated, yet more constrained. The Linux desktop has plenty of workitems, but it advances everywhere. I’m surprised Arch is only the 9th most popular version of Linux on Distrowatch. However, if you add in Manjaro and Antergos, it would be #2. (I recommend people run Antergos rather than Manjaro, if they don’t want to install from the command line as it uses the official Arch repositories.)

I’m happy I’ve never had to mess with UEFI. I don’t feel like I’m missing any features compared to the old BIOS system. I hope it remains optional indefinitely but I somehow doubt it. Lenovo has no idea how many people are even using their legacy BIOS option, and I doubt it is a question they’d ever think to ask.

Once the hardware works, then we need the applications. Music and movie-making are a big priority in things that need to get better. I’ve heard that a number of the Ableton software engineers personally love Linux and they write a lot of their code in Python, but their software is released only on Windows and the Mac. I’d prefer if people were working together on free software for music creation, but in the meantime, running Ableton on Linux should be a better experience! The key to the Linux desktop’s success is lowering barriers.

Since Ableton already supports Windows and the Mac, supporting Linux isn’t technically very hard. Applications like Firefox, Chrome, LibreOffice, VLC, Audacity, Gimp, and many others are cross-platform. There are many challenges to Linux reaching beyond 1% on the desktop. I wrote a chapter about them in my book years ago, and there are new ones since. Fortunately, it generally gets better, if not always in the places that need it most.

It is amazing how Linux is doing very well, given how so much of it is underfunded. The UK government has given hundreds of millions of dollars to Microsoft for Office alone, and yet the foundation behind LibreOffice has total of a $225,000 budget. Hopefully along with the UK government’s decision to standardize on ODF, it will also include investments in free software to support their needs. The proprietary world continues to suck up huge amounts of money which is effectively starving Linux.

Update: In January, 2017 I upgraded to a Yoga 900. Here’s the review of that device. It also talks about long-term experiences running the Yoga 2 and Arch Linux.

Shipping the LibreOffice HiDPI Patches, or How I Learned to Love Heartbleed

I wrote my story about getting some HiDPI patches into LibreOffice, but it was an unfinished one because while the code had gotten accepted into the main Master branch, there was a lot remaining. It hadn’t shipped, I’d only tested it on Gnome and KDE, it hadn’t been tried on Windows, and didn’t work on the Mac. Worst of all, because it missed the December 20 cutoff date for 4.2.0, it was on the default next release train for 4.3.0 in late July.

LibreOffice has a two-part release process. You are encouraged to submit code into the main tree where it can sit for up to 6 months. Twice per year, it is branched and shipped. In between these major releases, every month or so, a minor release is made containing high priority fixes. Meanwhile most of the development team moves ahead adding features and cleanup for the upcoming release.

The code was too late for 4.2.0, and so it wasn’t getting much feedback. Very few people run the daily builds, with all the releases and release-candidates to test. A friendly chap named Darcy from Australia showed up on the QA alias, built LibreOffice on his Fedora 20 laptop, and verified that it worked, but that was it. The only way to get this code tested was to get it out there.

I had also decided to stop working after the second batch. I had improved the most noticeable parts of the product, but I was also steadily making more potential problems for myself. Software isn’t just about code, it is about standing behind your work. I could prove most of my changes were fine, but I was changing places where I didn’t always understand what was going on around. I could justify my fixes, but not the code around it.

Even though LibreOffice is built by a community where other people can fix your bugs, other people can also find your bugs. If your code is causing problems, and no one has time to look into it, it can be reverted. The work is interesting, but I was just a motivated user with some free time during the Christmas holiday. I wanted to reserve time to deal with the inevitable complaints.

In spite of the lack of feedback, since it makes a visual and usability difference, why wait? More computers with these beautiful screens are coming out every day. A very high-resolution screen is the best reason to buy a new laptop. There should be a free software experience that we can enjoy looking at. LibreOffice has plenty of ways to improve, but it can look good in the meanwhile.

Sidebar

The Sidebar was one of the areas I had kept putting off and almost didn’t work on. It is about 70,000 lines of new code providing an alternate UI, and I wanted to focus on the existing one first. I have been using this codebase for almost 10 years and had never missed it. The code was also written by someone from IBM, and so I couldn’t trust that anyone in LibreOffice would be able to help me.

I also hoped that maybe the Apache team would notice bug reports and fix the Sidebar themselves. LibreOffice grabs fixes from Apache on a daily basis. Only about half the changes are useful because in many cases LibreOffice has already done the work, but any pieces of value are ported over, and just a small part of LibreOffice’s churn of the their thousands of improvements per release.

I considered sending an email to the Apache OpenOffice alias asking if they were aware of the problem, and whether they were planning to work on it. It is more efficient to coordinate efforts and not have multiple people re-learning each other’s work. It took me hours to fix problems that could have been fixed over lunch by the person who wrote the code. However, while LibreOffice is taking patches from Apache OpenOffice, the groups are generally not actively planning work, and so asking for HiDPI support for the Sidebar would have been a breach of protocol.

In addition, the codebases are diverging so fixes might not be usable. Apache OpenOffice doesn’t have the OutputDevice::DPIScaleFactor API, so the patches wouldn’t have been directly usable. I didn’t try Apache OpenOffice on Linux, but I did try it on Windows 8.1 and sidebar bitmaps looked doubled. However, Windows 8.1 might have been artificially scaling the entire Apache OpenOffice UI because the text was a blurry mess compared to LibreOffice:
OOLO2
So I could imagine that fixing the Sidebar for LibreOffice would not be a high priority for Apache.

While I personally don’t care about the Sidebar, it is now turned on by default for Impress. I knew that the more places I fixed, the stronger argument I would have to convince people to get the improvements out there. I realized I just needed to motivate myself to learn the code. So while I was in rural northern Michigan with my family over the holiday, there were some quiet nights, and I dug in and learned the Sidebar well enough to fix the major issues. It was the same process and techniques I had used for the other parts of the code. As per usual, finding the correct place to put in a fix was the hardest part.

I’m glad I worked on it because not only did it make the Sidebar fit in visually with the other improvements, it fixed a crashing bug. LibreOffice’s Sidebar is better than OpenOffice’s in that it has dynamic layout when docked. However, the bigger buttons created something wider than the maximum width allowed. With the sidebar starting in an invalid state, the product would still work, but if you tried to resize it with the mouse, you could sometimes get LibreOffice to hang. If you push software beyond its limits, bad things can happen.

I don’t even remember clearly how I found the place to fix, but by just reading enough code, I found the routine SidebarController::RestrictWidth.

@@ -1109,7 +1112,8 @@ void SidebarController::RestrictWidth (sal_Int32 nWidth)
const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
	pSplitWindow->SetItemSizeRange(nSetId,
- 	Range(TabBar::GetDefaultWidth() + nWidth, gnMaximumSidebarWidth));
+ 	Range(TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor() + nWidth,
+ 	gnMaximumSidebarWidth * mpTabBar->GetDPIScaleFactor()));
	}
}

Getting on the 4.2.3 release train

Since it was a batch of new code to a stable branch, the LibreOffice Engineering Steering Committee had a discussion about it in one of their weekly meetings:

* HiDPI patches for 4.2.x? (Kendy)
    + LibreOffice does not look good on HiDPI screens at all - close to unusable
    + proposal to merge the HiDPI work to 4.2.x as a late feature
        + I would split the work into 'safe' and 'need real review' parts & push to a branch
        + can I get ESC approval / 3 independent reviews for that ?
    + is it a feature or a bug-fix ? (Michael)
        + most of the pieces going in enclosed in an if (hidpi) ...
            + checking that everything in the right if.
        + less safe part is checking / setting that flag; a small VCL piece.
    + Michael / Caolán signed up to review as/when there is a branch.

Once they gave their support, Kendy prepared for the patches for review.

Working with free software can be fun, but it can also be upsetting because problems can show up at any time. I was happy to see Kendy’s mail to the alias asking for review of the Gerrit patches, but not for very long because Norbert Thiebaud objected to them for the Mac. So after a flurry of emails over 3 days, we eventually got that resolved with another patch. So within a few days after that, the patches got reviewed and into the build for 4.2.3-rc1.

Windows

I was happy to see my efforts finally get into RC build, but I wasn’t happy for very long because this screenshot with clipped toolbar buttons showed up in my inbox:

This was upsetting for several reasons. The first is that it could have been found on master months before. Instead, it showed up on a day when I had my own things to work on. But instead of being able to focus on my tasks, I kept thinking about the toolbars, and what was I going to do about it?

I had been wondering for months what would happen when this code was tried on Windows. LibreOffice is created primarily by Linux developers, but Windows is the most popular OS for their users. My machine shipped with Windows but I had wiped it within a few hours and so couldn’t try it. I had used Windows for 15 years, but the last time was 9 years ago and I had no plans to go back.

I had envisioned various possibilities for what might happen on Windows, but cut-off toolbar buttons was not one of them. I also didn’t understand the toolbar layout code. I had written a toolbar manager before and didn’t want to volunteer any of my life on that boring problem.

However, I felt bad and that I should at least put some effort into trying to fix the problem. So that evening, I decided to just read through the toolbar code from beginning to end and see if I found anything obviously wrong. You don’t have to be very clever to notice a bloody knife at a murder scene.

And so I read through toolbox.cxx, including the toolbar layout code, and didn’t notice anything that stood out. So I next went to toolbox2.cxx. About halfway down, I found something suspicious:

/*static*/ Size
ToolBox::GetDefaultImageSize(bool bLarge)
{
    const long TB_SMALLIMAGESIZE = 16;
    if (!bLarge) {
        return Size(TB_SMALLIMAGESIZE, TB_SMALLIMAGESIZE);
    }

    OUString iconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
    return vcl::IconThemeInfo::SizeByThemeName(iconTheme);
}

That 16 was a sign of a place that needed doubling. I didn’t yet know who used that function and whether it would make a difference, but opengrok helped me and found that it was called by the main toolbar layout routine.

So I made a change:

1738     // set defaults if image or text is needed but empty
1739     nDefWidth       = GetDefaultImageSize().Width() * GetDPIScaleFactor();
1740     nDefHeight      = GetDefaultImageSize().Height() * GetDPIScaleFactor();

However, I couldn’t tell whether it would fix the problem. The comment above the code, while happily in English, explained it was relevant only for empty toolbars. This was not a case I care about.

So I changed the code, and hoped the comment was wrong, but didn’t understand what the implication was. It was a change I would try if I had a Windows box. It requires much less mental effort to test a change than to manually prove what happens in a big function. As long as you can test something, you can postpone the necessity of full understanding.

Here is the main toolbar layout routine. I’ve highlighted in red all the references to the variable I changed.

bool ToolBox::ImplCalcItem()
{

    // recalc required ?
    if ( !mbCalc )
        return false;

    ImplDisableFlatButtons();

    long            nDefWidth;
    long            nDefHeight;
    long            nMaxWidth = 0;
    long            nMaxHeight = 0;
    long            nMinWidth   = 6;
    long            nMinHeight  = 6;
    long            nDropDownArrowWidth = TB_DROPDOWNARROWWIDTH;

    // set defaults if image or text is needed but empty
    nDefWidth       = GetDefaultImageSize().Width() * GetDPIScaleFactor();
    nDefHeight      = GetDefaultImageSize().Height() * GetDPIScaleFactor();

    mnWinHeight = 0;
    // determine minimum size necessary in NWF
    {
        Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
        Rectangle aReg( aRect );
        ImplControlValue aVal;
        Rectangle aNativeBounds, aNativeContent;
        if( IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) )
        {
            if( GetNativeControlRegion( CTRL_TOOLBAR, PART_BUTTON,
                                        aReg,
                                        CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
                                        aVal, OUString(),
                                        aNativeBounds, aNativeContent ) )
            {
                aRect = aNativeBounds;
                if( aRect.GetWidth() > nMinWidth )
                    nMinWidth = aRect.GetWidth();
                if( aRect.GetHeight() > nMinHeight )
                    nMinHeight = aRect.GetHeight();
                if( nDropDownArrowWidth < nMinWidth )
                    nDropDownArrowWidth = nMinWidth;
                if( nMinWidth > mpData->mnMenuButtonWidth )
                    mpData->mnMenuButtonWidth = nMinWidth;
                else if( nMinWidth < TB_MENUBUTTON_SIZE )
                    mpData->mnMenuButtonWidth = TB_MENUBUTTON_SIZE;
            }
        }

        // also calculate the area for comboboxes, drop down list boxes and spinfields
        // as these are often inserted into toolboxes; set mnWinHeight to the
        // greater of those values to prevent toolbar flickering (#i103385#)
        aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
        aReg = aRect;
        if( GetNativeControlRegion( CTRL_COMBOBOX, PART_ENTIRE_CONTROL,
                                    aReg,
                                    CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
                                    aVal, OUString(),
                                    aNativeBounds, aNativeContent ) )
        {
            aRect = aNativeBounds;
            if( aRect.GetHeight() > mnWinHeight )
                mnWinHeight = aRect.GetHeight();
        }
        aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
        aReg = aRect;
        if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL,
                                    aReg,
                                    CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
                                    aVal, OUString(),
                                    aNativeBounds, aNativeContent ) )
        {
            aRect = aNativeBounds;
            if( aRect.GetHeight() > mnWinHeight )
                mnWinHeight = aRect.GetHeight();
        }
        aRect = Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
        aReg = aRect;
        if( GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL,
                                    aReg,
                                    CTRL_STATE_ENABLED | CTRL_STATE_ROLLOVER,
                                    aVal, OUString(),
                                    aNativeBounds, aNativeContent ) )
        {
            aRect = aNativeBounds;
            if( aRect.GetHeight() > mnWinHeight )
                mnWinHeight = aRect.GetHeight();
        }
    }

    if ( ! mpData->m_aItems.empty() )
    {
        std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
        while ( it != mpData->m_aItems.end() )
        {
            bool bImage;
            bool bText;

	     // indicates if text will definitely be drawn, influences dropdown pos
            it->mbVisibleText = false;

            if ( it->meType == TOOLBOXITEM_BUTTON )
            {
                // check if image and/or text exists
                if ( !(it->maImage) )
                    bImage = false;
                else
                    bImage = true;
                if ( it->maText.isEmpty() )
                    bText = false;
                else
                    bText = true;
		 // default to toolbox setting
                ButtonType tmpButtonType = determineButtonType( &(*it), meButtonType ); 
                if ( bImage || bText )
                {

                    it->mbEmptyBtn = false;

                    if ( tmpButtonType == BUTTON_SYMBOL )
                    {
                        // we're drawing images only
                        if ( bImage || !bText )
                        {
                            it->maItemSize = it->maImage.GetSizePixel();
                        }
                        else
                        {
                            it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET,
                                                   GetTextHeight() );
                            it->mbVisibleText = true;
                        }
                    }
                    else if ( tmpButtonType == BUTTON_TEXT )
                    {
                        // we're drawing text only
                        if ( bText || !bImage )
                        {
                            it->maItemSize = Size( GetCtrlTextWidth( it->maText )+TB_TEXTOFFSET,
                                                   GetTextHeight() );
                            it->mbVisibleText = true;
                        }
                        else
                        {
                            it->maItemSize = it->maImage.GetSizePixel();
                        }
                    }
                    else
                    {
                        // we're drawing images and text
                        it->maItemSize.Width() = bText ? GetCtrlTextWidth(it->maText)+TB_TEXTOFFSET:0;
                        it->maItemSize.Height() = bText ? GetTextHeight() : 0;

                        // leave space between image and text
                        if( bText )
                            it->maItemSize.Width() += TB_IMAGETEXTOFFSET;

                        // image and text side by side
                        it->maItemSize.Width() += it->maImage.GetSizePixel().Width();
                        if ( it->maImage.GetSizePixel().Height() > it->maItemSize.Height() )
                            it->maItemSize.Height() = it->maImage.GetSizePixel().Height();

                        it->mbVisibleText = bText;
                    }
                }
                else
                {   // no image and no text
                    it->maItemSize = Size( nDefWidth, nDefHeight );
                    it->mbEmptyBtn = true;
                }

                // save the content size
                it->maContentSize = it->maItemSize;

                // if required, take window height into consideration
                if ( it->mpWindow )
                {
                    long nHeight = it->mpWindow->GetSizePixel().Height();
                    if ( nHeight > mnWinHeight )
                        mnWinHeight = nHeight;
                }

                // add in drop down arrow
                if( it->mnBits & TIB_DROPDOWN )
                {
                    it->maItemSize.Width() += nDropDownArrowWidth;
                    it->mnDropDownArrowWidth = nDropDownArrowWidth;
                }

                // text items will be rotated in vertical mode
                // -> swap width and height
                if( it->mbVisibleText && !mbHorz )
                {
                    long tmp = it->maItemSize.Width();
                    it->maItemSize.Width() = it->maItemSize.Height();
                    it->maItemSize.Height() = tmp;

                    tmp = it->maContentSize.Width();
                    it->maContentSize.Width() = it->maContentSize.Height();
                    it->maContentSize.Height() = tmp;
                }
            }
            else if ( it->meType == TOOLBOXITEM_SPACE )
            {
                it->maItemSize = Size( nDefWidth, nDefHeight );
                it->maContentSize = it->maItemSize;
            }

            if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
            {
                // add borders
                ImplAddButtonBorder( it->maItemSize.Width(), it->maItemSize.Height(),
					mpData->mbNativeButtons );

                if( it->meType == TOOLBOXITEM_BUTTON )
                {
                    long nMinW = std::max(nMinWidth, it->maMinimalItemSize.Width());
                    long nMinH = std::max(nMinHeight, it->maMinimalItemSize.Height());

                    long nGrowContentWidth = 0;
                    long nGrowContentHeight = 0;

                    if( it->maItemSize.Width() < nMinW )
                    {
                        nGrowContentWidth = nMinW - it->maItemSize.Width();
                        it->maItemSize.Width() = nMinW;
                    }
                    if( it->maItemSize.Height() < nMinH )
                    {
                        nGrowContentHeight = nMinH - it->maItemSize.Height();
                        it->maItemSize.Height() = nMinH;
                    }

                    // grow the content size by the additional available space
                    it->maContentSize.Width() += nGrowContentWidth;
                    it->maContentSize.Height() += nGrowContentHeight;
                }

                // keep track of max item size
                if ( it->maItemSize.Width() > nMaxWidth )
                    nMaxWidth = it->maItemSize.Width();
                if ( it->maItemSize.Height() > nMaxHeight )
                    nMaxHeight = it->maItemSize.Height();
            }

            ++it;
        }
    }
    else
    {
        nMaxWidth  = nDefWidth;
        nMaxHeight = nDefHeight;

        ImplAddButtonBorder( nMaxWidth, nMaxHeight, mpData->mbNativeButtons );
    }

    if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE )
    {
        // make sure all vertical toolbars have the same width and horizontal have the same height
        // this depends on the used button sizes
        // as this is used for alignement of multiple toolbars
        // it is only required for docked toolbars

        long nFixedWidth = nDefWidth+nDropDownArrowWidth;
        long nFixedHeight = nDefHeight;
        ImplAddButtonBorder( nFixedWidth, nFixedHeight, mpData->mbNativeButtons );

        if( mbHorz )
            nMaxHeight = nFixedHeight;
        else
            nMaxWidth = nFixedWidth;
    }

    mbCalc = false;
    mbFormat = true;

    // do we have to recalc the sizes ?
    if ( (nMaxWidth != mnMaxItemWidth) || (nMaxHeight != mnMaxItemHeight) )
    {
        mnMaxItemWidth  = nMaxWidth;
        mnMaxItemHeight = nMaxHeight;

        return true;
    }
    else
        return false;
}

So I looked through the code, but didn’t understand it and didn’t want to. However, it was easy to see the change was reasonable and helpful in some cases. So I submitted it to Gerrit to see if it could get it reviewed and approved. If I can sneak it into a daily build, then maybe I could convince someone to try it out. So I submitted and waited for input. 3 days later, Caolán McNamara of Red Hat reviewed and accepted the patch. In fact, Caolán appears to be an email alias that 3 developers are attached to. I think Arch is a better distro for me than Fedora, but I am very grateful for the useful investments that Red Hat is making.

Once my patch got into the daily builds, I emailed the tester asking he could try one out, but he replied that he didn’t have time. So I was stuck and frustrated again. I couldn’t know if the change fixed the bug, which made me uncomfortable to ask for a patch to be triple-reviewed and back-ported. Blind-fixes to stable branches are generally not a good way to work.

I also didn’t know how to submit changes to anything other than the master branch. The LibreOffice wiki is great for new developers, but didn’t cover that specific topic. So I decided to ask Caolán if he could submit them to Gerrit to get them in before the 4.2.3 release. Caolán did that and even sent me the Git incantations so I can do it in the future.

With some reviews from Norbert and Miklos Vajna, the patch got into the 4.2.3 branch. So I was very happy, but not for very long. Because I soon noticed that the final 4.2.3 RC build had already been made. You can still push changes to the Git branch, but it doesn’t matter, the digital equivalent of air guitar. It is possible to mark bugs as release critical and delay the release, but this didn’t meet the bar. I should just have been happy that the issue was likely now fixed, but instead I was upset that after all my stress it had missed the train by a few hours.

However, the Heartbleed bug and a few other important ones showed up, and so another RC was made. I’m probably the only person on the Internet, other than the NSA, who was happy for Heartbleed.

KDE Regression

Just as LibreOffice 4.2.3 was shipping, another bug showed up from a KDE Ubuntu user:

Someone with a 1920×1080 15.6” monitor was seeing the HiDPI mode kick in. This is a bad bug because it is a regression. The goal of the feature is to improve the experience for HiDPI users, not break it for everyone else. Degrading a product for other people is the fastest way to get your code reverted.

This would have been stressful for me, but several weeks earlier I had studied the Linux DPI detection code and multi-monitor support. Since I knew exactly what 4.2.3 was doing here, I didn’t worry about being able to quickly solve the problem. I just needed to figure out what data LibreOffice was getting from the OS. You can stare at code as much as you want, but if you depend on hardware-specific information, you can’t prove it correct until you test on other computers.

I had taken the time to learn the code because I submitted a patch to LibreOffice for 4.3 that simplifies it to only fetch from xrdb and never bother to fetch from X Windows. I found the information unreliable for my laptop. On my machine, X tells me it is 96 DPI on a 33” by 18” monitor. It is pretty impressive to squeeze all that into a 13.3” screen. The patch to ignore X isn’t in 4.2.x, but that wasn’t a problem because the hard part is understanding the code. The tester was very helpful in quickly giving me the information I needed.

The problem is simple to describe. The monitor was 141 DPI, but X said it was 139×144. Of course it is crazy with bad data of different DPI values in the X and Y direction, but that was irrelevant here. The issue was that LibreOffice’s doubling kicked in at 144 DPI in the Y direction:

mnDPIScaleFactor = std::max((sal_Int32)1, (mpWindowImpl->mpFrameData->mnDPIY + 48) / 96);

144 + 48 == 192 / 96 == 2

I could think of several fixes, but I wasn’t sure what was best, so I decided to ask Kendy who had written that line of code. Within a few days, he submitted an improvement that will not cause this new mode to kick in until at least 168 DPI. That fixes the problem for this machine, and hopefully others. So with these fixes, things are in decent shape. The next issue is Unity, which is currently broken.

Unity

While LibreOffice can look good with Gnome, KDE, and Xfce, I hadn’t tried Unity. It is difficult to get it running on Arch because it has patches to a lot of key components they’ve not convinced upstreams to accept. And so I’d have to replace a lot of system packages, and I didn’t want to deal that risk for my personal laptop.

Unity isn’t even the only environment Ubuntu supports, but it is their premier one and so I had been curious. The Unity team had done a bunch of HiDPI work for version 8, and so I hoped it would work. Ubuntu 14.04 is shipping 4.2.3 with the LibreOffice icons prominently placed on the dock.

After hearing nothing for months, I tried out a live USB image of the final Ubuntu 14.04. Unfortunately, I discovered that even though they based some of their work on the Gnome 3.10 design, they didn’t fix the xrdb values. I could also find no way to force apps to be 192 DPI, as the other environments enable. Apparently there are new Unity APIs.

I wish Unity would fix their xrdb values. I don’t know where the Unity documentation is or how to write Ubuntu-specific code on LibreOffice. I recommended to Ubuntu’s developer, Bjoern Michaelson, to requisition a new machine. For now, it doesn’t work on Unity and the fix is unknown.

The end, for now

This story ends, but there is plenty more that can be done. It would be great to have higher-resolution toolbar bitmaps, but it isn’t high priority because only a few are pixelated. The Mac is still broken. It appears that the OS doesn’t work in pixels on retina displays. Good luck fixing that.

The splash screen is a little embarrassing, but is is only visible for a moment. I found the relevant code in splashx.c, but didn’t find an easy fix because this early code apparently can’t use the BitmapEx class with its scaling routines. In fact, it often draws bitmaps pixel by pixel. Maybe someone can just make a bigger splash screen and fix the progress control.

The status bar still needs to be improved. The bitmaps look fine but because the layout is done in pixels and stored in an XML file, there is no way currently to make it be different widths for normal and HiDPI screens.

The hyperlink dialog box has a few problems:

HyperlinkLO423

The Insert-special characters dialog needs to be taller by default. The letters are all much too small. I had spent some time looking through the code but never managed to find the place to make a fix. Fortunately, the dialog box is resizable so this isn’t a big problem.

It also needs testing on Windows 7, although from my casual re-reading of the MSDN documentation, it should work.

The underline wave character property isn’t scaling yet. I didn’t bother with that because it is very little used compared to mis-spellings, and is a more complicated codepath.

The line styles toolbar dropdown preview draws lines too thin. I looked around the code, but it was very voluminous. Kohei Yoshida spent a couple of weeks re-working it recently so I’m hoping when he gets a new laptop, he’ll quickly notice and be able to fix it.

It doesn’t appear that multiple monitors of different resolutions is handled properly in LibreOffice. Fixing that could be tricky. So the work continues!