New in iOS 8 is a bug that blocks the UI when more than a couple of JavaScript to native code communications take place.
Native to Javascript communication is via UIWebView
's stringByEvaluatingJavaScriptFromString
, and JavaScript to native is done via a custom URL Scheme.
If I do a three or more webview -> native communications, the first two happen immediately, however the subsequent ones take 10 seconds per communication to occur.
Anyone experiencing this?
EDIT: 2014/09/23
Specifically, the problem occurs if you do two javascript to native calls consecutively,
[self.webView stringByEvaluatingJavaScriptFromString:@"calliOS('aurlscheme://awebview?say=two'); calliOS('aurlscheme://awebview?say=cat');"];
where calliOS() is a JavaScript function that uses to the iframe hack to call the native code through the URL scheme.
If you replace the iframe hack with a straight call to 'window.location',
[self.webView stringByEvaluatingJavaScriptFromString:@"window.location='aurlscheme://awebview?say=two';window.location='aurlscheme://awebview?say=cat';"];
You lose all but the last URL scheme request.
So in conclusion, when making rapid consecutive javascript to native calls, either you use the iframe hack and the UI freezes for a few seconds, or you use the window.location
way and lose all but the last request.
application:application handleOpenURL:url
to catch the request, parse the GET query string and the pass the dictionary of parameters to the corresponding view controller. – paulvs