Bug 38910 - PageGroupLoadDeferrer should also defer executeScriptSoonTimer
Summary: PageGroupLoadDeferrer should also defer executeScriptSoonTimer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-11 08:36 PDT by Yong Li
Modified: 2010-06-14 12:19 PDT (History)
6 users (show)

See Also:


Attachments
the patch (3.65 KB, patch)
2010-05-11 08:54 PDT, Yong Li
no flags Details | Formatted Diff | Diff
fix merge error (3.66 KB, patch)
2010-05-11 10:41 PDT, Yong Li
no flags Details | Formatted Diff | Diff
Test case included thanks to Robin! (5.54 KB, patch)
2010-05-26 08:31 PDT, Yong Li
no flags Details | Formatted Diff | Diff
With enhanced test case (5.61 KB, patch)
2010-05-26 08:52 PDT, Yong Li
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yong Li 2010-05-11 08:36:27 PDT
PageGroupLoadDeferrer suspends all active dom timers and loading jobs. But it doesn't suspend Document::m_executeScriptSoonTimer. In the case a m_executeScriptSoonTimer is already scheduled, and a JS alert window pops up (which is guarded by PageGroupLoadDeferrer), Document::m_executeScriptSoonTimer can still fire and run JS on the same doc, and then can schedule DOM timers on the doc.

I've seen it results ASSERTION failure in DOMTimer when the PageGroupLoadDeferrer destructs. (it resumes dom timers, and every dom timer asserts that it is currently suspended.)

But this problem cannot be reproduced reliably because it depends on timing. It happens only when m_executeScriptSoonTimer has been scheduled by not fired yet before a PageGroupLoadDeferrer is constructed.

The solution is simple: Just suspend all executeScriptSoonTimer timers in PageGroupLoadDeferrer ctor, and resume them in PageGroupLoadDeferrer dtro.

But it's very hard to create a layout test for it. Help needed!!!
Comment 1 Yong Li 2010-05-11 08:54:49 PDT
Created attachment 55707 [details]
the patch
Comment 2 Yong Li 2010-05-11 10:41:09 PDT
Created attachment 55718 [details]
fix merge error
Comment 3 Yong Li 2010-05-26 08:31:42 PDT
Created attachment 57099 [details]
Test case included thanks to Robin!

Thanks to Robin Cao, who created the test case.

This test cast can reproduce the problem reliably.

Robin has verified this problem happens on both Safari for Windows and QtLauncher.
Comment 4 WebKit Review Bot 2010-05-26 08:32:18 PDT
Attachment 57099 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1
WebCore/manual-tests/resources/load-deferrer-script-element.js:1:  One or more unexpected \r (^M) found; better to use only a \n  [whitespace/carriage_return] [1]
Suppressing further [whitespace/carriage_return] reports for this file.
Total errors found: 5 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Yong Li 2010-05-26 08:52:54 PDT
Created attachment 57102 [details]
With enhanced test case
Comment 6 Darin Adler 2010-06-13 21:27:53 PDT
Comment on attachment 57102 [details]
With enhanced test case

Can this work be put into the suspendActiveDOMObjects and resumeActiveDOMObjects function rather than adding two more member functions to Document? I’d prefer to do it that way. It’s OK this way, but I’d prefer not to modify Document.h and PageGroupLoadDeferrer.cpp.

r=me
Comment 7 George Staikos 2010-06-14 06:12:35 PDT
Let's open a second bug report to refactor it.  I think we have a couple of additional similar patches coming.
Comment 8 Yong Li 2010-06-14 08:59:34 PDT
Comment on attachment 57102 [details]
With enhanced test case

I agree they should be merged into one function, but the old function name seems a little bit misleading. PageGroupLoadDeferrer needs to be purified more, and refactoring can be done in next patches. Committing it for now?
Comment 9 WebKit Commit Bot 2010-06-14 09:27:21 PDT
Comment on attachment 57102 [details]
With enhanced test case

Clearing flags on attachment: 57102

Committed r61126: <http://trac.webkit.org/changeset/61126>
Comment 10 WebKit Commit Bot 2010-06-14 09:27:28 PDT
All reviewed patches have been landed.  Closing bug.