Bug 827976 - Use requestIdleCallback from Timer.jsm instead of from the hidden window. r=mconley
authorFelipe Gomes <felipc@gmail.com>
Mon, 04 Mar 2019 18:53:22 +0000
changeset 520355 1960442645ea613e13d326252b33448b4d49587f
parent 520354 52c87e58dff37922c4da8593f3151566db6cd0b9
child 520356 5f4cebc62cbd61b5062724f78dfb9cfadaf84a3f
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs827976
milestone67.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 827976 - Use requestIdleCallback from Timer.jsm instead of from the hidden window. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D21085
browser/components/sessionstore/SessionSaver.jsm
--- a/browser/components/sessionstore/SessionSaver.jsm
+++ b/browser/components/sessionstore/SessionSaver.jsm
@@ -171,32 +171,30 @@ var SessionSaverInternal = {
 
     // Interval until the next disk operation is allowed.
     let interval = this._isIdle ? this._intervalWhileIdle : this._intervalWhileActive;
     delay = Math.max(this._lastSaveTime + interval - Date.now(), delay, 0);
 
     // Schedule a state save.
     this._wasIdle = this._isIdle;
     this._timeoutID = setTimeout(() => {
-      let hiddenDOMWindow = Services.appShell.hiddenDOMWindow;
-
       // Execute _saveStateAsync when we have enough idle time. Otherwise,
       // another idle request is made to schedule _saveStateAsync again.
       let saveStateAsyncWhenIdle = (deadline) => {
         // When looking at the telemetry data, the time it takes to execute
         // _saveStateAsync is around 5.9ms (median). Therefore,
         // we'll not execute the function when the idle time is less than 5ms.
         if (deadline.timeRemaining() < 5) {
-          this._idleCallbackID = hiddenDOMWindow.requestIdleCallback(saveStateAsyncWhenIdle);
+          this._idleCallbackID = requestIdleCallback(saveStateAsyncWhenIdle);
           return;
         }
         this._saveStateAsync();
       };
 
-      this._idleCallbackID = hiddenDOMWindow.requestIdleCallback(saveStateAsyncWhenIdle);
+      this._idleCallbackID = requestIdleCallback(saveStateAsyncWhenIdle);
     }, delay);
   },
 
   /**
    * Sets the last save time to the current time. This will cause us to wait for
    * at least the configured interval when runDelayed() is called next.
    */
   updateLastSaveTime() {
@@ -204,17 +202,17 @@ var SessionSaverInternal = {
   },
 
   /**
    * Cancels all pending session saves.
    */
   cancel() {
     clearTimeout(this._timeoutID);
     this._timeoutID = null;
-    Services.appShell.hiddenDOMWindow.cancelIdleCallback(this._idleCallbackID);
+    cancelIdleCallback(this._idleCallbackID);
     this._idleCallbackID = null;
   },
 
   /**
    * Observe idle/ active notifications.
    */
   observe(subject, topic, data) {
     switch (topic) {