Closed jacob314 closed 9 years ago
Ok, following along a test case Jacob had, we created this smaller repro of some of the bug/problems.
to repro: put all the 3 files in the same dir, then open index.html in dartium. Click on "move away" then click the back button, look at the output printed in the console.
Some interesting things:
Attachments: other.dart (31 Bytes) index.html (235 Bytes) isolate_bug.dart (197 Bytes)
Changed priority to medium as we don't need to run multiple DOM isolates each in their own script tags in the near future so this bug won't be an immediate blocker.
Removed Priority-High label. Added Priority-Medium label.
This comment was originally written by antonm@google.com
That's an abuse of Dart's DOM app model.
As of now adding dart scripts on the fly have undefined behaviour. For example, if you add it late enough, those scripts won't be executed.
Technically right now NodeList of script elements was used, and this node list is live, so if you modify it on the fly via script elements insertion, you've got this behaviour.
To make this behaviour more robust at least I'm adding snapshotting of the list script tags found when about to start dart isolates: at least we should have consistent behaviour.
Added this to the M5 milestone. Added AsDesigned label.
Clicking the back button in Dartium sometimes causes Dartium to run two separate DOM isolates for the same .dart code causing the page to render incorrectly unless hacky code like the following is added. The issue only occurs when you open a page containing Dart, navigate to a link on a different domain, then click the back arrow to reopen the page. Reloading a page or opening the page fresh will not trigger the issue.
Note: clicking the back arrow by design behaves differently than reloading the page. For example, scripts aren't reloaded, etc. As far as I know, the issue only reproduces reliably on large applications where perhaps there are browser memory leaks due to lots of event listeners attached to the DOM.
Here is the code I use add to workaround the issue.
// This is a workaround for a bug where an isolate is loaded twice when the back button is pressed. main() { if (document.documentElement.dataset.containsKey('dart-loaded')) { throw "Skipping main as Dart is already loaded. This is due to a Dartium bug"; } document.documentElement.dataset['dart-loaded'] = "true";
// Run actual main code.... }