Fennec + CrunchPad?

TechCrunch has an ongoing project to design a “dead simple and dirt cheap touch screen web tablet to surf the web.” The latest version, Prototype B, looks pretty nice.

The device is currently running Ubuntu and has a Webkit-based browser. Arrington originally wanted Firefox to run on the tablet. I’d be interested to see how Fennec works on the tablet. Fennec is designed to work well on mobile-class processors with tighter memory requirements. Fennec is also designed for touchscreens and supports the same add-ons mechanism as Firefox. Since Fennec is built on XULRunner, other XUL-based apps (Songbird, Chatzilla) get a free runtime.

Anyone with a Prototype B can test out Fennec Alpha 2 for Linux Desktop.

Fennec Alpha2 – Performance

Fennec Alpha 2 is now available for download! Desktop versions are available too (Windows, OS X, Linux). While we added some good features in this alpha, the primary focus was performance. Faster startup. Faster page loading. Faster panning and UI interactions.

Faster, faster, faster!

Madhava made a nice video showing off Alpha 2. Even from the video, anyone who tried Alpha 1 can see that Alpha 2 is noticeably faster.

I thought I’d focus a bit on what we did to squeeze more speed out of Fennec, and the Mozilla platform in general. First, a big shout out to Taras Glek for finding slow spots and filing bugs to get them fixed. Taras worked tirelessly to find as many problem areas as he could.

Panning

Alpha 1 used a two layer system to implement panning. One layer panned the UI chrome – the URLbar, the tab sidebar and the browser control sidebar. Another layer, implemented in a XBL component, panned the web content. Both layers were children of a XUL , which allowed us to position and float elements relative to each other. The “hand-off” between the two systems – when UI panning transitioned to content panning – was sloppy and chrome panning was not very smooth.

Alpha 2 combines the panning layers into a single system, still contained in a . We removed the XBL component and now chrome and content pan together as a single unit. The result is much smoother panning. Also, the chrome UI parts are now located relative to the web content much better – in Alpha 1, the sidebars panned into view sooner than they should have.

I plan to cover more details of the Fennec architecture soon.

URL Autocomplete (Awesomebar)

We found that using elements to float chrome UI over the main window was a performance problem. In fact, any XUL element that creates a native OS window under the covers slows things down. The awesomebar autocomplete list uses a . We re-wrote the autocomplete list such that it was a in the main and the results were dramatic. The list displays much faster.

URLbar

We started with XUL similar to Firefox for our URLbar. We used a for the static caption and a to allow the user to type in a new URL. The elements occupied the same space, but only one was visible at a time. We used some JS code to hide/show the appropriate element.

We found that the process of showing/hiding the elements was taking a noticeable amount of time, affecting the perceived page loading time. We ended up removing the and we just toggle readOnly on the .

Favicon Indicator

A similar situation occurred with the favicon indicator. We initially used the same holding two elements – one for the throbber and another for the website’s favicon. Again, we were showing and hiding the images depending on situation. This time it was the that was the slow down – creates a native OS window. So we removed it and page loading appeared to complete a little faster. We kept the two image elements because the load time for the swapping the favicon image with the throbber image eclipsed any benefits of removing the show/hide code.

We also restructured the way we handled favicons to wait until the page fully loaded before updating the favicon indicator. Updating the indicator immediately, while the page was still loading, just caused the page load to take longer.

Canvas and Thumbnails

For panning and zooming performance, Fennec uses a canvas element as the main display surface – not a browser element. We copy the contents of the browser to the canvas. Updating the contents of a browser to a canvas is not cheap on mobile devices. Each drawWindow call can take ~300-400ms. On the other hand, drawImage is much faster – ~100ms. In Alpha 2, we switched to use drawImage as much as we could when updating the tab thumbnails.

Alpha 2 also uses the new MozAfterPaint event to optimize all DHTML updates to the the main canvas display surface. Whenever the contents of the web page changes, for whatever reason, we only update the areas that actually changed. We don’t repaint the entire canvas.

Post-Pageload Work

Any work that occurs after the page loads is potentially bad for performance. Users like to start interacting with page content as soon as possible. We had some slow code that transformed phone numbers into links. The tel: links can allow devices to auto-dial telephone numbers. The code was optimized quite a bit in Alpha 2 (see bug).

File I/O

Various places in the platform code we found spots where file I/O was slowing Fennec down, usually on startup. As Taras said on IRC – “File I/O on the n810 is measured in milliseconds” – probably not just limited to the n810. So we tried to avoid useless I/O whenever we could. Startup improved from taking around 30 seconds (yes) for a first-time, cold start in Alpha 1 to around 7-10 seconds in Alpha 2. A warm start improved from taking around 13 seconds down to 4-5 seconds.

One spot in the Extension Manager code was checking for the existence of a file, which was never created unless you had extensions installed. That fix alone saved ~300ms during startup. XBL loading was also improved – saved 100-200ms during startup.

We still have more work to do – we are shooting for a ~3 second startup. Yes, we have already found several more changes we plan to make for the next release.

Wrapup

We made some significant improvements startup, panning and page loading. Take Fennec Alpha 2 for a spin, especially if you tried Alpha 1 and found it too slow.

The downside of the many changes we made, especially in the UI, will be extension breakage. Giorgio Maone, author of NoScript already discovered some breakage, but plans to have an updated version ready soon. Unfortunately, we will likely cause more breakage with the next release too. However, my hopes are that by soliciting feedback from the add-on developer community, we can get a stable XUL structure and JS API in place for the next release.

Add-on-Con, Open Houses and Mobile

Next week I’ll be in Mountain View, CA. Mozilla Mobile is having a face-to-face work week, gearing up for Fennec Alpha 2. As a remote employee, I enjoy getting together with the rest of the team.

You’ll also find me at Add-on-Con on Dec 11th presenting a session on Add-ons and Mashups. I’ll show some existing add-ons, walk through some code, and generally discuss the advantages of using add-ons to create mashups.

Mozilla is having a small informal Open House the previous night (Dec 10th) at the Mozilla Offices. Be sure to stop by and get your fill of information on Firefox 3.1 & Add-ons.

Adding Mochitests to a XULRunner Application

Last weekend I decide to add some Mochitest unit testing to XUL Explorer, one of my XULRunner based applications. Luckily, this is something Dave Townsend already did with a different XULRunner application, McCoy. It was pretty easy to use Dave’s McCoy patch as a basis for getting things working in XUL Explorer. I used XULRunner 1.9.0.4 for building XUL Explorer and, amazingly, my unit tests ran on the first try! Here’s the changeset.

Next, I started working on adding the same support to Fennec. I hit a snag because of changes in Mozilla 1.9.1 to support new types of testing. I made a patch (reviewed and waiting to land) that makes things work again. We are hoping that some of the tweaks needed by Dave’s patch can be rolled into the mainline Mochitests system.

Now that I have some experience under my belt, I plan to add some docs no MDC. I also plan to add the necessary code templates to XUL Explorer and FizzyPop application generators, so anyone making a new XUL application automatically get Mochitest support.

Thanks Dave 🙂

XULRunner 1.9.0.4

The newest official XULRunner has been released. XULRunner 1.9.0.4 matches the Firefox 3.0.4 release. For XULRunner developers, most of the changes in 1.9.0.4 are related to security fixes.

Runtimes
SDKs
Source tarball

For those interested in the mobile versions of XULRunner, nightly builds of XULRunner for Maemo can be found here. The mobile tinderbox is also up and running.

Want to get started building XULRunner applications? We have an article for that.

XULRunner at MozCamp 2008

I decided to take a detour in my XULRunner session at MozCamp. I have done several XULRunner talks over the last few years. I usually focus on the functionality built into the platform and discuss the benefits of using Mozilla technologies to develop applications.

This crowd was very Mozilla savvy and many had at least experimented with building XULRunner applications. So, instead of my normal slide deck, I went with a “walk-through” of using the Mozilla build system to create a XULRunner application. I did the same with setting up an auto-updating XULRunner application. I think the Mozilla build system is something any XULRunner developer should learn and setting up auto-updating always seems to frustrate developers.

The talk went very well. Thanks to Robert Kaiser for helping me fill in some blanks. We had some good discussion and I could have spent a lot more time covering some of the smaller details. I think I might look into expanding this “walk-through” format.

Another topic we talked about was the potential of XULRunner on mobile devices. Many developers are excited to see XULRunner become available for mobile platforms. The ability to move XUL applications from desktops to mobile devices is fairly powerful. Fennec, for example, runs just fine on any supported XULRunner platform – without any changes.

Fennec – Here Comes AMO

Last night, support for Fennec on AMO was pushed live. A big thank you to Mike Morgan and crew for making this happen. There are no recommended Fennec add-ons yet, so you need to search for them. Here are some results, based on the two add-ons I know support Fennec and are on AMO:

Extending this mobile browser is now fully operational!

EU MozCamp 2008 & Me

I am headed to Barcelona to take part in Mozilla Europe’s MozCamp 2008 conference. I’ll be presenting sessions on XULRunner, Fennec Add-ons & Embedding Gecko. If you’re interested in any of these sessions and have topics you’d like to see covered, let me know. Commenting here or adding items to the wiki pages are goods ways to do that.

I also plan to hang around the Prism session, presented by Matt Gertner. Prism has some cool features brewing. I hope we get a new release (with samples) out soon.

Fennec Alpha1 & Add-ons

One of the reasons we released Fennec A1 with desktop versions was to allow add-on developers to start hacking on Fennec add-ons. As long as the add-on contains no binary compiled code, it should run on any platform – including mobile devices. Developers can build and debug Fennec add-ons using the desktop builds, without needing an actual device.

As I previously posted, making a Fennec add-on is no different than making an add-on for any Mozilla-based application, such as Firefox, Thunderbird or Songbird. Fennec is a different application – add-ons for Firefox will not Just Work in Fennec. I started documenting the process of building Fennec add-ons. I plan to add some use cases there too.

Fennec supports installing add-ons from websites (remember to use the right MIME type – application/x-xpinstall). Once an extension is ready for testing, the developer can post the XPI somewhere. The add-on can then be installed to Fennec on devices or Fennec on desktops.

Very soon, we will support Fennec add-ons on AMO (addons.mozilla.org)

Update: If you want to debug your code using the error console, try using the command line flag like this:
fennec -jsconsole