A WebAssembly Milestone: Experimental Support in Multiple Browsers

WebAssembly is an emerging standard whose goal is to define a safe, portable, size- and load-time efficient binary compiler target which offers near-native performance—a virtual CPU for the Web. WebAssembly is being developed in a W3C Community Group (CG) whose members include Mozilla, Microsoft, Google and Apple.

I’m excited to announce that WebAssembly has reached an important milestone: there are now multiple, interoperable, experimental browser implementations. We still have a lot of work left on the standard implementation before shipping, but this is a good occasion to present our progress so far, talk about what’s coming next, and invite feedback.

Why WebAssembly?

The low-level asm.js subset of JavaScript has demonstrated not only that it’s possible for browsers to achieve safe, sandboxed, near-native computational performance, but that there’s tremendous demand for this kind of capability on the Web. Thanks to the Emscripten compiler, we’ve seen asm.js used for a diverse and growing array of applications, including mapping, cryptography, compression, games, CAD, image editing, and facial recognition.

The WebAssembly CG formed last year to take the Web the next step further, with a standardized binary format whose storage size and decoding times could be optimized beyond what is possible with JavaScript. Additionally, by being a new standard, WebAssembly is able to evolve to accommodate low-level features independently of the evolution of JavaScript.

At the same time, we knew it was important for WebAssembly to be “of the Web:” it had to access existing Web APIs and integrate tightly with JavaScript by, e.g., allowing calls between WebAssembly and JavaScript. Unlike classic plugin models, this will allow WebAssembly to be more easily integrated into JavaScript applications and libraries, just as asm.js has been able to do.

Finally, we’ve been able to draw on our years1,2,3,4,5,6,7 of experience with Emscripten and asm.js to guide and focus the initial design of WebAssembly. And crucially, with the great performance of asm.js code on modern browsers, the creation of polyfills will allow developers to begin using WebAssembly even before native implementations have reached saturation in the browser market.


Fast forward to today, and the CG has already made a remarkable amount of progress. Within the WebAssembly GitHub organization, the group has produced:

What’s more, engineers on four browser engines have implemented prototype WebAssembly implementations1,2,3,4. Within Firefox, we refactored our existing asm.js optimization pipeline to use WebAssembly’s binary format as the representation of asm.js code sent from the main parsing thread to the background compiler threads.

This change ended up significantly improving asm.js parallel compilation performance by moving two costly steps, MIR and code generation, off the sequential critical path. With this refactored pipeline, native WebAssembly decoding only requires the addition of a small new frontend to validate the untrusted bytes:

asm.js and WebAssembly compilation pipeline

For definitions of these terms and more background on JS and asm.js compilation, see this previous blog post.

Experimenting with WebAssembly

With all these pieces in place, it’s now possible to build WebAssembly demos that run on multiple experimental implementations. We do mean “experimental”: both the binary format and JS bindings for WebAssembly will likely change incompatibly over the next months until the first edition is stabilized. And we don’t expect implementations to be mature enough for stress tests or benchmarking for some time yet. Rather, the importance of this milestone is getting all the browsers on the same page so we can continue to iterate in sync.

With all that said, it’s gratifying for us to see a real, working demo that will run in multiple browsers:

Screenshot of AngryBots

This particular demo actually has some nostalgic value: AngryBots is a Unity tutorial project which was used as a smoke test while bringing up Unity’s WebGL export. Good memories! 🙂

To run the demo, download a Nightly build, open about:config and set javascript.options.wasm to true.

Path To Release

So what’s next? There’s more to do before we have a stable, shippable first edition. In the CG, some big remaining tasks are:

  • Define the official WebAssembly text format.
  • Further reduce binary format size. While the current binary format is 42% smaller than asm.js uncompressed (12% smaller after gzip), we know from previous prototype binary format work that further significant size reductions are available.
  • Iterate on the WebAssembly JavaScript API. Currently the experimental builds define a single new synchronous function, Wasm.instantiateModule, that does both compilation and instantiation. There are tentative plans to break these steps apart and provide both synchronous and asynchronous functions that produce a structured-cloneable code object. This gives developers more control over both compilation and machine-code caching than current implicit machine-code caching for asm.js in Firefox.
  • Create more approachable documentation for compiler writers, tool authors, hackers, and students.
  • Add a bunch more tests to the test suite.

In Firefox we’re also planning to:

  • Add WebAssembly support to browser devtools, including both the debugger and profiler. Fortunately, the JavaScript, Developer Tools and Firebug teams worked together to move tools over to a new, abstract, unit-testable Debugger API which we’ll be implementing for WebAssembly code. In fact, work has already begun which is why, if you open the Debugger tab for the above demo, you can already see a placeholder text format being generated for the binary code (which will, of course, switch over to the official text format when it’s ready).
  • Further reduce cold load time. Measuring AngryBots compile time on a 16×2.4Ghz core Linux desktop, WebAssembly reduces compile time by about 52%. That’s a good start and leverages the fact that WebAssembly decoding is currently about 10× faster than asm.js parsing, but cold load time can be significantly further reduced by working on the other parts of the compilation pipeline.
  • Finish adding the full set of WebAssembly operators and import the test suite.

Full Speed Ahead

The progress on WebAssembly so far has been exhilarating. I continue to be impressed and appreciative of the collaborative atmosphere of the whole WebAssembly Community Group. If you want to learn more, the GitHub org page is a good starting point. Happy hacking!

View full post on Mozilla Hacks – the Web developer blog

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Firefox OS 2.5 Developer Preview, an experimental Android app

Today we have made Firefox OS 2.5 available worldwide. We are also making an early, experimental build of the OS — Firefox OS 2.5 Developer Preview — available for developers to download on Android devices. This latest version of Firefox OS delivers exciting features including:

  • Add-ons: Just like the add-ons we’ve come to love in desktop browsers, Firefox OS add-ons can extend just one app, several, or all of them, including the system app itself.
  • Private Browsing with Tracking Protection: A new Firefox privacy feature, Tracking Protection allows users to control how their browsing activity is tracked across many sites.
  • Pin the Web: Pin the Web removes the artificial distinction between web apps and web sites and lets you pin any web site or web page to your home screen for later usage.

To find out more about all aspects of the release, visit Firefox OS v2.5.

Firefox OS 2.5 Developer Preview is an app that lets you experience Firefox OS as an alternate home screen on your Android device without having to re-flash and replace your Android installation. To give it a try, visit Firefox OS 2.5 Developer Preview, right from your Android device.

Firefox OS 2.5 developer preview homescreenAndroid apps alongside Web apps on the homescreen

Firefox OS 2.5 developer preview CalendarFirefox OS Calendar with Android navigation bar

Firefox OS 2.5 developer preview top sites viewFirefox OS Browser landing page

What is the Firefox OS 2.5 Developer Preview?

You’ve asked how to get involved with the Firefox OS open source project. To date, it’s only been possible to download and explore the latest versions of Firefox OS on specific hardware, such as the Flame device. We’re now working on making Firefox OS more widely available. The Firefox OS Participation Hub provides up-to-date information on getting involved with Firefox OS . The B2G-installer add-on lets you flash a full port of Firefox OS on to an Android device (Note: Firefox OS is under development. Don’t expect it to be bug-free or completely stable.)

Re-flashing existing hardware means losing user data as well as access to Android apps that you may depend on. There’s always an inherent risk of rendering your hardware inoperable, i.e., bricking your device. Firefox OS 2.5 Developer Preview avoids these issues by replacing the Android home screen with the Gaia (UI) layer of Firefox OS. Effectively you can use Firefox OS while still having full access to your Android apps. Firefox OS 2.5 Developer Preview makes Firefox OS available to more developers, testers, localizers, and supporters of the Open Web around the world.

If you’re curious to see what Firefox OS is all about, or just interested in testing out new features, the Firefox OS 2.5 Developer Preview app makes it very simple to get started with very little risk involved. By downloading the app, you can experience Firefox OS and explore many of its capabilities, without flashing hardware. If you decide you’re done trying it out, the app can be removed as simply as any other app. If you’re interested in becoming a code contributor or bug reporter, the app makes it dramatically easier to get involved.

What’s the catch?

As a full operating system, Firefox OS has its own task manager, utility tray, navigation buttons, settings, and more. Running on top of Android means that these elements of the operating system may come into conflict with those same system functions on Android. Android launchers were never designed to enable replacement of these operating system functions. As a result we employ various workarounds, where possible, to avoid delivering a poor user experience. For example, Android uses a back button as a primary navigation method. Firefox OS does not. While we are trying to mitigate these issues, the current edition of the Firefox OS 2.5 Developer Preview app should be considered experimental and will most likely contain bugs. We can certainly use your help in discovering, reporting, and fixing issues.

Hacking on the Firefox OS 2.5 Developer Preview

We’d love for you to play with the Firefox OS 2.5 Developer Preview — to scratch your own itch, test an idea, or contribute to the project by improving performance or finding interesting solutions to the conflict problems with Android system functions mentioned above. With that said, if you are interested in hacking on the app, instructions for building it from scratch can be found here. Alternatively, you can make use of WebIDE in the Firefox Developer Edition browser to start making changes directly to the layout and composition of apps in Firefox OS Developer Preview.

Get involved without coding

There are many ways to get involved without contributing code. The easiest way is to install Firefox OS 2.5 Developer Preview on your Android device and file bugs when you run into problems or discover things that don’t work as expected. If you’re looking for other ways to help, visit our Firefox OS Participation Hub.

Supported devices

The current build will only work on ARM-based devices. It will not work on x86 devices.

Final thoughts

We are very excited about the Firefox OS 2.5 Developer Preview app. We’ve worked hard to produce a Firefox OS experience for Android users. As with all things at Mozilla, this effort is very much a community effort and we welcome all forms of constructive feedback and suggestions for making the experience better.

Got questions about running Firefox OS on new hardware or devices? Try the dev-fxos mailing list or #fxos on IRC. Thanks!

View full post on Mozilla Hacks – the Web developer blog

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

r2d2b2g: an experimental prototype Firefox OS test environment

Developers building apps for Firefox OS should be able to test them without having to deploy them to actual devices. I looked into the state of the art recently and found that the existing desktop test environments, like B2G Desktop, the B2G Emulators, and Firefox’s Responsive Design View, are either difficult to configure or significantly different from Firefox OS on a phone.

Firefox add-ons provide one of the simplest software installation and update experiences. And B2G Desktop is a lot like a phone. So I decided to experiment with distributing B2G Desktop via an add-on. And the result is r2d2b2g, an experimental prototype test environment for Firefox OS.

How It Works

r2d2b2g bundles B2G Desktop with Firefox menu items for accessing that test environment and installing an app into it. With r2d2b2g, starting B2G Desktop is as simple as selecting Tools > B2G Desktop:

B2G Desktop Menu Item

To install an app into B2G Desktop, navigate to it in Firefox, then select Tools > Install Page as App:

Install Page As App Menu Item

r2d2b2g will install the app and start B2G Desktop so you can see the app the way it’ll appear to Firefox OS users:

B2G Desktop

Try it out!

Note that r2d2b2g is an experiment, not a product! It is neither stable nor complete, and its features may change or be removed over time. Or we might end the project after learning what we can from it. But if you’re the adventurous sort, and you’d like to provide feedback on this investigation into a potential future product direction, then we’d love to hear from you!

Install r2d2b2g via these platform-specific XPIs: Mac, Linux (32-bit), or Windows (caveat: the Windows version of B2G Desktop currently crashes on startup due to bug 794662 795484), or fork it on GitHub, and let us know what you think!

View full post on Mozilla Hacks – the Web developer blog

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

9 More Experimental PHP Projects to Check Out

The Developer.com article I wrote last year, 10 Experimental PHP Projects Pushing the Envelope , was originally intended to be little more than an homage to nontraditional PHP efforts that stretched beyond standard Web application development tools such as PHP-GTK and phpList . However, upon further investigation, it soon became clear that the PHP community was stretching PHP’s capabilities far …

View full post on web development – Yahoo! News Search Results

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)