Tuesday, 31 May 2005


David Reveman just demoed his latest Xgl work (an X server based on Glitz). It's incredibly impressive. He has virtual desktops as the faces of a cube, so you can switch desktops by rotating the cube. Then he played a movie in a translucent window, crossing a virtual desktop boundary so it wraps around the cube. Of course it keeps playing while he rotates the cube. All very smooth and pretty. Amazing.

It looks like on Linux the preferred hardware acceleration story for rich apps like Mozilla/Firefox will be to run the Xgl X server, and have Cairo talk to Xgl via Xrender. Xgl implements the Xrender calls using GL so we get the same sort of hardware acceleration we'd get if we used Glitz directly. With only Xgl talking to the GL drivers, we avoid the problem that the vendor GL drivers aren't very good at handling multiple processes banging on them simultaneously. The only downside is that Xrender doesn't support some of the operations we need accelerated --- e.g., gradients, non-affine transformations, and SVG-style filters. We'll just have to fix that :-).

The story on Windows remains a bit less clear...

Friday, 27 May 2005


I'm currently at the XTech conference in Amsterdam. It's been lots of fun to meet up with people again ... Mozilla people, Novell people, and other people who I've interacted with online but never met face to face.

Amsterdam is an interesting city, dominated (to my mind) by bicycles and canals. I like seeing all the people on bicycles although it is hard to get used to pedestrians being distinctly third-class. I really enjoy just walking around the city ... it's about a 35 minute walk from my hotel to the conference centre, but I'm not tempted to catch a tram or taxi. I had a really good time with Martijn on Tuesday just walking around the central city area. But I get no feeling of "I'd like to live here" ... I guess Auckland has me hooked.

The conference technical talks have been good, especially given there was no real peer review selection mechanism.

A person from the BBC Creative Archive gave a good talk about the potential for users to remix and build on existing digital content and it's exciting to see the BBC making their content avaiable for this --- although the restriction to UK users is a bummer.

The XAML/Avalon talk was almost exactly what I expected. Rob Relyea focused on technical advantages and steered away from any direct discussion of a confrontation with the Web ... though Microsoft's desire to supplant the Web remains completely clear. One interesting point was that the Avalon team prioritizes ease of tooling over ease of hand editing. Another was that most of the demos relied to some extent on 3D effects, something that Cairo doesn't directly address. We need to work on our story there.

