cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shazron Abdullah (JIRA)" <>
Subject [jira] [Commented] (CB-8838) WKWebView iosExec Results in Double Call
Date Thu, 09 Apr 2015 23:26:13 GMT


Shazron Abdullah commented on CB-8838:

By inspection and by your description -- it indeed looks like a bug.

The old way was through this:

which calls fetchCommandsFromJs which in turn will call the js, which clears the queue. This
is not called in the new bridge. My patch initially was to make it work with the new WKWebView
binding with minimal impact to the existing bridge. Although I don't really see how the queued
commands are replayed, since commandQueue should never be used by the new bridge -- the bug
here is as you correctly pointed out, it shouldn't be queued in the first place.

I setup a new repo with a test, and I'll be testing that to verify:
This contains the Camera plugin.

I'll report back what I find out.

> WKWebView iosExec Results in Double Call
> ----------------------------------------
>                 Key: CB-8838
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, CordovaLib, iOS
>    Affects Versions: 4.0.0
>            Reporter: Thomas Mouton
>   Original Estimate: 4h
>  Remaining Estimate: 4h
> When we invoke the cordova Barcode plugin, it is always called twice!
> I have only looked at the code a short time, but it appears to me that:
> * the first call to Barcode happens, and in iosExec, it gets placed in commandQueue.
> * the first call passes to Objective C world by WKScriptMessageHandler - (void)userContentController:(WKUserContentController*)userContentController
> * this call to Barcode does its thing, completes, and it's javascript response handler
code winds through:
>     CDVCommandDelegateImpl::sendPluginResult
>     CDVCommandDelegateImpl::evalJSHelper
>     CDVCommandDelegateImpl::evalJSHelper2
> * in Helper2, the callback is finally passed to a webViewEngine, which processes the
Javascript, and returns, on completion, a list of commands remaining in the javascript commandQueue.
> * these commands are queued on the Obj-C side and run in CDVCommandQueue fashion.
> AHA!
> * since the command was persisted in commandQueue before execution, and not removed,
it is called again!
> SO
> I moved the enqueue behavior into the branch that excludes bridgeMode === jsToNativeModes.WK_WEBVIEW_BINDING
> This fixes it, but I am not confident its the right solution.
> Do you have any insight into this problem?
> Feedback for my solution?
> A broader or more appropriate venue for the conversation?
> Thanks!
> Alex Mouton

This message was sent by Atlassian JIRA

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

View raw message