Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.7.0
    • Fix Version/s: 1.8.0
    • Component/s: Android
    • Labels:
      None

      Description

      This issue is able to be ignored in Android 1.7, but it has come to a head in Android 1.8, since we moved where the Callback Server lives.
      D/CordovaLog( 3395): file:///android_asset/www/cordova-1.7.0.js: Line 3570 : JSCallback Error: Request failed.

      When this occurs, and you have methods that are called onDeviceReady, while the interfaces exist, there's no way to get the callback, which means that it hangs forever and always fails when using the CordovaWebView branch. This indicates that we are calling onNativeReady prematurely when we go from page to page, and that we have to wait for the server to be ready before calling this.

        Issue Links

          Activity

          Hide
          Filip Maj added a comment -

          Interestingly, I cannot reproduce with the Accelerometer. Using the stock example that comes with cordova-android currently, if I call navigator.accelerometer.watchAcceleration inside the deviceready callback, it works fine and no errors are reported in logcat on my Galaxy Nexus running 4.0.2.

          Joe mentioned that this was coming up while using the File API, so I will investigate with calling resolveLocalFileURI inside deviceready.

          Show
          Filip Maj added a comment - Interestingly, I cannot reproduce with the Accelerometer. Using the stock example that comes with cordova-android currently, if I call navigator.accelerometer.watchAcceleration inside the deviceready callback, it works fine and no errors are reported in logcat on my Galaxy Nexus running 4.0.2. Joe mentioned that this was coming up while using the File API, so I will investigate with calling resolveLocalFileURI inside deviceready .
          Hide
          Filip Maj added a comment -

          If I drop mobile-spec into it, I see the "request failed" message showing up in my logs when I load different pages. I believe this log also comes up not on-load of a page, but rather on unload of a page. Investigating further!

          Show
          Filip Maj added a comment - If I drop mobile-spec into it, I see the "request failed" message showing up in my logs when I load different pages. I believe this log also comes up not on-load of a page, but rather on unload of a page. Investigating further!
          Hide
          Filip Maj added a comment -

          Using mobile-spec, I did a simple test: loading the index page, loading another page, and then hitting the back button to re-load the index page. On both pages, I added console.log}}s in the {{window.onload, window.onunload, and deviceready events (I have seperated these logs with ---- for clarity). My logcat output is below (interspersed with small notices on when I loaded the next page / hit the back button):

          D/DroidGap(24070): DroidGap.onCreate()
          D/DroidGap(24070): DroidGap.loadUrl(file:///android_asset/www/index.html)
          D/DroidGap(24070): DroidGap: url=file:///android_asset/www/index.html baseUrl=null
          V/PhoneStatusBar(  271): setLightsOn(true)
          D/DroidGap(24070): DroidGap.init()
          D/CordovaWebView(24070): Origin to allow: http://127.0.0.1*
          I/CordovaLog(24070): Found log level DEBUG
          I/CordovaLog(24070): Changing log level to DEBUG(3)
          I/CordovaLog(24070): Found preference for useBrowserHistory
          D/PluginManager(24070): init()
          D/SoftKeyboardDetect(24070): Ignore this event
          I/WindowManager(  196): createSurface Window{41c8fc10 ca.filmaj.cwv/ca.filmaj.cwv.CordovaWebView paused=false}: DRAW NOW PENDING
          D/chromium(24070): Unknown chromium error: -6
          D/chromium(24070): Unknown chromium error: -6
          D/SoftKeyboardDetect(24070): Ignore this event
          D/OpenGLRenderer(  447): Flushing caches (mode 1)
          V/PhoneStatusBar(  271): setLightsOn(true)
          ----
          D/CordovaLog(24070): index load
          D/CordovaLog(24070): file:///android_asset/www/main.js: Line 137 : index load
          I/Web Console(24070): index load at file:///android_asset/www/main.js:137
          D/CordovaLog(24070): index deviceready
          D/CordovaLog(24070): file:///android_asset/www/main.js: Line 2 : index deviceready
          I/Web Console(24070): index deviceready at file:///android_asset/www/main.js:2
          ----
          D/OpenGLRenderer(  447): Flushing caches (mode 0)
          W/InputManagerService(  196): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41d6b780 (uid=10028 pid=447)
          I/ActivityManager(  196): Displayed ca.filmaj.cwv/.CordovaWebView: +649ms
          ----
          LOAD NEXT PAGE
          ----
          D/CordovaLog(24070): JSCallback Error: Request failed.
          D/CordovaLog(24070): file:///android_asset/www/cordova-1.7.0.js: Line 3570 : JSCallback Error: Request failed.
          I/Web Console(24070): JSCallback Error: Request failed. at file:///android_asset/www/cordova-1.7.0.js:3570
          ----
          D/CordovaLog(24070): index unload
          D/CordovaLog(24070): file:///android_asset/www/main.js: Line 139 : index unload
          I/Web Console(24070): index unload at file:///android_asset/www/main.js:139
          ----
          D/CordovaLog(24070): Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix.
          D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 5 : Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix.
          V/Web Console(24070): Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix. at file:///android_asset/www/autotest/index.html:5
          D/chromium(24070): Unknown chromium error: -6
          D/chromium(24070): Unknown chromium error: -6
          ----
          D/CordovaLog(24070): autotest load
          D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 13 : autotest load
          I/Web Console(24070): autotest load at file:///android_asset/www/autotest/index.html:13
          D/CordovaLog(24070): autotest deviceready
          D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 18 : autotest deviceready
          I/Web Console(24070): autotest deviceready at file:///android_asset/www/autotest/index.html:18
          ----
          HIT BACK BUTTON
          ----
          D/CordovaLog(24070): JSCallback Error: Request failed.
          D/CordovaLog(24070): file:///android_asset/www/cordova-1.7.0.js: Line 3570 : JSCallback Error: Request failed.
          I/Web Console(24070): JSCallback Error: Request failed. at file:///android_asset/www/cordova-1.7.0.js:3570
          ----
          D/CordovaLog(24070): autotest unload
          D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 15 : autotest unload
          I/Web Console(24070): autotest unload at file:///android_asset/www/autotest/index.html:15
          ----
          D/chromium(24070): Unknown chromium error: -6
          D/chromium(24070): Unknown chromium error: -6
          ----
          D/CordovaLog(24070): index load
          D/CordovaLog(24070): file:///android_asset/www/main.js: Line 137 : index load
          I/Web Console(24070): index load at file:///android_asset/www/main.js:137
          D/CordovaLog(24070): index deviceready
          D/CordovaLog(24070): file:///android_asset/www/main.js: Line 2 : index deviceready
          I/Web Console(24070): index deviceready at file:///android_asset/www/main.js:2
          ----
          

          This confirms my intuition that the request failed log message happens during a page UNLOAD.

          Now will dive into native code and see why this is happening and what, if anything, we can do to stop this from happening.

          Show
          Filip Maj added a comment - Using mobile-spec, I did a simple test: loading the index page, loading another page, and then hitting the back button to re-load the index page. On both pages, I added console.log}}s in the {{window.onload , window.onunload , and deviceready events (I have seperated these logs with ---- for clarity). My logcat output is below (interspersed with small notices on when I loaded the next page / hit the back button): D/DroidGap(24070): DroidGap.onCreate() D/DroidGap(24070): DroidGap.loadUrl(file:///android_asset/www/index.html) D/DroidGap(24070): DroidGap: url=file:///android_asset/www/index.html baseUrl=null V/PhoneStatusBar( 271): setLightsOn(true) D/DroidGap(24070): DroidGap.init() D/CordovaWebView(24070): Origin to allow: http://127.0.0.1* I/CordovaLog(24070): Found log level DEBUG I/CordovaLog(24070): Changing log level to DEBUG(3) I/CordovaLog(24070): Found preference for useBrowserHistory D/PluginManager(24070): init() D/SoftKeyboardDetect(24070): Ignore this event I/WindowManager( 196): createSurface Window{41c8fc10 ca.filmaj.cwv/ca.filmaj.cwv.CordovaWebView paused=false}: DRAW NOW PENDING D/chromium(24070): Unknown chromium error: -6 D/chromium(24070): Unknown chromium error: -6 D/SoftKeyboardDetect(24070): Ignore this event D/OpenGLRenderer( 447): Flushing caches (mode 1) V/PhoneStatusBar( 271): setLightsOn(true) ---- D/CordovaLog(24070): index load D/CordovaLog(24070): file:///android_asset/www/main.js: Line 137 : index load I/Web Console(24070): index load at file:///android_asset/www/main.js:137 D/CordovaLog(24070): index deviceready D/CordovaLog(24070): file:///android_asset/www/main.js: Line 2 : index deviceready I/Web Console(24070): index deviceready at file:///android_asset/www/main.js:2 ---- D/OpenGLRenderer( 447): Flushing caches (mode 0) W/InputManagerService( 196): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41d6b780 (uid=10028 pid=447) I/ActivityManager( 196): Displayed ca.filmaj.cwv/.CordovaWebView: +649ms ---- LOAD NEXT PAGE ---- D/CordovaLog(24070): JSCallback Error: Request failed. D/CordovaLog(24070): file:///android_asset/www/cordova-1.7.0.js: Line 3570 : JSCallback Error: Request failed. I/Web Console(24070): JSCallback Error: Request failed. at file:///android_asset/www/cordova-1.7.0.js:3570 ---- D/CordovaLog(24070): index unload D/CordovaLog(24070): file:///android_asset/www/main.js: Line 139 : index unload I/Web Console(24070): index unload at file:///android_asset/www/main.js:139 ---- D/CordovaLog(24070): Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix. D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 5 : Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix. V/Web Console(24070): Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix. at file:///android_asset/www/autotest/index.html:5 D/chromium(24070): Unknown chromium error: -6 D/chromium(24070): Unknown chromium error: -6 ---- D/CordovaLog(24070): autotest load D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 13 : autotest load I/Web Console(24070): autotest load at file:///android_asset/www/autotest/index.html:13 D/CordovaLog(24070): autotest deviceready D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 18 : autotest deviceready I/Web Console(24070): autotest deviceready at file:///android_asset/www/autotest/index.html:18 ---- HIT BACK BUTTON ---- D/CordovaLog(24070): JSCallback Error: Request failed. D/CordovaLog(24070): file:///android_asset/www/cordova-1.7.0.js: Line 3570 : JSCallback Error: Request failed. I/Web Console(24070): JSCallback Error: Request failed. at file:///android_asset/www/cordova-1.7.0.js:3570 ---- D/CordovaLog(24070): autotest unload D/CordovaLog(24070): file:///android_asset/www/autotest/index.html: Line 15 : autotest unload I/Web Console(24070): autotest unload at file:///android_asset/www/autotest/index.html:15 ---- D/chromium(24070): Unknown chromium error: -6 D/chromium(24070): Unknown chromium error: -6 ---- D/CordovaLog(24070): index load D/CordovaLog(24070): file:///android_asset/www/main.js: Line 137 : index load I/Web Console(24070): index load at file:///android_asset/www/main.js:137 D/CordovaLog(24070): index deviceready D/CordovaLog(24070): file:///android_asset/www/main.js: Line 2 : index deviceready I/Web Console(24070): index deviceready at file:///android_asset/www/main.js:2 ---- This confirms my intuition that the request failed log message happens during a page UNLOAD. Now will dive into native code and see why this is happening and what, if anything, we can do to stop this from happening.
          Hide
          Joe Bowser added a comment -

          The fix was related to when the callback server actually starts and stops. It doesn't make sense for the callback server to be stopped and restarted on loadUrl, and instead it should happen on the onPageStarted in the CordovaWebViewClient. That being said, I'm not sure why we are doing this at all, but that discussion should take place on the list.

          Show
          Joe Bowser added a comment - The fix was related to when the callback server actually starts and stops. It doesn't make sense for the callback server to be stopped and restarted on loadUrl, and instead it should happen on the onPageStarted in the CordovaWebViewClient. That being said, I'm not sure why we are doing this at all, but that discussion should take place on the list.

            People

            • Assignee:
              Joe Bowser
              Reporter:
              Joe Bowser
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development