Android 2.0 uses V8 JavaScript engine

Google has not yet released most of the Android 2.0 "eclair" source code, but they did publish source for a very small number of components, including a WebKit snapshot. I was excited to see that the snapshot includes Google's V8 virtual machine. (Previous Android releases used Safari's JavaScriptCore/"SquirrelFish Extreme" VM.) But without the rest of the source tree, there was no way to build and run this on a real Android phone. The SDK includes a binary image that runs only in the qemu-based emulator.

Today I got to try out a Motorola Droid. Here's how its browser compares to Android 1.6 on my HTC Dream (Android Dev Phone / T-Mobile G1) in the V8 Benchmark Suite:

Test Dream (1.6) Droid (2.0) Change Richards 13.5 15.6 +16% DeltaBlue 5.23 12.9 +147% Crypto 13.2 10.9 -17% RayTrace 10.9 80.1 +635% EarleyBoyer 23.5 74.7 +218% RegExp did not complete 16.5 – Splay did not complete did not complete –

Some tests (Richards, Crypto) see little or no improvement, while others (DeltaBlue, RayTrace, EarleyBoyer) are dramatically faster. Just for comparison, let's run the same benchmark on Safari 4 (JavaScriptCore) and a Chromium 4 nightly build (V8) on a Mac Pro:

Test Safari 4 Chromium 4 Change Richards 4103 4640 +13% DeltaBlue 3171 4418 +39% Crypto 3331 3643 +9% RayTrace 3509 6662 +90% EarleyBoyer 4737 7643 +61% RegExp 1268 1187 -6% Splay 1198 7290 +509%

The precise ratios are different, but the same tests that showed the most improvement from Android 1.6 to 2.0 also show the most improvement from Safari to Chrome. Based on this plus the source code snapshot, I'm pretty sure that Android 2.0 is indeed using V8.

This is exciting news. It makes Droid the first shipping product I know that uses V8 on an ARM processor, although V8 has included an ARM JIT compiler for some time now. [Correction: Palm Pre was first; see the comments below.] For mobile web developers like me, it means we're one step closer to having desktop-quality rich web applications on low-power handheld devices.

Android still lags behind the iPhone in at least one important way for web developers: CSS animation. The iPhone (and Safari on the desktop) provides hardware acceleration for CSS transforms, like this falling leaves demo. On Android, CSS animation is done in software, making it much, much slower. (Even outside the browser, Android's Skia 2D graphics API lacks hardware acceleration. OpenGL is the only way to for Android developers to take advantage of the GPU.) Accelerated animation would really make it possible to write interactive web pages that match the smoothness and responsiveness of native apps.

Final thought: Although the Motorola Droid is still 100 times slower than Chromium on a Mac Pro, it's already faster at some benchmarks than IE8 or Firefox 2 on desktop hardware from just a few years ago.

Update (2010-02-09): Just for comparison, here are numbers for the Google/HTC Nexus One with Android 2.1. The Nexus One is around 2-4 times faster than the Droid at the V8 benchmark suite. It even renders the falling leaves animation at a decent framerate (but still not as smoothly as the GPU-accelerated iPhone).