Thursday, 29 March 2007

Questions That Must Be Answered

Who --- or WHAT --- is the figure at the centre of this picture?

Chewbacca? Bigfoot? Jamie Zawinski?



Sunday, 25 March 2007

Text Text Text

I'm well aware I haven't blogged for a while. Things have been extremely busy. After I checked in code to implement the new textrun abstraction on Mac and Windows, there were some performance and correctness regressions. Bad me! I've fixed the Mac performance regressions and we have a fix in hand for the Windows regressions ... thanks to some heroic wrestling of VTune by Chris Double. Another thing I broke was the display of "missing-glyph boxes" when the user has no font with glyphs for a given character. To fix that I've done a cross-platform implementation of Pango-style "hexboxes" --- when glyphs are missing, we draw a box and inscribe inside it tiny hex characters with the character index we're missing glyphs for. It should be very useful for debugging complex scripts (and for users who've memorized the Unicode character table).

With those fires waning I've spent time working on the new textframe code. The gfx side is working pretty well for now and apart from the outstanding regression fixes, what's on trunk is adequate to support the new textframe. First I polished off a number of bugs triggered by our pageload performance test suite, so I could get some performance data. Then today I fixed a bunch of bugs triggered by our "reftest" layout test suite. All these tests work correctly now as far as I know. All these new-textframe fixes have been landed on trunk so it is now possible to build and test the new-textframe code and expect to be able to actually browse. This just requires you to set MOZ_NEW_TEXTFRAME=1 in layout/generic/Makefile.in. There are still lots of bugs, I'm sure; I know there are serious bugs in caret movement. There are also areas I've barely tested yet such as complex script handling and preformatted tabs.

Performance of new-textframe is interesting. Right now it's a slight slowdown in my Mac tests. However almost all the text-related performance cost is in textrun construction, and I've looked carefully at the textruns that are being created in our test suite. The current trunk code usually creates one textrun per word and caches them; the new textframe creates one textrun per run of text with a uniform font, but doesn't use a cache. The current code creates 28K textruns while the new code creates 21K textruns, but the textruns in the new code are much longer on average. The good news is that 8K of those 21K consist of a single space! Optimizing that will be easy. Furthermore if we cache textruns for use with the new text frame (which can be done quite efficiently), then we should get a 30% hit rate which will further reduce the textrun construction cost. So I think we can quite easily turn new-textframe into a significant net performance win.

Tim Rowley is working on integrating textruns into SVG text. He already has prototype code that works reasonably well. Transitioning SVG from the cairo toy text API to gfxTextRun has immediate benefits --- in particular gfxTextRuns implement font substitution, so non-complex international scripts (e.g., Chinese) will be displayed properly as we fall back to Chinese fonts when the default font does not contain glyphs for Chinese characters. It will take more work to support complex scripts with clusters, though.

One problem we've noticed is that SVG text requires bidi reordering. This means that when you have mixed-direction text (e.g. Hebrew and English in the same line) it's possible for SVG <tspan> and other elements to require "splitting" because a single <tspan> may be rendered as multiple discontiguous pieces. This is really tricky stuff. We've already implemented it for HTML+CSS and I'm not looking forward to implementing it again. According to SVG people it's "OK" for SVG to duplicate this functionality because it's done in a "compatible way" so in theory we can share code. But in practice we already have our bidi code tied into the HTML/XML/CSS code and extracting it for reuse with SVG would not be at all easy, especially given that we must avoid slowing down the existing code paths. There is another way that might work, though: have SVG create hidden HTML-style layouts of its text content, applying the HTML text layout engine including bidi processing. Then SVG could take apart the resulting HTML layout and massage it for display SVG-fashion, even including drawing text along a path. Not easy, but perhaps the best way forward. We'll see.

There are other exciting things going on. Offline apps are moving ahead; we've landed significant offline app support on the trunk so a number of interesting demos are possible with Firefox nightly builds. I think other people are blogging about that. There's good discussion going on regarding a first-class <video> element for HTML, and we are preparing to implement it. I spent quite a bit of time reviewing some cool new drag-and-drop code --- download a Firefox nightly build and try selecting content and then dragging it. And a new contractor started work in our Auckland office on Monday.

Looking forward, OOPSLA submissions closed on Monday so I'll have to spend 2-3 of the next six weeks doing OOPSLA reviews, which will be challenging but fun. There are a lot of really interesting-looking submissions. I'm also working on preparing the Amber debugger code for release. Unfortunately I have to rename everything because there's some BIOS debugging tool already called Amber ... I've chosen the name "Continuum" instead. And in just over two weeks I'll be in Mountain View for nearly a week, for a Mozilla Corporation all-hands meeting. When I get the chance I'll be driving the new textframe forward and fixing textrun-related regressions. It's all on!

Update I'm thinking maybe "Chronicle" for the debugger instead. If anyone knows of a project that's using that name, let me know! There's is some blog-related project with that name, but it looks pretty dead (and pretty far away in subject, anyway).



Monday, 12 March 2007

Festival Mania

Last weekend we had the annual Lantern Festival celebrating Chinese New Year. I didn't get to go this year but the rest of the family did. Great fun as usual.



This weekend was the start of two weeks of the Auckland Festival '07. Yesterday we went to the Pasifika Festival at Western Springs. These lakes are a brilliant setting for hundreds of stalls and stages showing off the crafts, food, and culture of the different people groups of the South Pacific islands. I usually loathe "put the natives on the display" sort of cultural performances, but Pasifika feels very different, perhaps because so many of the 200,000-odd visitors are New Zealand Polynesians themselves, so it's more about people sharing their cultures with each other. We arrived at 10:30 and left at 1:30 which worked out well, since we avoided the worst of the heat and the crowds. Very highly recommended. Unfortunately we missed the fireworks at the Domain which I hear were also fabulous.



Today we skipped festivals and had teppanyaki lunch at Daikoku at Botany Downs shopping centre. This is a great deal --- $13 each for plenty of very tasty food cooked at your table. Our chef today was a real showman with a repertoire that was new to me, such as flicking pieces of fried egg into customers' mouths. A few of his other tricks, such as throwing raw eggs into the air and catching them in a bowl at the other end of the table, didn't quite come off, but it was all great fun. The kids loved it. (There's another Daikoku on Quay St downtown that offers the same deal.) After that we went to the nearby Panmure Basin for a walk around the water's edge. It's a beautiful spot, and like much of Auckland's beautiful geography, it's a reminder of Auckland's violent volcanic past --- being one big explosion crater formed by a phreatomagmatic blast. For now it's very peaceful. At one end of the basin is a model railway with trains you can ride on, built and operated by the Auckland Society of Model Engineers, which runs from 1pm to 4pm on Sundays. Our kids love it.



Thursday, 1 March 2007

Miscellany

Novell has generously granted permission to release Amber as open source. I need to choose a license and a place to host it. Currently I'm thinking GPL and Google Code. The GPL isn't too restrictive because applications talk to the query agent using a pipe, so a debugger frontend or whatever would not be required to be GPL.

I've been doing more wrestling with ATSUI to try to handle some tricky Hindi text. Hindi is basically left-to-right but sometimes a vowel that comes logically after a consonant is actually rendered to the left of the consonant. In this case ATSUI reorders the vowel visually which confuses our textrun infrastructure, because it depends on characters proceeding in a uniform direction. I'm dealing with this by fusing the reordered characters into a single atomic cluster. This is suboptimal, because you can't select part of the cluster or place the caret within the cluster, but it's probably good enough.

Beyond that, I've made considerable progress on the new textframe. It can now display many Web pages without crashing. I've also got textruns refactored so that all platform-specific code is isolated to gfxFont and gfxFontGroup implementations; most of the platform-specific code is code to use platform APIs to extract positioned glyph data, which is then stored in gfxTextRun (which is now the same code on all platforms). I've got Mac and Windows textrun setup implementations now too.

I'm going to be off work for a few days. Back at work on Monday, hopefully.

All four of us current and soon-to-be Gecko developers in Auckland met for lunch today. It was exciting!