Sunday, 30 July 2006

RGBA Windows

Today we had a sort of mini-hackfest at the office. Earlier in the week Larry Ewing had shown how to use Xgl+compiz's support for RGBA windows to implement window translucency in F-Spot in a very nice way, so I thought I'd extend Mozilla's translucent window support to use this mechanism. Up till now, on X we've only used the Shape extension, which only provides 1-bit transparency.

In a cairo build, it is almost no effort to implement. Basically you just need to call gdk_screen_get_rgba_colormap and make that the colormap for the toplevel GTK widget. A general patch for Mozilla will be a little more complicated because we need to set the colormap before "realizing" the widget, at which point we don't actually know whether the window will need translucency or not. I'm not quite sure what to do about this, but it might be OK to just always use RGBA windows all the time when Xgl and compiz are active (which we can detect).

Obligatory eye candy follows. The example is a standalone HTML document with a transparent background, containing HTML form widgets, script, and SVG.

Saturday, 29 July 2006

Worlds In Collision

I've had a great week up here in Boston with the rest of my desktop team. It really helps to chat in ways that wouldn't reach the acivation threshold required to send email or ping someone on IRC. Of course we've also spent a lot of time in more structured meetings. The downside is that I haven't been able to do much reviewing or bugfixing this week...

Yesterday I visited MIT. I reflected on the nature of my professional life as I rushed from a talk on the openSuSE build infrastructure to talking with a student about widening operators in abstract interpretation ... prior to giving a talk about my real work on Mozilla and the Web. The talk went well, I think, although there was less audience interaction during the talk than I expected, given that there were W3C staff present --- my talk chides the W3C a little, hopefully in a constructive way. In fact I was pleasantly surprised when Tim Berners-Lee introduced himself after I'd finished, although for better or worse he had missed the chiding part. I did manage to complain to him about the SVG spec a little bit, so I hope something useful got through :-).

On Saturday I'm off to New York, looking forward to seeing friends and giving the talk again at IBM Hawthorne. I just hope my voice is OK, I've been hoarse all week, I think a combination of a virus and too much chit-chat. I'd like to avoid a repeat of my thesis defense when I croaked my way through the talk and had to answer questions in almost a whisper.

Wednesday, 26 July 2006

The Good, The Bad, And The Three-D

Last Friday I visited Linden Lab, makers of Second Life, to spend several hours talking with Callum, author of UBrowser. UBrowser is an interesting Gecko embedding that needs to direct all rendering to an offscreen area so it can be transformed by OpenGL for display. A surprising number of people have contacted me over time requesting help with this kind of problem, and I'd like to have all these people collaborating on a solution that can be properly supported in the Mozilla tree.

We need to choose between two alternative approaches:

  • Extend existing Gecko ports, e.g. the Windows port, to support offscreen embedding
  • Create a new Gecko port that does not depend on any window system --- the "membuf approach" taken by the first effort in this space, Crystalzilla

The decision is not clear-cut. For a long time I favoured the membuf approach because it's somewhat cleaner, portable, and could run on headless servers. But with more thought and after talking things through with Callum, I favour extending existing platform ports, for the following reasons:

  • The changes required to Mozilla code turn out to be very minor. The membuf approach requires a significant amount of new code.
  • A separate membuf port would be poorly maintained compared to the platform code that everyone else uses.
  • Some important things such as plugins and native themes would be difficult or impossible with membuf.
  • There are a few things that are harder to do when the native platform gets in the way, but nothing major. For example Mozillla windows must be hidden. Platforms seem to be able to do this OK.
  • If support in headless servers is required, they'll just have to run Xvfb or Xvnc; not an ideal solution, but probably practical.

The plan is to work towards getting the UBrowser code ported to Linux and it and its support patches landed in Mozilla's CVS tree. Then people can use it as a starting point for their own embedding projects and start collaborating on improvements. The code is already xulrunner-based which is great.

Before my visit I had been confused by reports that plugins actually work in UBrowser, since I knew of no way to redirect plugin rendering to an offscreen bitmap. It turns out that the patch detects the offscreen painting case on Windows and asks plugins to print themselves via the NPAPI Print command, and Flash honours this. Other plugins such as Quicktime don't. We can't detect when the Flash plugin wants to repaint its window so UBrowser just updates it at 15Hz. Input events don't work in any plugin although that can probably be faked. On Linux we can probably solve these issues using the X Composite and Damage extensions, but I'm not sure what we can do on Mac or how we can complete the job on Windows. Nevertheless it's a step forward. It means that once we land this patch, the canvas drawWindow API will paint Flash content on Windows, which will be a nice bonus for the tab-preview extensions.

While there I also learned a lot about Second Life. It's a very interesting virtual world focused on the creativity and commerce of its residents. I think there's enormous potential for invention and fun --- and also vice. I certainly hope that people find ways to use it for more good than evil. Either way, I'm sure that Second Life is going to be extraordinarily successful.

Thursday, 20 July 2006


For a while things were going very well. The flight was good and I had a great weekend with friends here in California. Yesterday I went to IBM Almaden and had a lot of fun giving my talk and talking to some of the IBM researchers. There's some really cool Web-related, Firefox-related stuff going on there.

