⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 212845 in webkit


Ignore:
Timestamp:
Feb 22, 2017, 12:44:30 PM (10 years ago)
Author:
Chris Dumez
Message:

Do not aggressively throttle DOM timers until they've reached their max nesting level
​https://bugs.webkit.org/show_bug.cgi?id=168700
<rdar://problem/29808005>

Reviewed by Simon Fraser.

Source/WebCore:

Do not aggressively throttle DOM timers until they've actually areached their max
nesting level (5). This overly aggressive throttling of non-nested timers is what
was causing Google Maps to use 100% CPU in background tabs for several minutes.

Test: fast/dom/timer-throttling-hidden-page-non-nested.html

  • dom/Document.cpp:

(WebCore::Document::timerAlignmentInterval):

LayoutTests:

Add layout test coverage.

  • TestExpectations:
  • fast/dom/timer-throttling-hidden-page-expected.txt:
  • fast/dom/timer-throttling-hidden-page-non-nested-expected.txt: Added.
  • fast/dom/timer-throttling-hidden-page-non-nested.html: Added.
  • fast/dom/timer-throttling-hidden-page.html:
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r212841 r212845  
     12017-02-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Do not aggressively throttle DOM timers until they've reached their max nesting level
     4        https://bugs.webkit.org/show_bug.cgi?id=168700
     5        <rdar://problem/29808005>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add layout test coverage.
     10
     11        * TestExpectations:
     12        * fast/dom/timer-throttling-hidden-page-expected.txt:
     13        * fast/dom/timer-throttling-hidden-page-non-nested-expected.txt: Added.
     14        * fast/dom/timer-throttling-hidden-page-non-nested.html: Added.
     15        * fast/dom/timer-throttling-hidden-page.html:
     16
    1172017-02-22  Antti Koivisto  <antti@apple.com>
    218
  • trunk/LayoutTests/TestExpectations

    r212812 r212845  
    109109# media/W3C/video/networkState/networkState_during_progress.html is flaky
    110110webkit.org/b/76280 media/W3C/video/networkState/networkState_during_progress.html [ Pass Failure ]
    111 
    112 webkit.org/b/118301 fast/dom/timer-throttling-hidden-page.html [ Skip ]
    113111
    114112# This test will run slowly in debug mode, but is plenty fast in release.
  • trunk/LayoutTests/fast/dom/timer-throttling-hidden-page-expected.txt

    r130720 r212845  
    44
    55
    6 PASS timerIntervalWhilePageVisible is within 20 of 100
    7 PASS firstTimerIntervalWhilePageHidden is >= 80
    8 PASS firstTimerIntervalWhilePageHidden <= 1120 is true
    9 PASS timerIntervalWhilePageHidden is within 20 of 1000
    10 PASS timerIntervalWhilePageVisible is within 20 of 100
     6PASS timerIntervalWhilePageVisible is within 20 of 10
     7PASS timerIntervalWhilePageVisible is within 20 of 10
     8PASS timerIntervalWhilePageVisible is within 20 of 10
     9PASS timerIntervalWhilePageVisible is within 20 of 10
     10PASS timerIntervalWhilePageVisible is within 20 of 10
     11PASS timerIntervalWhilePageHidden > (timeoutInterval + tolerance) is true
     12PASS timerIntervalWhilePageVisible is within 20 of 10
    1113PASS successfullyParsed is true
    1214
    1315TEST COMPLETE
    14 This test measures the time taken to fire a 100ms DOM Timer when the page visibility is set to "visible", "hidden" and then back to "visible". Due to hidden page timer throttling, the timer should fire close to 1s when page is hidden. And it should fire close to 100ms, when the page is visible.
     16This test measures the time taken to fire a 10ms DOM Timer when the page visibility is set to "visible", "hidden" and then back to "visible". Due to hidden page timer throttling, the timer should fire close to s when page is hidden. And it should fire close to 10ms, when the page is visible.
  • trunk/LayoutTests/fast/dom/timer-throttling-hidden-page.html

    r155265 r212845  
    1010        var firstTimerWhileHidden = true;
    1111        var isPageVisible = true;
    12         var timeoutInterval = 100;
     12        var timeoutInterval = 10;
    1313        var tolerance = 20;
    14         var timerAlignmentInterval = 1000;
     14        var maxNestingLevel = 5;
    1515
    1616        function testTimer()
    … …  
    1818            var date = new Date();
    1919            var time = date.getTime();
    20             if (!isPageVisible) {
    21                 if (firstTimerWhileHidden) {
    22                     firstTimerIntervalWhilePageHidden = time - previousTime;
    23                     var minValue = timeoutInterval - tolerance;
    24                     shouldBeGreaterThanOrEqual("firstTimerIntervalWhilePageHidden", minValue.toString());
    25                     var maxValue = timeoutInterval + timerAlignmentInterval + tolerance;
    26                     shouldBeTrue("firstTimerIntervalWhilePageHidden <= " + maxValue);
    27                     firstTimerWhileHidden = false;
    28                 } else {
    29                     timerIntervalWhilePageHidden = time - previousTime;
    30                     shouldBeCloseTo("timerIntervalWhilePageHidden", timerAlignmentInterval, tolerance);
    31                 }
     20            if (!isPageVisible && timerCount >= maxNestingLevel) {
     21                timerIntervalWhilePageHidden = time - previousTime;
     22                shouldBeTrue("timerIntervalWhilePageHidden > (timeoutInterval + tolerance)");
    3223            } else {
    3324                timerIntervalWhilePageVisible = time - previousTime;
    … …  
    4132                testRunner.setPageVisibility("hidden");
    4233                isPageVisible = false;
    43             } else if (timerCount == 3) {
     34            } else if (timerCount == maxNestingLevel + 1) {
    4435                testRunner.resetPageVisibility();
    4536                isPageVisible = true;
    46             } else if (timerCount >= 4){
     37            } else if (timerCount > maxNestingLevel + 1){
    4738                finishJSTest();
    4839                return;
    … …  
    6354                timeoutIntervalSpans[i].innerText = timeoutInterval;
    6455
    65             document.getElementById('alignmentInterval').innerText = timerAlignmentInterval / 1000;
    66 
    6756            testRunner.dumpAsText();
    6857            setTimeout(testTimer, timeoutInterval);
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r212617 r212845  
    301301
    302302# testRunner.setPageVisibility is not implemented for iOS
     303webkit.org/b/165799 fast/dom/timer-throttling-hidden-page.html [ Skip ]
     304webkit.org/b/165799 fast/dom/timer-throttling-hidden-page-non-nested.html [ Skip ]
    303305webkit.org/b/165799 fast/events/page-visibility-onvisibilitychange.html [ Skip ]
    304306webkit.org/b/165799 svg/animations/animations-paused-page-non-visible.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r212844 r212845  
     12017-02-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Do not aggressively throttle DOM timers until they've reached their max nesting level
     4        https://bugs.webkit.org/show_bug.cgi?id=168700
     5        <rdar://problem/29808005>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Do not aggressively throttle DOM timers until they've actually areached their max
     10        nesting level (5). This overly aggressive throttling of non-nested timers is what
     11        was causing Google Maps to use 100% CPU in background tabs for several minutes.
     12
     13        Test: fast/dom/timer-throttling-hidden-page-non-nested.html
     14
     15        * dom/Document.cpp:
     16        (WebCore::Document::timerAlignmentInterval):
     17
    1182017-02-22  Eric Carlson  <eric.carlson@apple.com>
    219
  • trunk/Source/WebCore/dom/Document.cpp

    r212629 r212845  
    28482848{
    28492849    auto alignmentInterval = ScriptExecutionContext::timerAlignmentInterval(hasReachedMaxNestingLevel);
     2850    if (!hasReachedMaxNestingLevel)
     2851        return alignmentInterval;
    28502852
    28512853    // Apply Document-level DOMTimer throttling only if timers have reached their maximum nesting level as the Page may still be visible.
    2852     if (m_isTimerThrottlingEnabled && hasReachedMaxNestingLevel)
     2854    if (m_isTimerThrottlingEnabled)
    28532855        alignmentInterval = std::max(alignmentInterval, DOMTimer::hiddenPageAlignmentInterval());
    28542856
Note: See TracChangeset for help on using the changeset viewer.