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

Unable to switch to ONLINE_EVENT Native to JS mode after switching to POLLING

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.5.0
    • None
    • cordova-android
    • None
    • Nexus 4 running Android (KitKat) 4.4.4

    Description

      Switching between ONLINE_EVENT and POLLING Native to JS modes on Android results in the following exception:

      08-05 13:18:29.729: DEBUG/JsMessageQueue(25805): Set native->JS mode to 2
      08-05 13:18:29.739: WARN/WebView(25805): java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41ec6650} called on Looper (JavaBridge, tid 3688) {41ed39e8}, FYI main Looper is Looper (main, tid 1) {41ec6650})
              at android.webkit.WebView.checkThread(WebView.java:2072)
              at android.webkit.WebView.setNetworkAvailable(WebView.java:705)
              at org.apache.cordova.NativeToJsMessageQueue$OnlineEventsBridgeMode.reset(NativeToJsMessageQueue.java:320)
              at org.apache.cordova.NativeToJsMessageQueue.setBridgeMode(NativeToJsMessageQueue.java:105)
              at org.apache.cordova.ExposedJsApi.setNativeToJsBridgeMode(ExposedJsApi.java:69)
              at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
              at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.os.HandlerThread.run(HandlerThread.java:61)
      08-05 13:18:29.749: WARN/System.err(25805): java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41ec6650} called on Looper (JavaBridge, tid 3688) {41ed39e8}, FYI main Looper is Looper (main, tid 1) {41ec6650})
      08-05 13:18:29.749: WARN/System.err(25805): at android.webkit.WebView.checkThread(WebView.java:2082)
      08-05 13:18:29.749: WARN/System.err(25805): at android.webkit.WebView.setNetworkAvailable(WebView.java:705)
      08-05 13:18:29.749: WARN/System.err(25805): at org.apache.cordova.NativeToJsMessageQueue$OnlineEventsBridgeMode.reset(NativeToJsMessageQueue.java:320)
      08-05 13:18:29.749: WARN/System.err(25805): at org.apache.cordova.NativeToJsMessageQueue.setBridgeMode(NativeToJsMessageQueue.java:105)
      08-05 13:18:29.749: WARN/System.err(25805): at org.apache.cordova.ExposedJsApi.setNativeToJsBridgeMode(ExposedJsApi.java:69)
      08-05 13:18:29.749: WARN/System.err(25805): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
      08-05 13:18:29.749: WARN/System.err(25805): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
      08-05 13:18:29.749: WARN/System.err(25805): at android.os.Handler.dispatchMessage(Handler.java:102)
      08-05 13:18:29.749: WARN/System.err(25805): at android.os.Looper.loop(Looper.java:136)
      08-05 13:18:29.749: WARN/System.err(25805): at android.os.HandlerThread.run(HandlerThread.java:61)
      08-05 13:18:29.749: WARN/System.err(25805): Caused by: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41ec6650} called on Looper (JavaBridge, tid 3688) {41ed39e8}, FYI main Looper is Looper (main, tid 1) {41ec6650})
      08-05 13:18:29.749: WARN/System.err(25805): at android.webkit.WebView.checkThread(WebView.java:2072)
      08-05 13:18:29.749: WARN/System.err(25805): ... 9 more
      08-05 13:18:29.749: DEBUG/CordovaLog(25805): file:///android_asset/www/app/app.js: Line 30018 : processMessage failed: Error: Error: Error calling method on NPObject.
      08-05 13:18:29.749: INFO/chromium(25805): [INFO:CONSOLE(30018)] "processMessage failed: Error: Error: Error calling method on NPObject.", source: file:///android_asset/www/app/app.js (30018)
      08-05 13:18:29.759: DEBUG/CordovaLog(25805): file:///android_asset/www/app/app.js: Line 30018 : processMessage failed: Stack: Error: Error calling method on NPObject.
              at Function.androidExec.setNativeToJsBridgeMode (file:///android_asset/www/cordova.js:993:29)
              at _.extend._androidResult (file:///android_asset/www/app/app.js:30433:33)
              at file:///android_asset/www/app/app.js:587:28
              at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:292:54)
              at processMessage (file:///android_asset/www/cordova.js:1039:21)
              at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1076:13)
              at pollOnce (file:///android_asset/www/cordova.js:944:17)
              at pollingTimerFunc (file:///android_asset/www/cordova.js:949:9)
      08-05 13:18:29.759: INFO/chromium(25805): [INFO:CONSOLE(30018)] "processMessage failed: Stack: Error: Error calling method on NPObject.
              at Function.androidExec.setNativeToJsBridgeMode (file:///android_asset/www/cordova.js:993:29)
              at _.extend._androidResult (file:///android_asset/www/app/app.js:30433:33)
              at file:///android_asset/www/app/app.js:587:28
              at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:292:54)
              at processMessage (file:///android_asset/www/cordova.js:1039:21)
              at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1076:13)
              at pollOnce (file:///android_asset/www/cordova.js:944:17)
              at pollingTimerFunc (file:///android_asset/www/cordova.js:949:9)", source: file:///android_asset/www/app/app.js (30018)
      08-05 13:18:29.759: DEBUG/CordovaLog(25805): file:///android_asset/www/app/app.js: Line 30018 : processMessage failed: Message: S01 VerifyCertificateService774585263 sOK
      08-05 13:18:29.759: INFO/chromium(25805): [INFO:CONSOLE(30018)] "processMessage failed: Message: S01 VerifyCertificateService774585263 sOK", source: file:///android_asset/www/app/app.js (30018)
      

      webView.setNetworkAvailable(true); in OnlineEventsBridgeMode.reset() needs to run in the UI Thread.

      Attachments

        Activity

          People

            agrieve Andrew Grieve
            NathanSmith Nathan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: