Archive for June 3rd, 2006

Oh shit. Code-a-thon

Saturday, June 3rd, 2006

So, I got this hair-brained idea yesterday on how to fix one of the bugs in Super Faviconic…
Basically the problem was this:
When Super Faviconic is running, Safari(WebKit) can be downloading new favicons. However, Safari(WebKit) does not immediately write the favicons to disk. Instead it caches the favicons in memory and by some retain count mojo (I’m not really sure how it works) it eventually syncs it’s in-memory DB with the on-disk File DB. So, when surfing in Safari and browsing the icon cache in SuperFaviconic, there was always a delay between when a new site favicon was downloaded and when it was synched into the File DB for Super Faviconic to read in.

Anyhow, my hair-brained idea to fix this bug turned out to be a totally egregious hack. And it goes something a little like this…
Part a) Build a WebKit Cocoa plugin that responds to new icons being downloaded.
Part b) said plugin will then notify Super Faviconic of the impending database change via Cocoa distributed notifications. (I know, genius/insanity at it’s best).
Part c) Super Faviconic readies its internal icon cache for an impending change.
Part d) said plugin then forces WebKit to synchronize it’s in memory DB to disk. (by some really unkosher private variable access, yuk).
Part e) Now that the new icons have been written to disk, Super Faviconic then pulls the new icon index into memory and re-displays the browsing tables based on the new notification.

…in five easy steps parts. Except, now of course, I have the small requirement of the user having to install the plugin if they want live Favicon DB browsing. Which, I guess I can explain easily enough (I think it’s a good feature). Also, I now have to write some code to get Super Faviconic to both recognize that Safari has been launched (easy) and recognize whether or not said plugin has been installed. Which, shouldn’t be all that bad.

But to the point of the matter: It’s now 6am. Furthermore, my (very lovely) girlfriend has been asleep in bed with no one to cuddle with. I know I’m very definitely going to get the shit end of the stick for this offense. Now, even though I’m in the dog house for now, I’ll still take the time to realize now that I truly enjoy this type of reckless code hacking. This is the first time in a long while that I’ve sit down and wrote some righteous Cocoa code. You may not understand what’s so great about what I’ve built. But I look upon it and it is good. Trust me on that.