Launching a new mobile OS is a difficult project since the market leaders, Android and iOS, have such a big lead. Even Microsoft, with its near-infinite financial resources and vast ecosystem of complementary products, has struggled to gain traction. And new entrants face a chicken-and-egg problem: developers don't want to write apps for a platform without many users, while users don't want to buy a phone without many apps.

Mozilla, the non-profit foundation behind Firefox, believes it can tackle this dilemma. In 2011, it announced a new project called Boot2Gecko to build an operating system around its browser. Last year the project was re-branded Firefox OS, and Mozilla began preparations for a major push into the mobile phone market.

In February, Mozilla unveiled an impressive initial list of hardware and network partners. If all goes according to plan, Firefox OS phones will be available in a number of countries, mostly in the developing world, later this year. Firefox OS phones won't reach the United States until 2014.

To sustain any early momentum, Mozilla will need to convince developers to build Firefox OS apps. The company has a plan that's so crazy it just might work: Firefox OS apps will be built entirely using HTML5. According to Mozilla, the thousands of developers who already know how to build Web apps will be able to build Firefox OS apps with minimal additional training. And because they're built on open standards, Mozilla hopes that Firefox OS apps will work reasonably well on other platforms that support HTML5—which is to say, all of them.

Is it actually possible to build full-featured mobile apps entirely in HTML5? Earlier this month, Mozilla sent us a review unit of the Geeksphone Keon with a "developer preview" of its new OS, and we put the system and its "Web apps" approach through their paces.

The Web as first-class platform

Obviously, the concept of building mobile apps on top of Web standards is not a new one. The late Steve Jobs famously insisted that the Web was good enough for building apps for the original iPhone. But it wasn't long before he changed his mind and announced a traditional SDK for building apps with Objective C.

There's an important difference between Apple's pitch in 2007 and Mozilla's pitch today: Mozilla is much more committed to eating its own dog food. The Apple-provided apps on the original iPhone were not Web apps; they were written using APIs that at the time were not available to third parties. This was a clear hint that Apple wasn't that dedicated to the Web-only model. In contrast, Mozilla claims that absolutely everything you see and interact with in Firefox OS—from the phone app to the icons in the status bar—is generated by the same Gecko rendering engine that powers the Firefox browser.

Of course, until recently HTML5 didn't have all the features you'd need to build a full-fledged mobile OS. So when Mozilla says Firefox OS is built on "HTML5," that sometimes means it's built using Mozilla's own proposed extensions to HTML5 that it hopes will be accepted by the W3C (the Web's standard-setting organization) and implemented by other browsers. Here Mozilla is drawing on one of its strengths, as it has a lot of experience developing, proposing, and implementing new Web standards.

At a talk last summer, Mozilla Director of Research Andreas Gal described an example of this process in action. Like any other mobile OS, Firefox OS displays the current battery status at the top of the screen. Mozilla engineers realized this might be a feature that would be useful on other platforms as well, so they set out to make it a Web standard.

After some searching, Mozilla engineers discovered that someone had previously proposed an HTML standard for querying battery status information. They implemented a version of the standard for Firefox OS and then proposed it to the W3C. Discussion at W3C inspired Samsung to adopt Mozilla's proposal and add battery status functionality to WebKit, the open source browser code shared by Apple's Safari and Google's Chrome browsers.

"Two or three months after that, W3C actually passed a battery status API as a recommended standard," Gal said. "So today, the battery status API actually can be found on many phone implementations." Mozilla even added the functionality to desktop versions of Firefox.

In this sense, Firefox OS is as much a project to improve the Web as it is a project to build a new mobile operating system. Every Firefox OS API Mozilla can get adopted by other major browsers makes it easier for developers to convert vanilla Web apps into "native" Firefox OS apps, and vice versa. Even if Mozilla's OS never gains significant market share, the effort to flesh out a complete set of Web standards for mobile computing will help to push the Web forward.

Architecture

The Firefox OS architecture has three layers, dubbed Gonk, Gecko, and Gaia. Gecko is the rendering engine at the core of the Firefox browser. Below Gecko sits Gonk, a bare-bones Linux distribution derived from Android. Above Gecko sits Gaia, a touchscreen user interface not too different from those found on other mobile operating systems.

One reason Mozilla chose to make Gonk a derivative of Android is that many device makers already know how to make devices that run Android. "If you're an OEM, you already have basically all the capabilities to run our system," Gal said last summer.

He described a 2011 meeting between Mozilla and Qualcomm. "They had a reference device we had never seen before," he said. "They were curious: can you run Boot2Gecko on this system?" While Mozilla and Qualcomm executives discussed strategic considerations, "two engineers sat down, one was a Qualcomm engineer with the device and the other one was an engineer from Mozilla who knew the stack." The engineers removed the higher levels of the Android software stack and replaced them with the corresponding parts of Mozilla's software stack.

"In that meeting, the first version of Boot2Gecko ran on this phone device we had never seen before," Gal said. "So if you know how to build Android devices, you know how to bring up our stack."

Gal claimed that the architecture of Firefox OS gives it an important advantage over Android: faster software upgrades. Android's monolithic design means that in many cases Google needs help from the network operator to upgrade a device's software. Network operators often drop the ball, leaving users stranded on ancient versions of Android.

Mozilla hopes to solve this problem by pushing as much functionality as possible up to the Gecko layer of the software stack. Mozilla may still need help from carriers to upgrade Gonk, but it expects that to rarely, if ever, be necessary. Mozilla hopes all the stuff that does require regular updates will be in the Gecko layer, which Mozilla will have the ability to update itself.

Packaging and permissions

A key feature of a modern smartphone platform is its procedure for approving and distributing apps. To satisfy Apple's strict review process, iOS apps must not only protect users' privacy and security, but they must also comply with Apple's user interface guidelines and other requirements. Google's app store is more permissive. And Google, unlike Apple, gives its users the option to install software outside of its app store.

Once the phone was set up, we found that some of the core apps have achieved near-parity with their Android counterparts.

Because Firefox OS apps are essentially just Web apps, app developers are not required to use Mozilla's app store at all. A developer can distribute a Firefox OS app as a "hosted app," delivered from any Web server. Technically, an app's URL points to a manifest, a JSON file describing the files needed to run the app. The manifest can include instructions for caching the app to enable faster startup and offline use.

Alternatively, Firefox OS apps can be distributed in "packaged" form. A packaged app is a zip file containing the app's manifest as well as the other files needed to run the app.

Packaging is required if an app wishes to be designated a privileged app. These apps are allowed to access certain APIs that Mozilla has designated as sensitive. For example, only privileged apps are allowed to access contacts, music, images, and videos on the device's built-in storage, or to initiate a TCP connection.

Mozilla has reserved the most sensitive APIs for a third category of apps known as "certified" apps. These apps are generally distributed with the device. Certified apps can perform functions like making phone calls, sending text messages, and changing settings such as the time and power management. Mozilla's documentation currently says that access to the built-in camera is restricted to certified apps, though providing access to third-party apps is on the to-do list.