Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-3927

Exec Can Fail to Issue Callback Immediately After onCordovaReady

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0
    • cordova-android, cordova-js
    • None

    Description

      If javascript issues an exec to native after waiting for onCordovaReady the exec can possibly fail to issue any callback. The bug is caused when CordovaWebViewClient.onPageStarted, which resets the NativeToJsMessageQueue, is called between native queuing the response message and the javascript polling for that response. While webView.loadUrl is called near the entry point of the app, the onPageStarted event can happen very far in the future, after cordova-ready.

      These are the order of events that typically need to happen for this bug to manifest:

      • webView.loadUrl is called near entry point of app
      • At some point in the future after cordova-ready, exec is called by javascript
      • Native handler processes exec but gets blocked before the response message can be added to the queue because another thread is currently accessing the queue
      • Native exec returns without response
      • Handler gets unblocked and adds the response message to the queue and signals to javascript that there are messages to be read
      • CordovaWebViewClient.onPageStarted is called which resets the message queue
      • javascript receives signal from native and polls for messages, but gets none in response because the queue was reset

      The end result is that neither the success or failure callback of the exec ever gets issued.

      Attachments

        1. 0001-Exec-bug-reproducing.patch
          10 kB
          Jeffrey Willms

        Activity

          People

            agrieve Andrew Grieve
            jbwillms Jeffrey Willms
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: