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

Cordova 2.1 callbacks stops working after sleep/wake with jQuery Mobile + Android Transformer Pad

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.2.0
    • cordova-android
    • None
    • Android 4.0.3; Asus Transformer Pad,

    Description

      Using attached sample app, program works up until tablet goes to sleep. When the tablet wakes up, callback no longer functions

      Full thread of original problem report: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/ut3RqEgDx58

      I started with Cordova 2.0.0, then while investigating upgraded to development code from github and struck an introduced, now fixed, problem. SO I am now back to the original issue but with latest code (2.1 RC)

      Steps to reproduce:
      ------------------
      1. Install attached APK file (I also include source in separate zip (includes cordova.jar file), and run program.

      2. Touch the "dialog" button
      OBSERVED: Text says "mary had a little lamb..." ( result from plugin)
      3. Touch "Close" to return to front screen
      4. Wait for the tablet to go to sleep and disconnect from network etc - takes about 5 minutes with my tablet as it is configured. (screen going dark is not enough, it has to shut down into deep sleep)

      5. Wake the tablet and unlock screen
      6. Touch the "dialog" buitton again.
      EXPECTED: Text "mary had a little lamb..." again
      but OBSERVED: Text "if you are reading this something went wrong"

      What seems to be happening
      ---------------------------
      The way the dialog works is that the "something wrong" message is the text in the HTML file, but the page show functions calls a plugin to get the text to show. This is all handled by jQuery Mobile with an ajax load.

      Until the deep sleep point, everything works as expected, the plugin returns a result which is placed in the queue, then the setTimeout()-based Javascript side picks it up.

      After deep sleep, the callback mechanism breaks, and although the plugin is called and produces a result, this is never collected from Javascript.

      I watch the log with the command :
      adb logcat -v time | grep -E "Cordova|Callback|DroidGap|TPadBug"

      So while it is working...

      8-28 14:15:32.180 D/DroidGap(29867): onMessage(onPageFinished,file:///android_asset/www/index.html#/android_asset/www/index.html&ui-state=dialog)
      08-28 14:15:32.200 D/CordovaLog(29867): Dialog is about to call plugin
      08-28 14:15:32.200 D/CordovaLog(29867): file:///android_asset/www/tpadbug2.js: Line 44 : Dialog is about to call plugin
      08-28 14:15:32.200 D/TPadBugPlugin(29867): Enter plugin action:GetRandomText
      08-28 14:15:32.200 D/TPadBugPlugin(29867): Plugin successful
      08-28 14:15:32.200 D/TPadBugPlugin(29867): Plugin exiting
      08-28 14:15:32.250 D/CordovaLog(29867): Dialog has got results back from plugin: 102 chars
      08-28 14:15:32.250 D/CordovaLog(29867): file:///android_asset/www/tpadbug2.js: Line 47 : Dialog has got results back from plugin: 102 chars
      08-28 14:15:35.770 D/Cordova (29867): onPageFinished(file:///android_asset/www/index.html)

      Note particular the "Dialog has got results back.." which shows the JS callback working.

      After a sleep/resume cycle:

      08-28 14:23:05.880 D/DroidGap(29867): onMessage(onPageFinished,file:///android_asset/www/index.html#/android_asset/www/index.html&ui-state=dialog)
      08-28 14:23:05.900 D/CordovaLog(29867): Dialog is about to call plugin
      08-28 14:23:05.900 D/CordovaLog(29867): file:///android_asset/www/tpadbug2.js: Line 44 : Dialog is about to call plugin
      08-28 14:23:05.900 D/TPadBugPlugin(29867): Enter plugin action:GetRandomText
      08-28 14:23:05.900 D/TPadBugPlugin(29867): Plugin successful
      08-28 14:23:05.900 D/TPadBugPlugin(29867): Plugin exiting

      .. and nothing more, no dialog handler.

      (I did have a lot of console.log and Log.d calls as well, but these got lost in some of the test and updating to latest code. Read Google Groups thread for the agonizing detail).

      Needless to say, this stops my app in its tracks.

      I left an additional page for "test timeouts" which if you navigate to this, it shows that callbacks are once again working, and then when you go back (using the android back button) to the indexpage, the callbacks start working there again too .. until the next time it falls sleep. However this is not an acceptable solution for a production app.

      Attachments

        1. TPadBug-debug.apk
          383 kB
          Walter Nicholls
        2. TPadBug-src.zip
          474 kB
          Walter Nicholls

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bowserj Joey Robert Bowser
            wnicholls Walter Nicholls
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment