Changeset 120108 in webkit


Ignore:
Timestamp:
Jun 12, 2012 1:20:57 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

HTML parser should yield more to improve perceived page load time
https://bugs.webkit.org/show_bug.cgi?id=86165

Source/WebCore:

Patch by Shrey Banga <banga@chromium.org> on 2012-06-12
Reviewed by Tony Gentilcore.

Test: fast/events/event-yield-timing.html

We want the parser to yield at least every 500ms to keep the page somewhat responsive and allow painting.
Since it would be too expensive to check the time after each token, the previous heuristic was to check every 4,096 tokens.
That works fine for most tokens, but a script may spend an arbitrary amount of time executing.

This patch fixes the issue by causing the parser to check the elapsed time immediately after executing a script.

  • html/parser/HTMLParserScheduler.cpp:

(WebCore::HTMLParserScheduler::checkForYieldBeforeScript):

  • html/parser/HTMLParserScheduler.h:

(WebCore::PumpSession::PumpSession):
(PumpSession):
(WebCore::HTMLParserScheduler::checkForYieldBeforeToken):

LayoutTests:

Added test for parser yield times after seeing a script

Patch by Shrey Banga <banga@chromium.org> on 2012-06-12
Reviewed by Tony Gentilcore.

  • fast/parser/parser-yield-timing-expected.txt: Added.
  • fast/parser/parser-yield-timing.html: Added.
  • http/tests/loading/gmail-assert-on-load-expected.txt: The test was added

for an assert that failed on debug builds when an iframe removed itself
from its parent window after blocking for 1 second. In previous builds,
the destroyIt() function was called without yielding to the event loop,
which lead to didFailLoadWithError being called. The fix for bug 86165
ensures that we yield after executing the script, which leads to
didHandleOnloadEventsForFrame being called instead. This is the cause
of the change in output of the test. The test still successfully removes
the iframe and since no asserts fail in the debug build, we should consider
it as passing.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120107 r120108  
     12012-06-12  Shrey Banga  <banga@chromium.org>
     2
     3        HTML parser should yield more to improve perceived page load time
     4        https://bugs.webkit.org/show_bug.cgi?id=86165
     5
     6        Added test for parser yield times after seeing a script
     7
     8        Reviewed by Tony Gentilcore.
     9
     10        * fast/parser/parser-yield-timing-expected.txt: Added.
     11        * fast/parser/parser-yield-timing.html: Added.
     12        * http/tests/loading/gmail-assert-on-load-expected.txt: The test was added
     13        for an assert that failed on debug builds when an iframe removed itself
     14        from its parent window after blocking for 1 second. In previous builds,
     15        the destroyIt() function was called without yielding to the event loop,
     16        which lead to didFailLoadWithError being called. The fix for bug 86165
     17        ensures that we yield after executing the script, which leads to
     18        didHandleOnloadEventsForFrame being called instead. This is the cause
     19        of the change in output of the test. The test still successfully removes
     20        the iframe and since no asserts fail in the debug build, we should consider
     21        it as passing.
     22
     23
    1242012-06-12  Pablo Flouret  <pablof@motorola.com>
    225
  • trunk/LayoutTests/http/tests/loading/gmail-assert-on-load-expected.txt

    r61234 r120108  
    55frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
    66frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
    7 frame "<!--framePath //<!--frame0-->-->" - didFailLoadWithError
     7main frame - didHandleOnloadEventsForFrame
    88main frame - didFinishLoadForFrame
    99This test provokes HTMLTokenizer::timerFired to be called and from within timerFired we want to call WebCore::pageDestroyed.
  • trunk/Source/WebCore/ChangeLog

    r120103 r120108  
     12012-06-12  Shrey Banga  <banga@chromium.org>
     2
     3        HTML parser should yield more to improve perceived page load time
     4        https://bugs.webkit.org/show_bug.cgi?id=86165
     5
     6        Reviewed by Tony Gentilcore.
     7
     8        Test: fast/events/event-yield-timing.html
     9
     10        We want the parser to yield at least every 500ms to keep the page somewhat responsive and allow painting.
     11        Since it would be too expensive to check the time after each token, the previous heuristic was to check every 4,096 tokens.
     12        That works fine for most tokens, but a script may spend an arbitrary amount of time executing.
     13
     14        This patch fixes the issue by causing the parser to check the elapsed time immediately after executing a script.
     15
     16        * html/parser/HTMLParserScheduler.cpp:
     17        (WebCore::HTMLParserScheduler::checkForYieldBeforeScript):
     18        * html/parser/HTMLParserScheduler.h:
     19        (WebCore::PumpSession::PumpSession):
     20        (PumpSession):
     21        (WebCore::HTMLParserScheduler::checkForYieldBeforeToken):
     22
    1232012-06-12  Sami Kyostila  <skyostil@chromium.org>
    224
  • trunk/Source/WebCore/html/parser/HTMLParserScheduler.cpp

    r95901 r120108  
    9696    if (needsFirstPaint && document->isLayoutTimerActive())
    9797        session.needsYield = true;
     98    session.didSeeScript = true;
    9899}
    99100
  • trunk/Source/WebCore/html/parser/HTMLParserScheduler.h

    r95901 r120108  
    4848        , startTime(0)
    4949        , needsYield(false)
     50        , didSeeScript(false)
    5051    {
    5152    }
     
    5455    double startTime;
    5556    bool needsYield;
     57    bool didSeeScript;
    5658};
    5759
     
    6870    void checkForYieldBeforeToken(PumpSession& session)
    6971    {
    70         if (session.processedTokens > m_parserChunkSize) {
     72        if (session.processedTokens > m_parserChunkSize || session.didSeeScript) {
    7173            // currentTime() can be expensive.  By delaying, we avoided calling
    7274            // currentTime() when constructing non-yielding PumpSessions.
     
    7577
    7678            session.processedTokens = 0;
     79            session.didSeeScript = false;
     80
    7781            double elapsedTime = currentTime() - session.startTime;
    7882            if (elapsedTime > m_parserTimeLimit)
Note: See TracChangeset for help on using the changeset viewer.