This week at LWN: Mozilla announces HTML5-based phone

February 29, 2012

This article was contributed by Nathan Willis

Mozilla announced
a deal with Latin American mobile carrier Telefónica Digital on February 27
to start shipping HTML5-driven smartphones by the end of 2012. Although
the press release dubs the new platform “Open Web Device,” many Mozilla
watchers know it better as Boot To
(B2G), a lightweight Linux-based system that uses Gecko as its
primary (if not sole) application framework. B2G has been in development
since July 2011, but it has advanced significantly since we last examined it in mid-August.

B2G architecture

Initially, the project debated several options for the underlying operating system on which to perch the Gecko runtime — including Android (which served as the basis for the earliest experimental builds), MeeGo, and webOS. The team has since settled on an architecture of its own, which takes some components from Android, but constructs its own stack, called Gonk.

Gonk is a stripped-down Linux distribution, using the kernel and some standard userspace libraries for hardware access (e.g., libusb and Bluez). It also borrows hardware abstraction layer code from Android — the architecture document on the Mozilla wiki lists camera and GPS devices in particular. The architecture document also makes references to both the Android kernel and to modified kernels supplied by hardware vendors; evidently B2G is designed to tolerate minor variations.

Gonk also includes an Android-derived init program, D-Bus,
wpa_supplicant, and Network Manager. The media playback functionality also
comes from Android: there is a mediaserver player for the audio
and video formats that Gecko can decode natively, and
libstagefright to access binary-only codecs and hardware decoding

Mozilla’s B2G team could not be reached for comment,
but several of the Android components in the Gonk stack appear to have been
chosen for the practical task of bootstrapping the OS on available
smartphone hardware (such as the Samsung Galaxy S II, which is the testbed
device at Mozilla) rather than on technical grounds. For instance, the
setup currently uses Android’s Bionic library, but there has been some discussion of
replacing it with a more general libc implementation.

Apart from those components and the cellular modem layer, however, Gecko
is the only runtime process started. In B2G, there is a master “Gecko
server” process named b2g that spawns lower-privileged child
processes for each web application run. Only the b2g process can
directly access hardware devices; it mediates access requested by the child
processes. b2g and the application processes can pass messages to
each other using what Mozilla calls “IPC (Interprocess communication)
Protocol Definition Language” or IPDL, which originates from the Electrolysis project. Electrolysis is Mozilla’s effort to refactor Firefox as a multi-process application; it is still in development, but it provides both synchronous and asynchronous communication, and isolates child processes from each other.

Ultimately, Gonk is different enough from both Android and typical desktop Linux systems to warrant its own build target for Gecko. Among other distinctions, it implements a lightweight input event system, and draws directly to OpenGL ES rather than the X Window system. But in order to provide the full smartphone application framework, the Gecko engine must also have direct access to low-level functionality that is normally handled by other processes — such as the telephony stack.

New APIs

B2G’s telephony stack is called the Radio Interface Layer (RIL), and is derived from the corresponding code in Android. RIL caters to device vendors by providing a rilproxy mechanism to manage connections between the b2g process and the cellular modem driver. The driver, called rild, can be proprietary (in fact, the RIL design assumes it is proprietary) and thus link to binary-only firmware blobs without triggering the license inheritance conditions from other parts of the stack.

RIL implements voice and 3G data calls, network status, text and MMS
messaging, and SIM card commands (such as storing and retrieving contacts,
or entering and validating unlock codes). These commands are exposed to HTML5 applications through the WebTelephony and WebSMS JavaScript APIs, which are still in development.

In fact, much of the B2G-specific functionality requires the definition
of new APIs that “traditional” Gecko applications do not expect. Mozilla
has already invested in the drafting of OS-independent web APIs for other
reasons, including its Web
App Store
project. Mozilla is also participating in the
standardization effort being managed by the W3C, primarily the Device APIs Working Group. At the
moment, not every API created by Mozilla has a corresponding W3C
specification, although Mozilla says standardizing all of them is the
ultimate goal. Mozilla’s list includes a mixture of
high-level interfaces (such as the Contacts or Camera APIs) and low-level
interfaces (such as the Bluetooth and near field communication (NFC) stack

The most far-reaching APIs in the library are Open Web Apps, which specifies a manifest file format and packaging guidelines for “installable” web applications, and WebRTC, which provides a real-time communication framework used for streaming media as well as network-centric features like peer-to-peer networking. Some of the less familiar specifications under development are APIs for detecting screen orientation, processing notifications when the device is idle, and locking hardware resources (such as preventing screen-dimming).

Applications and interfaces

The plan is for every application in a B2G device to be written in HTML5, CSS, and JavaScript, and naturally the list begins with the generic phone applications: a “home” screen, phone dialer, camera, contact list, calendar, and so on. While phone vendors may prefer to write their own code in-house, Mozilla is at least in the planning and mock-up stage of creating some demo B2G applications.

The demo application suite is code-named Gaia. The wiki page has
placeholders for a dozen or so basic applications, including more detailed
mock-ups for the web
, image
, and camera
application. There are also mock-up images on the Demo page for a home screen,
lock screen, and dialer.

More interesting than static mock-ups are the in-development demos found at B2G developer
Andreas Gal’s GitHub site (screen shots of some are shown here). A recent version of Firefox will open the HTML
files from the repository; the homescreen.html file shows the home
screen and lock screen, and several other applications are accessible
through home screen launchers (the Mozilla wiki’s Demo page also links to a
“live” demo, but that appears to be out-of-order at the moment). The UI
responds to mouse clicks and “slide” gestures, although the applications
vary widely in completion, of course — some are just static images.
Still, the home screen and generic applications are in place along with basic navigation and UI elements.

The road ahead

The B2G roadmap is ambitious; it predicts a product-ready milestone by the end of the second quarter of 2012. Considering that not all of the fourth quarter 2011 goals have been met yet, that may not be attainable without an infusion of developer time from a hardware partner, but the project did bring a B2G demonstration to Mobile World Congress alongside the February 27 announcement.

Perhaps notably, the Bluetooth, NFC, and USB tracking bugs appear to be behind schedule at the moment, while most of the higher-level work for sensor support and user applications appear to be on track. Arguably the biggest piece of the puzzle yet to get underway is WebRTC support. WebRTC itself is still undergoing rapid development, of course, but without it, the goal of supporting real-time audio and video on a web-runtime smartphone is difficult to imagine.

Resources for potential Open Web Device application developers are also
in short supply at the moment. Although Mozilla curates a collection of
HTML5 resources at its Mozilla Developer Network (MDN) site, so far only
the Open WebApps APIs are covered. Mozilla formally
its Open Web App “Marketplace” on February 28, in an
announcement that referenced the in-progress Web API effort in addition to
the traditional desktop platform. That is probably a sign that the Web
APIs will make their way to MDN in short order as well.

In its own press release, Telefónica Digital says only that its first Open Web Device-powered phone (which has not been detailed in hardware specification or price) will ship in 2012. That leaves considerable time to complete the project on schedule, although from Mozilla’s perspective getting the new JavaScript APIs through the not-known-for-its-rapidity W3C standardization process may be a tight fit.

(Log in to post comments)

Leave a Reply