Now that Apple iOS 4.3 is generally available for iPhone and iPad, users have noticed something that seems curious. The fast new “Nitro” JavaScript engine only works in the standalone Safari browser, not when a web app is pinned to the home screen, or when a web view is embedded into an app.
This link at mobilexweb.com shows the evidence. Here is the SunSpider test standalone, showing a time of 4098ms, and pinned to the home screen as an app, where it shows 10391.9ms:
The consequence: apps created using WebKit as a runtime, for example using PhoneGap, will not get the benefit of Nitro.
It would be easy to conclude that Apple is deliberately hobbling these apps in order to protect native apps, which can only be installed via Apple’s App Store and are subject to its 30% cut. However that might not be the case. It could be a bug – according to Hacker News it has been reported as such:
To add another note to this, its a bug that Apple seems to know about. I can’t link to it because its marked CONFIDENTIAL across the top of the dev forums, but in short its known about and being investigated.
or it could be a security feature. Using a just-in-time compiler exposes the operating system more than just interpreting the code; perhaps Safari has more protection when running standalone.
Either way, with the increasing interest in WebKit as a de facto cross-platform application runtime for mobile, this particular limitation is unfortunate.
Update: There are also reports of the HTML 5 offline cache not working other than in full Safari:
I’ve tested this by switching apple-mobile-web-app-capable from ‘yes’ to ‘no’ and offline cache works as expected. But whenever it’s switched back to ‘yes’, it’s not working anymore. This occurs when the app is standalone at home screen. As a website, viewed with Safari cache is working as expected.
This came up a few months ago between friends at apple – The limitation has to do with exposing the JIT to a protected area of the operating system. The security team cannot integrate and sandbox the Javascript VM without exposing your personal data and Apple’s own DRM keys to potentially malicious code. My read on it was that it was a question of time — it was not a strategic block by the execs.
The WebApp player that runs web pages pinned to the iOS desktop AND apps that use WebKit have to be recompiled to use the Nitro JavaScript engine.
This was done to prevent incompatibilities and crashes from the switch to a different engine. If current apps, for example were incompatible with Nitro, then they would crash and customers would complain. Thus Nitro is not automatically used in all apps, including Apple’s own until stability tests and recompilation can be done.
Disappointing, as I have wanted to use my iPod 2G for web apps every since I got it but the performance was so bad it wasn’t usable.