Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13067] Android: Global execution context inside WebView disappears after load event

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2013-03-19T23:32:37.000+0000
Affected Version/sRelease 3.0.2, Release 3.1.0
Fix Version/s2013 Sprint 06 Core, 2013 Sprint 06
ComponentsAndroid
LabelsSupportTeam, triage
ReporterEduardo Gomez
AssigneeMax Stepanov
Created2013-03-14T18:51:36.000+0000
Updated2017-03-03T22:12:23.000+0000

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

FileDateSize
app.js2013-03-14T18:51:36.000+00001667
jquery-1.9.1.min.jsx2013-03-14T18:51:36.000+000092629
test.html2013-03-14T18:51:36.000+00001365

Comments

  1. Max Stepanov 2013-03-19

    See comment to TIMOB-13057
  2. Lee Morris 2017-03-03

    Closing as invalid.

JSON Source