REGRESSION(r185012): chat frame in Gmail now says "Something's not right"
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2015 19:47:49 +0000 (19:47 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2015 19:47:49 +0000 (19:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146025
<rdar://problem/21391412>

Reviewed by Darin Adler.

Only throttle timers in non-visible iframes once they've reached the
max nesting level to avoid throttling critical one-shot timers. This is
consistent with the default DOMTimer throttling behavior that is
defined in the specification.

Power-wise, we are mostly interested in DOMTimers that fire frequently
and cause high CPU usage over an extended period of time anyway.

* dom/Document.cpp:
(WebCore::Document::setTimerThrottlingEnabled):
(WebCore::Document::timerAlignmentInterval):
* dom/Document.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::timerAlignmentInterval):
* dom/ScriptExecutionContext.h:
* page/DOMTimer.cpp:
(WebCore::DOMTimer::alignedFireTime):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185602 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/page/DOMTimer.cpp

index ca15aa3..9e89039 100644 (file)
@@ -1,3 +1,29 @@
+2015-06-16  Chris Dumez  <cdumez@apple.com>
+
+        REGRESSION(r185012): chat frame in Gmail now says "Something's not right"
+        https://bugs.webkit.org/show_bug.cgi?id=146025
+        <rdar://problem/21391412>
+
+        Reviewed by Darin Adler.
+
+        Only throttle timers in non-visible iframes once they've reached the
+        max nesting level to avoid throttling critical one-shot timers. This is
+        consistent with the default DOMTimer throttling behavior that is
+        defined in the specification.
+
+        Power-wise, we are mostly interested in DOMTimers that fire frequently
+        and cause high CPU usage over an extended period of time anyway.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setTimerThrottlingEnabled):
+        (WebCore::Document::timerAlignmentInterval):
+        * dom/Document.h:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::timerAlignmentInterval):
+        * dom/ScriptExecutionContext.h:
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::alignedFireTime):
+
 2015-06-16  sylvain-galineau  <galineau@adobe.com>
 
         Incorrect order of arguments in initial-letter property
index ca648f2..f55f9b1 100644 (file)
@@ -2760,22 +2760,19 @@ void Document::setTimerThrottlingEnabled(bool shouldThrottle)
     if (m_isTimerThrottlingEnabled == shouldThrottle)
         return;
 
-    double previousInterval = timerAlignmentInterval();
-
     m_isTimerThrottlingEnabled = shouldThrottle;
-
-    if (previousInterval != timerAlignmentInterval())
-        didChangeTimerAlignmentInterval();
+    didChangeTimerAlignmentInterval();
 }
 
-double Document::timerAlignmentInterval() const
+double Document::timerAlignmentInterval(bool hasReachedMaxNestingLevel) const
 {
-    if (m_isTimerThrottlingEnabled)
+    // Apply Document-level DOMTimer throttling only if timers have reached their maximum nesting level as the Page may still be visible.
+    if (m_isTimerThrottlingEnabled && hasReachedMaxNestingLevel)
         return DOMTimer::hiddenPageAlignmentInterval();
 
     Page* page = this->page();
     if (!page)
-        return ScriptExecutionContext::timerAlignmentInterval();
+        return ScriptExecutionContext::timerAlignmentInterval(hasReachedMaxNestingLevel);
     return page->settings().domTimerAlignmentInterval();
 }
 
index baa2c4f..0db6143 100644 (file)
@@ -1301,7 +1301,7 @@ private:
 
     virtual double minimumTimerInterval() const override final;
 
-    virtual double timerAlignmentInterval() const override final;
+    virtual double timerAlignmentInterval(bool hasReachedMaxNestingLevel) const override final;
 
     void updateTitle(const StringWithDirection&);
     void updateFocusAppearanceTimerFired();
index ed118b8..42f5e79 100644 (file)
@@ -449,7 +449,7 @@ void ScriptExecutionContext::didChangeTimerAlignmentInterval()
         timer->didChangeAlignmentInterval();
 }
 
-double ScriptExecutionContext::timerAlignmentInterval() const
+double ScriptExecutionContext::timerAlignmentInterval(bool) const
 {
     return DOMTimer::defaultAlignmentInterval();
 }
index 1d1e18b..0faa069 100644 (file)
@@ -173,7 +173,7 @@ public:
     virtual double minimumTimerInterval() const;
 
     void didChangeTimerAlignmentInterval();
-    virtual double timerAlignmentInterval() const;
+    virtual double timerAlignmentInterval(bool hasReachedMaxNestingLevel) const;
 
     virtual EventQueue& eventQueue() const = 0;
 
index 2980ea2..585aa72 100644 (file)
@@ -428,7 +428,7 @@ double DOMTimer::intervalClampedToMinimum() const
 
 double DOMTimer::alignedFireTime(double fireTime) const
 {
-    if (double alignmentInterval = scriptExecutionContext()->timerAlignmentInterval())
+    if (double alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel))
         return ceil(fireTime / alignmentInterval) * alignmentInterval;
 
     return fireTime;