Bug 827976 - Use requestIdleCallback from Timer.jsm instead of from the hidden window. r=mconley
☠☠ backed out by bf3cbcc82527 ☠ ☠
authorFelipe Gomes <felipc@gmail.com>
Fri, 01 Mar 2019 21:07:13 +0000
changeset 462022 f976c2d4cebb29588222e0c5122c475aae3be509
parent 462021 66cffb171024564fa70e9f8d237c76181cc51514
child 462023 443087a359f9baec6e41e9693adc32ad420c561c
push id35634
push userrmaries@mozilla.com
push dateSat, 02 Mar 2019 09:26:10 +0000
treeherdermozilla-central@4166cae81546 [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) {