Then tragedy struck. Last night my laptop mysteriously died. It simply fails to boot with a "Fan Error". IBM's service people are shipping me a box with which I can ship it to them to be fixed. I have no idea if they'll actually be able to fix it and get it back to me before I leave California on Sunday. If not, I'm not sure what I'll do. I wonder why I can't take it somewhere to get it fixed quicker. The timing is terrible; it's significantly harder for me to get work done without it. I can however still meet up with people so I'll try to make the best of it.

I did have a good day today at the Mozilla Foundation offices, talking to people about a wide variety of things, and putting some faces to old names. I'm looking forward to more of that tomorrow.

Saturday, 15 July 2006

On The Road

It's time for another trip to the USA to visit friends and colleagues. I'm leaving on Saturday night and returning to New Zealand on Thursday August 3. During that time I will be a little slower than normal at responding to email and other communications.

I'll be in California for the first week. I'm giving a talk at IBM Almaden on Monday, mostly about the engineering and strategic challenges we're facing as we try to drive the Web forward and some ways in which people can help. I'll be visiting the Mozilla building and Google Tuesday through Thursday, talking to people about various works in progress. On Friday I'll be up in San Francisco visiting Linden Labs and talking to them about their use of Gecko. I might take some time to rove around the city; I always love to walk across Golden Gate Bridge. On the weekends I'll be catching up with some of my many friends in the Bay Area.

In the last week of July I'll be in Boston visiting my Novell Linux desktop team as we plan work for our next major release. I'm really looking forward to that since I've had very little face time with these people. I will also be visiting MIT on Thursday to give a similar talk and meet some friends there.

The following weekend I'm heading to New York to catch up with friends there, including my buddies at IBM Watson, and I'll be giving the talk again there.

It should be a ton of fun, God willing, as long as tunnel ceilings and tornadoes don't fall on my head.

Tuesday, 4 July 2006

Eighty Minutes Of Terror

Yesterday I was the featured speaker at the monthly meeting of the Auckland Linux Users Group. I gave a demo of some new features in SLED 10 and Firefox, and talked about Linux and Firefox development. It went well. However, it came very very close to being a complete disaster.

I was working on textframes most of the day. At 5:45pm I got to a good stopping point and turned my attention to preparing for the talk at 7:30pm. (AKLUG meets in our office these days.) I figured that nearly two hours would be enough time to get my laptop set up with our projector, and decide what to show and say, with a dry run.

After futzing around with the projector for a few minutes I decided I should reboot my laptop with the VGA cable plugged in, which sometimes seems to be necessary to get it recognized. Then my troubles really began, because some time ago I had applied software updates --- including a new kernel --- and I hadn't rebooted since. (Part of my problems may have come from the fact that I had a mishmash of packages from various beta versions and updates, not a single clean install.) Linux started up OK but Xgl (a major part of what I wanted to demo, of course) wasn't running, because the installed ATI kernel module didn't match the kernel anymore. So I started fooling around trying to get a new ATI driver installed by various means. During this phase I managed to erase the installed ATI X driver so that I couldn't start any X server at all! At one stage I tried to use yast2 to set things up via Novell's driver update Web site, but for that you have to register on the site, and since Firefox couldn't run it popped me into w3m, a text-mode browser. By this time I was more than a little panicky and I just couldn't get w3m to work.

By 7:20pm people had started arriving, I still had no graphics at all and running screaming into the night was starting to look like my best option. It was painfully clear that it would not reflect well on Novell if I stood up and said "thanks for taking the time to show up, but I COULDN'T GET OUR ENTERPRISE-READY PRODUCT TO WORK. Goodbye!" Yet I had lost hope; getting things working in the last five minutes after you've been working on it for over an hour just doesn't happen in real life. I also knew that even if I could get it working, I had no chance to prepare a talk or figure out what I was going to demo. My prayer was "Lord, help me to get this working, and I'll handle, um no, YOU'll have to handle the talk as well!"

I was more distraught than I have been in years. In some high-pressure situations, like childbirth, you're in the hands of professionals who you simply have to assume will do the best possible job. In other situations, like a car crash, it may not be your fault, or by the time you apprehend the gravity of the situation, there's nothing you can do. Facing the slow approach of a disaster of your own making, which you may or may not be able to mitigate, is an experience I wish to avoid.

Well ... by the grace of God, Hollywood endings do happen. I realized I could speed things up a lot by logging into my laptop from my desktop and running X applications that way. I found instructions for downloading the ATI installer and building a driver package that would work on SLED10, and they worked. I installed the driver, ran SAX, and everything came up correctly, Xgl, compiz and all. Wow. Of course I still had to give the talk and demo absolutely cold --- including demoing features that I hadn't actually ever used before --- but the off-the-cuff presentation seemed to work well. I even tried to explain the basic architecture of Xgl+compiz in a non-technical way --- which I realized immediately was very risky without having worked out my metaphors in advance --- and I think I did a decent job. Phoah!

I felt decidedly odd for the rest of the evening, a cocktail of delayed panic, relief, and enthusiasm. I felt jumpy. I didn't really settle down until I got home and poured out the story to my wife.