iOS 8 grants new power to rival browsers, Web-based apps

Today, third-party apps can run JavaScript programs only with hobbled performance on Apple's mobile OS, but Apple's next version grants them the full performance Safari gets.

iOS 8 gives third-party software access to several Safari advantages.
iOS 8 gives third-party software access to several Safari advantages. Screenshot by Stephen Shankland/CNET

Apple has decided to stop hogging some of the performance it once reserved for Safari on iOS.

The company for years has built software called WebKit that's used to display Web pages and run Web apps. WebKit is at the heart of Safari, but Apple also supplies a separate version that other apps on iOS 7 can use. That's handy for developers who want to create user interfaces based on Web technology such as JavaScript and HTML, and it's essential for Google Chrome and Opera Coast, because Apple prohibits anyone from bringing their own browser engines to iOS.

There's been a bit of a sore spot for those third-party developers, though: Safari gets extra privileges that mean it can run JavaScript faster than the WebKit that third-party software uses. But at Apple's Worldwide Developer Conference, WebKit engineer Anders Carlsson said that's no longer the case in iOS 8.

"Over the years we've seen a lot of requests from all of you for something a bit more powerful," Carlsson said in his WWDC talk. Apple therefore created a new programming interface called WKWebView for both iOS and OS X to tap into WebKit.

"One of the goals we had with this modern API [application programming interface] was to take a lot of features that were previously only available to Safari and give you access to them. For example...the full power of the JavaScript Nitro engine," he said, referring to Apple's software that runs JavaScript programs.

Ordinary folks will benefit. Many apps draw on Web technology, and they should run faster or get more features as programmers take advantage of new performance.

The biggest beneficiaries will be third-party browsers, though, most notably Google's Chrome. On Android, Windows, Linux, and OS X, Chrome uses Google's Blink browser engine, which was diverged from WebKit in 2013. But on iOS, Google has to use Apple's WebKit.

JavaScript has become central to Web browsers and Web apps, maturing over nearly two decades into a foundation powerful enough to run services like the Google Docs word processor. Web-style programming, which has natural advantages for developers trying to reach multiple operating systems, has become a powerful force in the industry.

So it's no surprise that programmers weren't happy that they got only watered-down JavaScript performance on iOS. When Carlsson announced the speed boost in iOS 8, he was greeted by a round of applause.

The big difference in JavaScript execution with Safari vs. WebKit for the third-party apps has been something called just-in-time (JIT) compilation. When JavaScript first arrived on the scene, browsers executed the programs line by line, translating them as they went from the human-written code into the machine-code instructions the computer actually can process. Software runs much faster by compiling software in advance to convert it into machine code.

But compilation takes time. Browsers work by executing the JavaScript traditionally while simultaneously compiling it into a faster version -- the JIT compiler.

But Apple wouldn't let the third-party software use that JIT compiler. One possible reason was security: a JIT compiler essentially creates a new program on the fly and marks the region of memory it's stored in as executable, and a hacker could potentially abuse that privilege. Apparently Apple is satisfied that its approach is secure enough though. The loosened restriction also matches what Google does with Android's built-in browser technology, so competitive considerations could be involved, too.

Apple, like other browser makers, has been working hard to improve JavaScript. The WebKit for third-party apps in iOS 8 and OS X will be able to use the newest speedup technology, called FTL JIT, Carlsson said. That stands for fourth-tier LLVM, not for faster than light, but Apple no doubt wouldn't be upset by any confusion.

The faster JavaScript isn't the only change coming with the new WebKit interface.

Other aspects drawn from Safari include "supersmooth 60-frames-per-second scrolling using hardware acceleration and CoreAnimation," Carlsson said.

And there's more: "We've taken the back/forward swipes and the pinch-to-zoom gestures from Safari and built them right into WebKit," he told developers. Another feature is "a really cool way for your app to talk to Web pages and vice versa."

(Via 9to5Mac)

 

Join the discussion

Conversation powered by Livefyre

Don't Miss
Hot Products
Trending on CNET

HOT ON CNET

Find Your Tech Type

Take our tech personality quiz and enter for a chance to win* high-tech specs!