I gave my talk earlier today and it seemed to go down rather well. Here it is (apologies if it didn't all get through, uploading files to Moveable Type is a pain!). My main theme is that browsers are now or very soon shipping technology to do rich graphics on the Web --- SVG and <canvas> in particular --- and it's time for developers to start using them. These technologies don't force you to dive down into Flash; you can incrementally extend existing Web pages with existing scripts and CSS styling. This ties into a general theme that people have been pushing at this conference: that the Web can and is evolving, and there is no need to tear it down and replace it with something else.

I think the highlight was my demo of SVG foreignObject in my Cairo build. I really have to thank God for this demo; I was up all night working on it and not until the last minute did I get it working reasonably. Basically I modified our implementation of foreignObject in my Cairo-based build (which I just recently got working with SVG and canvas) to "do the right thing" ... painting the foreign content is subjected to SVG transforms, and event coordinates are translated appropriately. Interestingly, the latter was a lot harder than the former to get right. Of course this build still has many bugs, and performance is pretty bad too. But it's a nice demo. It's much more impressive live, when you can interact with the rotated/scaled content, type into the text fields, scroll, click on links, and so on.

30-degree rotated HTML

Update! Apparently there actually was peer review in most cases. Sorry Edd!

Friday, 20 May 2005

Landed Canvas drawWindow API

I just checked the drawWindow API into trunk, so nightly builds and Deer Park will have it. Please test it out. I'm particularly interested in the results on the less popular platforms --- Mac, Linux on weird architectures, etc. I'm also interested in pages that render incorrectly via drawWindow. I know plugins won't work (except WMODE=transparent Flash should work) --- we can't fix that. File bugs on problems you find and CC me.

Thursday, 19 May 2005

Socialized Medicine

Every so often I hear Americans who believe that their health-care system is the best on the grounds that certain treatments available in the USA are not available, or less common, in other countries. I also hear some New Zealanders saying the same thing. It enrages me. For example, an American friend once said, without arrogance, "my relative lived in New Zealand and got cancer and of course had to come back to the USA for treatment, because, you know, socialized medicine". It wasn't a put-down, it was just a simple statement of what was obvious to her.

In fact, I believe that the US health system is very poorly designed and implemented. Whatever advantages it has are mostly due to the fact that more money goes into it than in any other country (in most cases, very much more). And who accounts for the time and frustration invested by the health consumer? Here's what's been happening to us:

We've been getting bills from our paediatrician (actually their outsourced billing service) for services that should have been covered by our insurance company (Aetna) --- regular checkups and immunisations. Aetna's online accounts show that the billing people submitted charges twice for the same services; they show that Aetna paid once and refused to pay the other. So we called our paediatrician's clinic a few times --- took a while to get someone, timezone issues, and no-one wants to call us back (maybe they don't know we have phones here). They told us we have to talk to billing. Call billing a few times, get a machine, leave messages, not returned. Forget about it for a while. More bills. Tempted to ignore them, but don't want to provoke international diplomatic crisis. Call billing again, get a human being, who says that Aetna never paid them, Aetna had sent them a form saying they didn't know who the charges are for (despite the fact that they paid bills for the same kids, same place, many times before), so billing just resubmitted the charges again hoping they'd go through. Billing promises to sort it out with Aetna, now that we've provided "more information" (that they already knew).


  • Someone is lying about whether Aetna paid out.
  • Billing is incompetent. (Why keep sending us a bill while you know there's a problem between billing and Aetna? Why do I have to call before you try to resolve it?)
  • Everyone has lousy customer service.
  • Whoever idolizes a system which requires us to wrangle three parties who blame each other while we try to avoid the debt collectors should be thrown in a river.
  • The most compelling feature of this system is that the insurance companies and billing agencies can reap free money when the customer pays out due to ignorance or exhaustion.

This is not an isolated case. This kind of thing only happened once to us in the ~4 years that we consumed US health services (OK there were a couple of other billing mistakes that created surprise charges for us, but they were easily sorted out), but it's happened to several people I know, some of them more than once.

Here's how the system here has worked for the regular checkups and immunisations we've had so far. We go to the nearest clinic (either the Plunket nurse's clinic or one with a doctor). The first time at the doctor's clinic, we filled out a form identifying it as our local clinic. The staff take our names and addresses. We pay a copay ($10 or so). That's it. No bills, no insurance companies, no billing agency, no hassle.

So maybe the USA gets great outcomes from vast amounts of money. Good for them. But if you want to emulate them, I suggest emulating their expenditures before emulating their structures.

BTW, you can get private health insurance here if you want it.


I'm going to be out of town for three weeks, until June 12. It's a big, long trip but if you're going to go to the other side of the world, you might as well fit as much in as you can.

On Monday I'm heading off to the XTech conference in Amsterdam (May 25-27). A lot of fun people will be there --- Mozilla people, Opera people, Web standards people, even Microsoft people. It's a chance to reconnect with people I work with on-line every day, and I will also get to meet some people I've never met in the flesh before. On Thursday I'll be presenting a talk about rich graphics on the Web and Mozilla's implementation.

After that I'm going to GUADEC (May 29-31), the big GNOME conference. The schedule looks really interesting and I'm looking forward to getting to meet more GNOME people. Some of my Ximian team will be there too.

Next I'm going to Nuremberg along with other Ximian folks to meet our SUSE colleagues for a few days. This is another chance for me to meet a bunch of people I work with but have never met face to face ... including my boss. That should be interesting.

On June 4 I fly on to Boston. I'll be at our Boston office for the following week, doing some work and getting to know my Ximian buddies better. That will be really valuable. At the end of the week a close friend is getting married near Boston, and I'm incredibly grateful to be able to be there. I fly out on June 12 and should get home on the 14th having circumnavigated the globe!

I'll be offline most of the time I'm on the road, since I'm too lazy to wrangle mobile networking and I try to spend all my time meeting people and having fun. However, I should be connected during the days I'm safely at Novell's bosom in Nuremberg and Boston.

Saturday, 14 May 2005

Rendering Web Page To Images

For a long time now, people have been asking for ways to use Gecko to render a Web page to an image. Creating thumbnails of a Web page is one common desire, but there are lots of potential uses, especially if the feature is available to scripts. I have implemented a new DOM API in 1.8/FF 1.1 that makes this possible. It builds on the canvas element that has recently been implemented in Gecko 1.8 and will be enabled by default soon. (My patch hasn't been checked in yet either, so you can't try this at home just yet.)

To demo this API I've implemented a very simple extension that displays a "thumbnail view" of the currently loaded page in your sidebar. Here's a screenshot. Below is the core source code for the extension. The extension itself is no big deal, and I'm hoping the wonderfully imaginative extension developer community will take this and run with it.



<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>

<script type="application/x-javascript" src="chrome://thumbview/content/thumbview.js"/>
<vbox flex="1" id="before"/>
<html:canvas id="canvas"/>
<vbox flex="1" id="after"/>


function update() {
var w = content.innerWidth + content.scrollMaxX;
var h = content.innerHeight + content.scrollMaxY;
if (w > 10000) w = 10000;
if (h > 10000) h = 10000;

var container = document.getElementById("win");
var canvasW = container.boxObject.width;
var scale = canvasW/w;
var canvasH = Math.round(h*scale);

var canvas = document.getElementById("canvas");
canvas.style.width = canvasW+"px";
canvas.style.height = canvasH+"px";
canvas.width = canvasW;
canvas.height = canvasH;
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvasW, canvasH);
ctx.scale(canvasW/w, canvasH/h);
ctx.drawWindow(content, 0, 0, w, h, "rgb(0,0,0)");

var NavLoadObserver = {
observe: function(aWindow)

function start() {
var obs = Components.classes["@mozilla.org/observer-service;1"].
obs.addObserver(NavLoadObserver, "EndDocumentLoad", false);

window.addEventListener("load", start, false);

Currently the drawWindow function can only be used by "chrome privileged" content, because untrusted Web content could abuse it in various ways. So extension authors and XUL application developers can use it, but normal Web pages cannot.

Update! I overhauled this entry significantly since we may not be adding a method to 'window' after all. The drawWindow method will be there though.

Tuesday, 10 May 2005

Light-Weight Instrumentation from Relational Queries Over Program Traces

Good news! OOPSLA 2005 has accepted our paper on Light-Weight Instrumentation From Relational Queries Over Program Traces by Simon Goldsmith, Alex Aiken and me. This is work I did with Simon in the (northern) summer of 2003 while he was an intern at IBM.

I'm glad to see this work get published; I think it's an exciting new area of research. The idea is to express dynamic program analyses (e.g., "how many times does function A get called during an invocation of function B") as SQL-like queries over a database containing a full trace of the program execution --- but instead of actually building such a database, our compiler translates the relational query into instrumentation code that gets injected into the program to evaluate the query on the fly as the program runs.

Monday, 9 May 2005

The Language Of Doom

I always wonder why most people barely care about "nuclear proliferation". Is it because the name is so mundane? What would be a suitable chilling phrase to refer to the widespread acquisition of nuclear weapons by the petty, the bitter, the paranoid and the xenophobic?

Perhaps if the possibility kept more people awake at night, our leaders would give it more serious attention. Honestly, one of the main reasons I was (and am) against the war in Iraq is that it's distracted the world, and especially the USA, from the far more serious problem of North Korea. But I can hardly blame politicians for that when most of their voters could hardly care less. It seems inevitable that nothing much will be done until we lose a major city to terrorists or an accident. I expect it will be New York or Washington. Unfortunately by then it will be very hard to turn things around.

Friday, 6 May 2005

Cairo Progress

In between checking in layout patches and fixing regressions, I've been pressing on with cairo integration. I've done a couple of major things since the last update:

  • Glitz integration. I have Mozilla builds running with Glitz. Unfortunately there are some serious bugs that would make it embarrassing to post a screenshot right now.
  • Drawing text using cairo. Up till now we've been using Xft to draw text. I updated to the latest cairo version and modified our Xft-Pango code to do Xft-cairo-Pango. This means we use Xft and Pango to do glyph selection and text measurement, and use cairo just to render the actual glyphs. This seems to work quite well. Eventually we will use cairo to measure text instead of Xft. On Windows and Mac we can't use Pango (since we want everything we distribute to be MPL-compatible), so we'll have to reuse more of our existing font code.
  • I also fixed various bugs in our cairo glue ... translucent images need premultiplied alpha, some clipping wasn't implemented, etc.

Next I need to fix some of the more glaring rendering bugs and then I'll start experimenting with SVG/HTML integration (but I'll have to get SVG working; it's currently broken in this build).

One issue which I'm putting off is the fact that native GTK2 themes don't work in cairo --- GTK themes want to draw into a GTK rendering context (naturally enough), and we don't have one. Among other things, this means that Firefox menus are transparent, because their background isn't drawn. I think we can rig something up by having nsNativeThemeGTK render to an offscreen pixmap if a GTK rendering context isn't available, then copying that pixmap to the Cairo context. (Ultimately GTK2 itself will render using cairo and hopefully then this issue will have a cleaner solution.) In any case this is not a priority right now.