Expose JSContext on WKWebView

Originator:tamas.lustyik
Number:rdar://17680867 Date Originated:07/15/2014
Status:Closed Resolved:
Product:OS X SDK Product Version:10.10beta3
Classification:enhancement Reproducible:
 
Unlike the former WebView class, the new WKWebView API doesn't seem to provide a means to access the underlying JSContext. This prevents code using the JavaScriptCore framework from acting on the JavaScript objects living in the context of the page loaded into the WKWebView. The provided WKUserContentController API is simply inefficient for marshalling and manipulating JS objects from native code. Therefore a new API should be added to provide access to the JSContext or JSContextRef that the WKWebView is running on.

Comments

"Engineering has determined that there are no plans to address this based on the following:

WKWebView can't expose a JS context since the web content runs in a separate process.

Please let us know whether that helps you resolve the issue.

Please be sure to regularly check new Apple releases for any updates that might affect this issue."

By tamas.lustyik at Oct. 20, 2014, 9:03 p.m. (reply...)

I don't think that's ever going to happen. WKWebView is just a dumb interface for XPC. The web view doesn't live in your app anymore when you use WKWebView. Even if they somehow managed to let you access JSContext over the process boundaries, it would probably be unsafe.

(In case you're wondering why WKWebView lives in its own process, it's for performance. You couldn't do JIT in apps before, because that requires changing executable memory, which is unsafe.)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!