-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on iOS 12 #340
Comments
Add the comment from "This solution IS NOT WORKING anymore. The callback now called from the main Thread and if you lock the main thread in the while loop (like in this solution), the callback handler will be never called. evaluateJavaScript waits for main thread released, but it never happens because it locked in the loop. – Mike Keskinov Sep 4 at 0:21" |
As the return value from CDVWKInAppbrowser's evaluateJavascript method is actually never used, it may well just changes the function signature to Thanks |
A change has been made at the pull request |
Could you take a look please @dpa99c? |
The PR changes look good to me: |
Any update for this pull request? |
…cked on ios 12 (#341) ### Platforms affected iOS ### What does this PR do? fix issue[ #340](#340) iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on iOS 12 ### What testing has been done on this change? manual testing ### Checklist - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. - [ ] Added automated test coverage as appropriate for this change.
The pull request has been merged, and the issue is closed. Thanks |
(FYI: If you use |
Hi,
While testing the new ios inappbrowser plugin with wkwebview on iOS 12 device, when the javascript code calls injectScriptCode method, the application may hang.
The reason is in CDVWKInAppBrowser.m, the completing block of evaluateJavascrip method is not called, so the method stuck in the while (!finished) loop
_- (NSString *)evaluateJavaScript:(NSString *)script {
__block NSString resultString = nil;
__block BOOL finished = NO;
__block NSString _script = script;
NSLog(@"evaluateJavaScript: %@", script);
[self.inAppBrowserViewController.webView evaluateJavaScript:script completionHandler:^(id result, NSError *error) {
NSLog(@"evaluatejavascript result: %@, %@", result, error);
if (error == nil) {
if (result != nil) {
resultString = result;
NSLog(@"%@", resultString);
}
} else {
NSLog(@"evaluateJavaScript error : %@ : %@", error.localizedDescription, _script);
}
finished = YES;
}];
}_
The xcode console log has the below output. After calling evaluatejavascript method, it calls runloop method few times in while block, and then just stops, the app is idle.
2018-11-02 09:44:32.646767-0400 wk[5669:2032638] evaluateJavaScript: (function(w){if(!w._cdvMessageHandler) {w._cdvMessageHandler = function(id,d){w.webkit.messageHandlers.cordova_iab.postMessage({d:d, id:id});}}})(window)
2018-11-02 09:44:39.013119-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.013583-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.013827-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.014057-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.014336-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.014561-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.014789-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.015012-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.015234-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.015455-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.015676-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.015898-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.016120-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.016400-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.016622-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.016848-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.017239-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.021299-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.037837-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:44:39.054533-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
2018-11-02 09:45:47.383791-0400 wk[5669:2032638] CDVWKInAppbrowser evaluateJavaScript runloop
I saw someone else also reported the same issue on ios 12 device testing at
https://stackoverflow.com/questions/26778955/wkwebview-evaluate-javascript-return-value
(see the first answer), so this may relate to the iOS 12 behavior change.
Thanks for help.
Jonathan
The text was updated successfully, but these errors were encountered: