8 ms·
Apple's FTLJIT project aims to give JavaScript a boost
- untog 13y agoHopefully they'll allow it to be used inside app WebViews. Nitro is already great, but it's disabled inside apps.
- frik 13y agoThis, and please enable WebGL support too [1] and give some love to the Webkit blog: https://www.webkit.org/blog/ https://www.webkit.org/blog/ [1] it's already in iOS since v4, but only activated for iAds
- eridius 13y agoThe only way any JIT at all will ever be allowed inside of UIWebViews is when UIWebView makes the jump to WebKit2, i.e. using a helper process to actually run the web content.
- dunham 13y agoThey might be able to handle it with a remote view controller. An existing iOS technology that allows for a view controller that fronts an out-of-process application. This is used for the mail composer and facebook sharing. See: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/ http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-... (I suspect there are some constraints on how a remote view controller can be used, and they'd have to do some additional work to shunt in NSURLProtocol and all.)
- eridius 13y agoThat's quite unrelated. That's a technology that allows for e.g. the Mail compose screen to run out-of-process while still compositing into the same layer hierarchy as the host application and receiving touches. This not only allows restricting access to Mail accounts to the daemon that runs the remote controller, but also prevents the host application from doing things like hiding the mail compose controller behind another view and forwarding touches to it, so a press on an unrelated button actually triggers an email send. WebKit2 is done differently. The UIWebView still handles all the user interaction and whatnot, and it talks to the Web Process to send it requests (e.g. "load this URL", "run this JavaScript in the context of the page", etc). I'm not quite sure how the compositing of the web content works, but it's not the same system as remote view controllers.
- 0x0 13y agoThere's stuff here about a UIRemoteWebViewController: http://oleb.net/blog/2012/10/more-on-remote-view-controllers/ http://oleb.net/blog/2012/10/more-on-remote-view-controllers... https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UIRemoteWebViewController.h https://github.com/nst/iOS-Runtime-Headers/blob/master/Frame... https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UIServiceWebViewController.h https://github.com/nst/iOS-Runtime-Headers/blob/master/Frame...
- eridius 13y agoPossibly interesting information, but still not actually relevant to WebKit2.
- dunham 13y agoI might not have been clear in my grandparent post. I wasn't proposing this as a means to WebKit2. (I don't know what WebKit2 is.) I was suggesting this might be a way to get JIT support in native apps with the current iOS WebKit, by running the entire UIWebKit out of process. However, I have no idea if there are enough hybrid apps out there, with javascript performance issues, to justify going to the trouble of doing this.
- eridius 13y agoAh. Well, it's a cute idea, but it won't work with UIWebView. Besides the fact that existing apps already rely on the fact that UIWebView isn't remote (because they can muck about with various view properties of it, including direct access to its UIScrollView), UIWebView also exposes at least one synchronous API (-stringByEvaluatingJavaScriptFromString:) and synchronous APIs are no good when doing stuff out-of-process. It also has a delegate that runs in a synchronous mode (e.g. it's asked questions it has to answer by returning a value, instead of just being notified of events or using a callback-based response), and that's the same problem as synchronous APIs (because now the remote process has to block waiting on a response from UIWebView). WebKit2 is an existing effort by Apple to do out-of-process rendering. Various desktop apps already use it, including Safari, Mail, and iBooks. It features new APIs for doing everything, because it's all asynchronous. If third-party iOS apps gain out-of-process rendering it will be through WebKit2 and not some attempt to port UIWebView to the remote view controller system. Incidentally, the same synchronous issues with UIWebView that I mentioned above suggest that porting to WebKit2 is a non-backwards-compatible change. If Apple makes this change, I would guess that either they'll introduce a separate UIWebView class that's used for WebKit2 and leave the existing UIWebView alone, or they'll give UIWebView two modes, a WebKit mode and a WebKit2 mode, and whichever mode it uses will be selected at initialization time (and using a WebKit method on a WebKit2 UIWebView would be an error, and vice versa). Either way, apps will have to be rewritten to take advantage of WebKit2.
- ksec 13y agoI thought the latest Safari (Desktop at least) were already on Webkit2. And i know Safari on iOS7 tends to be running one cycle behind ( Correct me if i am wrong ) So may be we get Webkit2 for iOS 8?
- ksec 13y agoAfter Further Digging, it turns out WebKit2 has been a private framework in both OSX and iOS. But on OSX it has been extremely unstable. It wasn't until Maverick did the process per tab came and stability improves. I guess Apple still needs to work on for iOS due to its heavy memory usage. So hopefully, they will come in iOS8.
- cclogg 13y agoOh man yeah... UIWebView's have been left in the dust for a while now lol (and Apple probably has a reason for it unfortunately).
- mmastrac 13y agoThe reason is basically that you can't easily provide a guaranteed W^X [1] environment alongside a JIT in the same address space -- that is unless you write a ROP-based JIT. [1] http://en.wikipedia.org/wiki/W%5EX http://en.wikipedia.org/wiki/W%5EX
- TazeTSchnitzel 13y agoI thought the problem was code-signing, with Safari and only Safari authorised to use JIT.
- mmastrac 13y agoIt is -- code-signing is how they enforce W^X. Only code loaded from signed applications is given pages with execute permission, and those pages are denied write access.
- eridius 13y agommastrac is correct, the problem with JIT is W^X. The default sandbox for iOS processes prevents marking any page as executable that has ever been marked as writable. Safari is not "authorized to use JIT" so much as it has a special sandbox that lifts this restriction. It's not about code-signing, it's about the security provided by W^X. If it was merely about code-signing, the JIT could simply codesign its output using a certificate provided by Apple for this purpose.
- mikeash 13y agoThere's nothing that prevents W^X and JIT from coexisting. All the JIT has to do is change the permissions on the generated code after generating it so that it becomes executable instead of writable. W^X just says that any given chunk of memory cannot be both writeable and executable at the same time. What Apple does on iOS goes beyond W^X. They give you a one-way trap door, where you're not allowed to mark any memory as executable, ever, once it's marked non-executable. (Obviously, there is an exception made for the OS facilities that actually load your code from the disk, and an exception made for Safari's JIT, but us mere mortals don't get access to that stuff.) As for the reason, it's hard to say. It's probably because of code signing and Apple's desire for control to prevent you from downloading and running unreviewed, unapproved code, although even that doesn't entirely make sense, because you can always embed an interpreter and download and run code in that.
- nobodysfool 13y agoHopefully they will allow you to ship a browser that contains a JIT. Apple doesn't currently allow that, so most browsers perform pretty much the same on iOS.
- JohnTHaller 13y agoApple doesn't allow you to ship a browser with its own JS engine full stop, let alone JIT. So every browser on iOS is just a fancy UI over the hobbled Safari engine with no Nitro. So there's Safari on iOS which is full speed, and then every other browser on iOS which is hobbled speed. This is by design and unlikely to change.
- e15ctr0n 13y agoThis is the very reason why Mozilla refuses to release a Firefox version for iOS[1]. Mozilla would like to ship Firefox with its own rendering engine, Gecko, while Apple policy dictates that all browsers on iOS are required to use WebKit[2]. [1] http://www.cnet.com/news/mozilla-says-no-plans-to-return-to-ios/ http://www.cnet.com/news/mozilla-says-no-plans-to-return-to-... [2] http://thenextweb.com/apple/2013/04/04/will-chrome-for-ios-be-able-to-use-googles-new-browser-rendering-engine-blink/ http://thenextweb.com/apple/2013/04/04/will-chrome-for-ios-b...
- anon1385 13y agoDoesn't that apply to FirefoxOS as well? You can't write a JIT in Javascript. So for example Google wouldn't be able to port Chrome with V8 to FirefoxOS, as far as I know.
- e15ctr0n 13y agoFirefox OS apps are written in HTML5, Javascript and CSS for which there is full-blown support by the rendering engine and the Javascript engine.
- 13y ago
- namuol 13y agoAnd open the door for high-performance, "write-once-run-anywhere" app development? Doubtful.
- deleted 13y ago[deleted]
- threeseed 13y agoSorry but I've not once used a HTML5 mobile app that ever convinced me it was the future of mobile development. In fact I far prefer companies serve me the full desktop site.
- untog 13y agoThere's a chicken and egg problem here. The OP said "maybe this will allow us to make high performance apps" - given that it currently isn't possible, it isn't very surprising that you haven't seen any great, high performance apps. As for preferring the desktop sites, I'm afraid you are in a minority there.
- Iftheshoefits 13y agoAt what point do we stop calling it a "browser" and start calling it "a crippled, inflexible OS?" Relying on the browser as the operating environment in which to run any and every kind of application seems like a misguided a path to take. At some point the browser would have to become a kind of middle-man between the underlying OS and the end-user. There are very few good reasons to prefer "web apps" over native apps in any environment.
- untog 13y agoI don't think anyone thinks that the browser is the perfect medium for something like this. But native development is still extremely costly, because every platform has it's own language and environment. If all the device manufacturers come together tomorrow and propose a cross-platform native programming platform then I'm all for it. Until then we'll rely on HTML.
- United857 13y agoI remember when everyone took Microsoft to task for their "private" APIs in Windows, deep IE integration, etc to give their own apps an advantage,and forced them to level the playing field. Why is no one up in arms about Apple doing essentially the same thing with Safari vs. UIWebView?
- th0ma5 13y agoI wanted to get into iPhone development, and I kept looking back thinking I was inept at Obj-C, and I may well still be, but thank you for saying this, it reminded me that my ideas that mixed local and remote content and web technology made me quickly realize that WebView was a second class citizen, and I would've needed to reimplement a whole browser to make what I wanted on the iPhone. So I switched to Android where the WebView is a better object, although it would be nice to have an embedded Chrome based web view.
- untog 13y agoFYI there is a Chrome-based WebView in Android 4.4 and up. So, it'll be a while before we can rely on it, but one day...
- batmansbelt 13y agoSafari is basically the worst browser right now. They have a firm toe hold in mobile obviously, but in terms of desktop it's the worst browser to support, even behind IE. Nice to see them finally getting with the times. Every other browser has had this technology for years.
- Osmium 13y ago> Nice to see them finally getting with the times. Every other browser has had this technology for years. Citation needed? Safari's had a JIT JavaScript engine since 2008, and was one of the first (if I remember correctly). This is just a new version again.
- matthewmacleod 13y agoThis is just flat wrong. Safari is basically at feature parity with Chrome, which isn't surprising given that they only diverged recently. I haven't to my knowledge ever had to work around differences between the two. Indeed, Safari has had JITed JS for longer than most browsers - this is just an update.
- Touche 13y ago> Safari is basically at feature parity with Chrome Is this a joke? IndexedDB, WebRTC, etc.?
- Turing_Machine 13y agoIndeed. There are many missing features in Safari, including such basic stuff as allowing you to set the download attribute on hyperlinks. That makes it very difficult to write client-side apps for Safari (at least if you want to allow the user to save the output to disk). This is a personal pain point that's bitten me several times. For those who aren't familiar with the problem, say you've written a cool web app that creates (just for example) ZIP files. You want to let the user save these to disk. In Chrome, Firefox, or Opera, this is dirt-simple. Put the ZIP data in a data URL, set the href attribute of the link to the data URL, and set the download attribute to "yourcoolfilename.zip" (or whatever you want). Boom. Done. User clicks the link, data downloads to "yourcoolfilename.zip". Totally streamlined. Not in Safari. The best you can do there is open up the data URL in a new window (which of course ignores any mime type you've set, so the user gets an ugly screen full of binary data) and tell them to use Save As to save the mess. Very nasty. Chrome has had this feature for 20 (!) versions, Firefox for 9, Opera for 5. It even works on the Android and Blackberry browsers. Even IE allows this (in a completely non-standard and convoluted way, naturally, but it can be done).
- deleted 13y ago[deleted]
- lightblade 13y agoNevermind.. Apparently it stands for Fourth Tier LLVM. Source: https://trac.webkit.org/wiki/FTLJIT https://trac.webkit.org/wiki/FTLJIT But it would be awesome if it's faster than light.
- killercup 13y agoIndeed it is. And quite funny, as: Faster than speed of light <=> faster than c
- dudus 13y agoWhy can't they just use v8 or spidermonkey? Why invest time on creating something that will be only marginally superior (maybe?) than current open source technologies?
- sp332 13y agoThe people who wrote v8 and spidermonkey are busy writing new things too.
- azakai 13y agoIt's great that Apple has smart engineers working on this. It's trying out a new approach that neither v8 or spidermonkey have - to use LLVM as a 4th tier JIT. This is how interesting things happen. The world would be a poorer place if we had fewer independent implementations, as each has its own design and architecture.
- stcredzero 13y agoto use LLVM as a 4th tier JIT So, what if this led to a bytecode derived from LLVM IR becoming a universal bytecode for the web?
- matthewmacleod 13y agoBear in mind that JavascriptCore is also open-source. There's absolutely no damage caused by having a diverse number of implementations!
- ahomescu1 13y agoThe title makes me cringe. It makes it sound like this is the first JIT from Apple, when it's actually the "Fourth Tier LLVM" JIT. It goes on top of the current JavaScript engine, which is already pretty fast.
- dang 13y agoOk, we replaced it with the subtitle.
- peterhunt 13y agoI have built lots and lots of stuff on mobile web. Never once was JavaScript perf the bottleneck on iOS. Never (especially since the rise of retina screens). I think there is a lot of hyperbole around the whole JIT in webview thing from people who don't have a good grasp of where the performance problems are on mobile web.
- iratedev 13y agoIt is a known "issue" [0] that iOS gimps JavaScript in webview for security purposes. Specifically, the Nitro engine is disabled. [0]http://blog.mobtest.com/2012/05/heres-why-the-facebook-ios-app-is-so-bad-uiwebviews-and-no-nitro/ http://blog.mobtest.com/2012/05/heres-why-the-facebook-ios-a...
- etrinh 13y agoThis. To my knowledge, JS perf isn't an issue in any modern browser (even the crippled iOS webview). Improving the performance of DOM access and manipulation (not just on iOS) would be a much more fruitful enterprise and is something I would like to see all browser makers focusing on.
- malandrew 13y agoA million times this. XML at the end of the day is a language with only two types, strings and children. This is woefully inadequate if you want performance. Take a 3D matrix transform for example. It needs to be marshalled from an array of floats to a string to be applied. Then it needs to be parsed back into an array of floats to be used to position a texture in the GPU. Such a huge waste...