Every fix doesn’t call for a blog post, but this one deserves it. It all started when Jonathon Jongsma found a way to make text disappear in QtWebKit on May 27th. So he raised a bug. He and I started working on fixing it. We rapidly found that WebKitGtk was also affected, but it was unreproducible on the Mac port.
We dove into the code: “grep selection”, GraphicsContext::drawText(), Font::drawText()… but nothing was really different (there) in the Qt or Gtk port which could explain why the text wasn’t being redrawn when changing the selection.
That’s when I discovered git bisect. Since we had established that the bug wasn’t there when QtWebKit was snapshot for Qt 4.4.0, I had a good place to start. So after recompiling QtWebKit some 15 times (yes, it took around 3 work days!), it pointed me to this changeset. Lucky for us, it was related to the bug (text rendering).
After some digging into the patch, I contacted the author, Dan Bernstein at Apple, and we looked at it together. In little time, he was able to find how to reproduce it on the Mac too. This was now a WebKit wide bug! Some back traces later and some trials: we came up with this fix. Pretty simple, isn’t it? barely 16 chars. Yet, these 16 chars cost around 1200$* in direct labour time and 3 engineers were involved.
Some will say this could have been prevented with proper tests. It happens that it was a special case on the Mac, but all other ports always went through it. Dan now added a pixel test.
The morals of the story are:
- bug fixing is costly (haven’t we heard that in school?)
- you never know when someone will hunt you back about your patch
- git is a cool beast (in fact, it just convinced me to use it)
One question lasts: how come it took over a month and a half before someone found it?
* This number is based on market mean hourly rate since exact rates are unknown
Side note on the WebKit party
It was really cool to get to San Francisco and finally meet IRL other WebKit devs. Kudos for the event!