Bug 1546098 - Ensure that nsRefreshDriver is always stopped when not needed. r=emilio
authorKenny Levinsen <kl@kl.wtf>
Mon, 22 Apr 2019 15:40:46 +0000
changeset 470359 4b7f613b9372e582bb175a0ed3b8843921ef2817
parent 470358 49c94645be164f0004412b60db6f8d464b39d317
child 470360 f6a2f11fd0b7bd380aea5553407c4ad19d7bf8b9
push id35903
push useropoprus@mozilla.com
push dateMon, 22 Apr 2019 21:46:44 +0000
treeherdermozilla-central@a11bd690638f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1546098
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546098 - Ensure that nsRefreshDriver is always stopped when not needed. r=emilio nsRefreshDrivers belonging to fully-loaded documents in content processes now correctly stop their timer when no observers are present. Differential Revision: https://phabricator.services.mozilla.com/D28339
layout/base/nsRefreshDriver.cpp
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1811,30 +1811,32 @@ void nsRefreshDriver::Tick(VsyncId aId, 
     // We don't want to stop the timer when observers are initially
     // removed, because sometimes observers can be added and removed
     // often depending on what other things are going on and in that
     // situation we don't want to thrash our timer.  So instead we
     // wait until we get a Notify() call when we have no observers
     // before stopping the timer.
     // On top level content pages keep the timer running initially so that we
     // paint the page soon enough.
-    if (!XRE_IsContentProcess() || !presShell || mTestControllingRefreshes ||
-        !mPresContext->Document()->IsTopLevelContentDocument() || mThrottled ||
-        gfxPlatform::IsInLayoutAsapMode()) {
-      StopTimer();
-    } else if (mPresContext->Document()->GetReadyStateEnum() <
-                   Document::READYSTATE_COMPLETE &&
-               !mPresContext->HadContentfulPaint()) {
+    if (presShell && !mThrottled && !mTestControllingRefreshes &&
+        XRE_IsContentProcess() &&
+        mPresContext->Document()->IsTopLevelContentDocument() &&
+        !gfxPlatform::IsInLayoutAsapMode() &&
+        !mPresContext->HadContentfulPaint() &&
+        mPresContext->Document()->GetReadyStateEnum() <
+            Document::READYSTATE_COMPLETE) {
       if (mInitialTimerRunningLimit.IsNull()) {
         mInitialTimerRunningLimit =
             TimeStamp::Now() + TimeDuration::FromSeconds(4.0f);
         // Don't let the timer to run forever, so limit to 4s for now.
       } else if (mInitialTimerRunningLimit < TimeStamp::Now()) {
         StopTimer();
       }
+    } else {
+      StopTimer();
     }
     return;
   }
 
   mResizeSuppressed = false;
 
   AutoRestore<bool> restoreInRefresh(mInRefresh);
   mInRefresh = true;