cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Freyhall (JIRA)" <>
Subject [jira] [Commented] (CB-10774) CDVUIWebView performs javascript synchronous, but command queue expects it to be async
Date Mon, 02 May 2016 06:30:13 GMT


Torsten Freyhall commented on CB-10774:

In my opinion, the javascript code fixed in #CB-10530 should never execute unless the command
bridge (I think it was called something like that) has changed.

My quick tests pointed at that the reason for the bridge change detection timeout to trigger
in the javascript was that the native code expected the javascript callbacks to be run async.
I haven't dug any further into the issue, just checked that this also solved the problem in
#CB-10530. Also, it might have other side effects, however they should be limited to the UIWebViewEngine,
since WKWebView performs javascript async by default.

> CDVUIWebView performs javascript synchronous, but command queue expects it to be async
> --------------------------------------------------------------------------------------
>                 Key: CB-10774
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 4.1.0
>            Reporter: Torsten Freyhall
>            Assignee: Shazron Abdullah
>              Labels: cordova-ios-4.1.1
> From regarding app freezing at launch.
> ...
> However I was not sure about why the timer resolves due to long script execution times
though. It seems like the intention is that whenever gap://ready is loaded in the iframe,
the immediate response from the native side should be to call nativeFetchMessages() which
should clear the timeout.
> Therefore I dug a little deeper in the native side, and found that the evaluateJavaScript:completionHandler:
in CDVCommandQueue expects implementation to to be async (a comment in the code says so),
but the CDVUIWebViewEngine method actually is implemented synchronous.
> I wrapped the entire method in a dispatch_async call (maybe a very naive solution, it
might mess with references?):
> {code}
> dispatch_async(dispatch_get_main_queue(), ^{
>   NSString* ret = [(UIWebView*)_engineWebView stringByEvaluatingJavaScriptFromString:javaScriptString];
> if (completionHandler)
> { completionHandler(ret, nil); }
> });
> {code}
> This also solves the original issue on cordova-ios 4.0.1 as the timeout never resolves,
so maybe asyncing this method should also be a part of the proper fix?

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message