Hacking Webkit fail

I have just had one of the most dispiriting and unfruitful afternoons trying to code, ever. I found a WebKit bug, tried to fix it, and massively failed. I am still convinced that it is a simple twenty line job, but I have not had an easy time.

Firstly, every nasty thing I have ever said about programming on Windows is almost certainly true. I downloaded well over a gigabyte of SDKs, APIs, DLLs, Visual C++ updates and did not get very far (this one weighs in at 400MB; what is that all doing?). Windows 7 messes up the registry and it will not build. I fixed that (will post to WekKit bugzilla later):

Index: WebKitTools/Scripts/webkitdirs.pm
--- WebKitTools/Scripts/webkitdirs.pm   (revision 57467)
+++ WebKitTools/Scripts/webkitdirs.pm   (working copy)
@@ -1052,8 +1052,9 @@ sub setupCygwinEnv()
 sub dieIfWindowsPlatformSDKNotInstalled
     my $windowsPlatformSDKRegistryEntry = "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1";
+    my $windows64PlatformSDKRegistryEntry = "/proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1";

-    return if -e $windowsPlatformSDKRegistryEntry;
+    return if ((-e $windowsPlatformSDKRegistryEntry) || (-e $windows64PlatformSDKRegistryEntry));

     print "*************************************************************\n";
     print "Cannot find '$windowsPlatformSDKRegistryEntry'.\n";

(Note—if you want to get WebKit to build, change the two lines marked with a – to + in the webkitdirs.pm file.)

Secondly, of all the open source projects I have written patches for, WebKit wins as having the most impenetrable, impossible code. Admittedly, the CSS parsing and rendering engine is not the most accessible piece of code, but I reckon now it would take a good couple of days fiddling before it all come together enough in my mind to actually do anything productive. Even so, the code is extraordinarily unwelcoming. Crucial files a dozen thousand lines long have not a single variable explained at all, and searching for all instances of the names in files reveals that most of them are not explained anywhere at all. Some of the names are easy to guess, but many are not, and I have read swathes of specifications from the W3C, IETF, IEEE, so I am hardly new to most of the jargon.

It was meant to be a restful Sabbath, away from the stress of work and tasks, but I got angry and put more pressure on myself to get the patch done before Monday. The simple, annoying, and humbling thing is that the code is just too in-depth to jump straight in with no assistance provided. Humbling, because I learned something that I forget a lot: I am no good at coding. When I pick up a KDE application with copious documentation and some of the functions even commented to explain their purpose, I am not doing something great when I add on a feature. It feels like it, but it is not until I hit a massive, crazy codebase that I appreciate how much dependence I have on others’ help.

This was all on my mum’s laptop, so she will be thrilled to have the SDKs at any rate. The happy end to the story is finally had an incentive to fiddle around with network bridges to get internet to my (linux) desktop. After reading the HTTP specs, it turns out there is a box you click for it on Windows (Clt-select the two interfaces, right click, and select ‘bridge’; no icon, but it is there—on linux, as we know, we use addbr). With internet on the linux box, 40MB of libraries are all that is needed to get WebKit up and running from SVN, with no problems at all.