Title: [197472] trunk/Source/WebCore
Revision
197472
Author
[email protected]
Date
2016-03-02 16:19:05 -0800 (Wed, 02 Mar 2016)

Log Message

Disable timer throttling increases for visually idle / active pages.
https://bugs.webkit.org/show_bug.cgi?id=154935

Reviewed by Chris Dumez.

Currently any page that is visually idle can timer throttle, and all are eligible for throttling
allow throttling to increase.

Instead, still allow any visually idle page to timer throttle, but only allow increasing in those
that are fully hidden & inactive (no page loading or media activity).

* page/Page.cpp:
(WebCore::Page::setTimerThrottlingState):
    - Updated policy per commet above.
(WebCore::Page::setPageActivityState):
(WebCore::Page::setIsVisible):
    - We now may need to updated timer throttling when these change.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (197471 => 197472)


--- trunk/Source/WebCore/ChangeLog	2016-03-03 00:17:12 UTC (rev 197471)
+++ trunk/Source/WebCore/ChangeLog	2016-03-03 00:19:05 UTC (rev 197472)
@@ -1,3 +1,23 @@
+2016-03-02  Gavin Barraclough  <[email protected]>
+
+        Disable timer throttling increases for visually idle / active pages.
+        https://bugs.webkit.org/show_bug.cgi?id=154935
+
+        Reviewed by Chris Dumez.
+
+        Currently any page that is visually idle can timer throttle, and all are eligible for throttling
+        allow throttling to increase.
+
+        Instead, still allow any visually idle page to timer throttle, but only allow increasing in those
+        that are fully hidden & inactive (no page loading or media activity).
+
+        * page/Page.cpp:
+        (WebCore::Page::setTimerThrottlingState):
+            - Updated policy per commet above.
+        (WebCore::Page::setPageActivityState):
+        (WebCore::Page::setIsVisible):
+            - We now may need to updated timer throttling when these change.
+
 2016-03-02  Konstantin Tokarev  <[email protected]>
 
         [cmake] Moved PRE/POST_BUILD_COMMAND to WEBKIT_FRAMEWORK.

Modified: trunk/Source/WebCore/page/Page.cpp (197471 => 197472)


--- trunk/Source/WebCore/page/Page.cpp	2016-03-03 00:17:12 UTC (rev 197471)
+++ trunk/Source/WebCore/page/Page.cpp	2016-03-03 00:19:05 UTC (rev 197472)
@@ -1031,8 +1031,6 @@
 
 void Page::setIsVisuallyIdleInternal(bool isVisuallyIdle)
 {
-    updateTimerThrottlingState();
-    
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (frame->document())
             frame->document()->scriptedAnimationControllerSetThrottled(isVisuallyIdle);
@@ -1185,12 +1183,21 @@
 
 void Page::updateTimerThrottlingState()
 {
-    TimerThrottlingState state = TimerThrottlingState::Disabled;
+    // Timer throttling disabled if page is visually active, or disabled by setting.
+    if (!m_settings->hiddenPageDOMTimerThrottlingEnabled() || !(m_viewState & ViewState::IsVisuallyIdle)) {
+        setTimerThrottlingState(TimerThrottlingState::Disabled);
+        return;
+    }
 
-    if (m_settings->hiddenPageDOMTimerThrottlingEnabled() && m_viewState & ViewState::IsVisuallyIdle)
-        state = m_settings->hiddenPageDOMTimerThrottlingAutoIncreases() ? TimerThrottlingState::EnabledIncreasing : TimerThrottlingState::Enabled;
+    // If the page is visible (but idle), there is any activity (loading, media playing, etc), or per setting,
+    // we allow timer throttling, but not increasing timer throttling.
+    if (!m_settings->hiddenPageDOMTimerThrottlingAutoIncreases() || m_viewState & ViewState::IsVisible || m_pageThrottler.activityState()) {
+        setTimerThrottlingState(TimerThrottlingState::Enabled);
+        return;
+    }
 
-    setTimerThrottlingState(state);
+    // If we get here increasing timer throttling is enabled.
+    setTimerThrottlingState(TimerThrottlingState::EnabledIncreasing);
 }
 
 void Page::setTimerThrottlingState(TimerThrottlingState state)
@@ -1395,6 +1402,9 @@
     if (changed & ViewState::IsVisuallyIdle)
         setIsVisuallyIdleInternal(viewState & ViewState::IsVisuallyIdle);
 
+    if (changed & (ViewState::IsVisible | ViewState::IsVisuallyIdle))
+        updateTimerThrottlingState();
+
     for (auto* observer : m_viewStateChangeObservers)
         observer->viewStateDidChange(oldViewState, m_viewState);
 }
@@ -1402,6 +1412,7 @@
 void Page::setPageActivityState(PageActivityState::Flags activityState)
 {
     chrome().client().setPageActivityState(activityState);
+    updateTimerThrottlingState();
 }
 
 void Page::setIsVisible(bool isVisible)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to