Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-13067

Android: Global execution context inside WebView disappears after load event

    Details

      Description

      Issue

      After WebView.reload() is called, the document object within get a 'ready' event and the window gets a 'load' event. jQuery is used to detect the 'ready' event. The window 'load' event is detected with a standard addEventListener().

      Expected results

      Inside the 'ready' event handler, a 'isReady' flag is set true. When the window 'load' event handler executes, it is still true.

      Actual results

      What's not expected is that sometime afterwards, the 'isReady' flag another other state goes away and new state appears. This can easily be seen by looking at the internal uuid that's globally created (intUuid). You'll notice that after the reload, a new value is generated (45926d11-60ec-2f85-ed95-16f311f1507f) as expected, but then a new value appears (4f0786c4-de9f-f0d7-2b03-46c7752b1431).

      This appears to be a 2nd brand new global execution context inside the webview. This means that state in the 1st brand new global context (the one that has isRead flag set to true) is now gone.

      Reproduction Steps

      1. start app
      2. notice external and internal uuids
      3. tap [dump] button
      4. notice external and internal uuids. they'll be the same as those in step 2.
      5. tap [reload] button
      6. notice a (na) external uuid, as expected
      7. notice in the document ready log, a brand new internal uuid and a isReady 8. flag set to false, as expected
      8. notice in the window load log, isReady flag is set to true, as expected
      9.now notice isDocReady log, both the internal uuid and the isReady flag are different from that in step 8

      Events stack trace attached on debug mode

      Load

      [INFO][TiAPI   ( 2428)] test.html: document ready: extUuid: na, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: false
      [INFO][TiAPI   ( 2428)] test.html: window load: extUuid: na, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)]  app.js: webview.beforeload: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)]  app.js: webview.load: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: na, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      [INFO][TiAPI   ( 2428)]  app.js: eval'ing: myFunc('35f3b60f-e4aa-4698-b989-d9d260170d95')
      [INFO][TiAPI   ( 2428)] test.html: myFunc: _extUuid: 35f3b60f-e4aa-4698-b989-d9d260170d95
      [INFO][TiAPI   ( 2428)] test.html: myFunc: extUuid: 35f3b60f-e4aa-4698-b989-d9d260170d95, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: 35f3b60f-e4aa-4698-b989-d9d260170d95, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: 35f3b60f-e4aa-4698-b989-d9d260170d95, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      

      Dump

      [INFO][TiAPI   ( 2428)]  app.js: dumping state for uuid: 35f3b60f-e4aa-4698-b989-d9d260170d95
      [INFO][TiAPI   ( 2428)] test.html: dumpState: extUuid: 35f3b60f-e4aa-4698-b989-d9d260170d95, intUuid: b287c702-fc78-2195-b241-afecaa71c6be, isReady: true
      

      Reload

      [INFO][TiAPI   ( 2428)]  app.js: resetting url
      [INFO][TiAPI   ( 2428)]  reloading...
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)] test.html: document ready: extUuid: na, intUuid: 45926d11-60ec-2f85-ed95-16f311f1507f, isReady: false
      [INFO][TiAPI   ( 2428)] test.html: window load: extUuid: na, intUuid: 45926d11-60ec-2f85-ed95-16f311f1507f, isReady: true
      [INFO][TiWebChromeClient.console( 2428)] (main) [49230,73278] Uncaught ReferenceError: Ti is not defined (20:file:///android_asset/Resources/test.html)
      [INFO][TiWebChromeClient.console( 2428)] (main) [2,73280] Uncaught ReferenceError: Ti is not defined (25:file:///android_asset/Resources/test.html)
      [INFO][TiAPI   ( 2428)]  app.js: webview.beforeload: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: na, intUuid: 4f0786c4-de9f-f0d7-2b03-46c7752b1431, isReady: false
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)]  app.js: webview.load: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)]  app.js: webview.beforeload: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)]  app.js: webview.load: uuid: na, url: file:///android_asset/Resources/test.html
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: na, intUuid: 4f0786c4-de9f-f0d7-2b03-46c7752b1431, isReady: false
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: na, intUuid: 4f0786c4-de9f-f0d7-2b03-46c7752b1431, isReady: false
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      [INFO][TiAPI   ( 2428)] test.html: isDocReady: extUuid: na, intUuid: 4f0786c4-de9f-f0d7-2b03-46c7752b1431, isReady: false
      [INFO][TiAPI   ( 2428)]  will retry evalWhenReady...
      

        Attachments

        1. app.js
          2 kB
        2. jquery-1.9.1.min.jsx
          90 kB
        3. test.html
          1 kB

          Activity

            People

            • Assignee:
              mstepanov Max Stepanov
              Reporter:
              egomez Eduardo Gomez (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-15896
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration