04 Oct 2010
The Mozilla Mobile team has been working for several months on Firefox 4 for Android and Maemo (also known as "Fennec"). Here are some thoughts about the challenges we've discovered, how we've decided to solve them, and why Firefox is different from other mobile browsers.
People often ask us why Android needs another web browser. These are a few things Firefox does that other Android browsers don't:
Syncs bookmarks, tabs, history, passwords, and form data to and from your phone. Firefox Sync and the Firefox Awesomebar help you enter URLs and passwords with less typing, and move seamlessly between your desktop and your mobile phone.
Lets anyone write add-ons that can customize any part of the user interface. (Dolphin HD is another Android browser with some great add-ons, but its add-ons are provided by the browser vendor.)
Supports web technologies like SVG, ECMAScript 5, WebM, and HTTP Strict Transport Security. Firefox for Android currently scores 217 points plus 9 bonus points on html5test.com. (Warning: Those tests can be deceptive; use them as a starting point for comparison only.)
There are several other browsers for Android, but all of them use the built-in WebKit rendering engine (except Opera Mini, which uses a proxy server for rendering). The same is true for iOS, which uses WebKit too – as do the latest versions of BlackBerry, Symbian, and Palm webOS. [Update, November 2010: Opera Mobile for Android is now in beta and uses its own rendering engine too.]
Part of the point of Firefox is to provide alternate capabilities, rather than reuse the built-in ones. Firefox for Android uses same Gecko engine as Firefox 4 for desktop. That's how it can support features that Android's WebKit doesn't, like SVG and ES5. (Of course, WebKit supports some features Gecko doesn't, which is why it's great to have a choice.)
Early Firefox for Android builds were very slow compared to the stock browser. Performance is critical in a mobile browser, and our work in this area is starting to pay off. The new beta version is much speedier, and we have plans to make it even faster.
To make sure Firefox's interface stays responsive even when pages are rendering, we split the browser into two processes: one for the user interface, and one to render and run scripts in web content. This was part of the Electrolysis project.
To make scrolling and zooming fast, Mozilla's graphics team has implemented a new "Layers" architecture to allow hardware acceleration and other optimizations. Beta 1 is the first mobile Firefox release to take advantage of this work. Because of Electrolysis, we need to share layers between the UI process and the content process. These cross-process layers allow Firefox to scroll smoothly in response to user input, even if the content process is still busy rendering the page.
These are just the first steps toward making Firefox fast on mobile devices. Upcoming releases will feature OpenGL hardware-accelerated compositing, for improved scrolling of complex pages. They will also load web pages faster, thanks to optimizations of our inter-process communication.
Unlike browsers that use the stock WebKit library, Fennec must ship its own rendering engine. Many Android phones were built with just 64 MB to 512 MB of storage for apps. Users who think nothing of a 12 MB download to install Firefox or Chrome on a laptop may think twice before installing it on these phones! Storage space is much larger on newer phones, but this is still an issue for many users.
Even worse, a quirk of the Android NDK means these native libraries are saved twice – both compressed inside the APK and extracted to a folder for loading. For apps like Firefox that are mostly native code, this more than doubles the installation size. Other NDK apps like Google Earth pay the same double storage penalty.
To solve this problem, Mozilla's Michael Wu wrote a custom dynamic linker that loads libraries from the APK without installing them to a folder. This cut the installed size by more than half, but increased startup time slightly. For newer phones with 1 GB or more of internal storage, we might want to let Firefox take more space but start faster. On phones with less storage, we can use the custom linker to save space.
Firefox 4 beta 1 needed about 40 MB of storage on Android. With the custom linker, Firefox 4 beta 2 takes a fraction of the space, and in Android 2.2 you can move almost all of it to SD.
Stock libraries have another advantage: They can be optimized for specific hardware. In contrast, apps usually come in a single flavor for all devices. Firefox can use ARMv7 features like Thumb-2 and NEON to run as fast as possible on high-end Android phones – but with these optimizations it can't run at all on low-end hardware. To run optimally on all current hardware, we'd need different builds for different devices. For now we're focusing on the current high-end phones, which will likely be next year's mainstream hardware.
Firefox is built by Mozilla, a non-profit organization with a mission to promote openness, innovation, and opportunity on the web. We want our work on the mobile web to benefit everyone, not only Firefox users – just as Firefox on the desktop helped create a new era of innovation and standards for all browsers.
WebKit is an excellent project. But a growing number of mobile sites work only on WebKit. This is dangerously similar to the web ten years ago, when Internet Explorer had an overwhelming market share and many sites used IE-specific markup. That made it hard for other browsers to compete, which killed the incentive for the dominant browser to keep improving.
Upcoming platforms like MeeGo and Windows Phone will give WebKit some new mobile competition – but many users still can't choose new browser technology without buying new hardware (and often new service contracts). We think you should have a meaningful choice of browsers on your current phone, just like you do on your computer. User choice will encourage all browsers to innovate and learn from each other, so they all improve faster.
To check if your phone is compatible with Firefox 4 beta, go to our download page. This is a test release, and we aren't finished fixing and optimizing it – but we are working hard. Let us know what you think!
We have a lot more work ahead of us. Our next releases will include even more exciting changes like the new Android skin, reduced installation size, and more speed improvements.