Bug 1511095 - Remove SchedulePressure.jsm and the fallback loading throbber in the tabstrip. r=mconley
authorJared Wein <jwein@mozilla.com>
Thu, 29 Nov 2018 22:25:33 +0000
changeset 448864 fc79d3717e40dfef08cfacd4213d8e2f66b84f6a
parent 448863 227e4c46623286b1968954e5bbaae940ad0805c5
child 448865 0ceb5c6cc6b076e9b79f9d5f70ae901f8fd9644e
push id35129
push usernerli@mozilla.com
push dateFri, 30 Nov 2018 09:34:14 +0000
treeherdermozilla-central@c5b713000513 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1511095
milestone65.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 1511095 - Remove SchedulePressure.jsm and the fallback loading throbber in the tabstrip. r=mconley The APNG version is still used by the TabsList which can't support the SVG version of the throbber currently. Differential Revision: https://phabricator.services.mozilla.com/D13461
browser/app/profile/firefox.js
browser/base/content/browser.css
browser/base/content/browser.js
browser/base/content/tabbrowser.css
browser/base/content/tabbrowser.js
browser/base/content/tabbrowser.xml
browser/modules/SchedulePressure.jsm
browser/modules/TabsList.jsm
browser/modules/moz.build
browser/themes/shared/tabs.inc.css
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -207,19 +207,16 @@ pref("browser.fixup.domainwhitelist.loca
 pref("general.smoothScroll", true);
 #ifdef UNIX_BUT_NOT_MAC
 pref("general.autoScroll", false);
 #else
 pref("general.autoScroll", true);
 #endif
 
 pref("browser.stopReloadAnimation.enabled", true);
-pref("browser.schedulePressure.enabled", true);
-pref("browser.schedulePressure.defaultCount", 3);
-pref("browser.schedulePressure.timeoutMs", 300);
 
 // UI density of the browser chrome. This mostly affects toolbarbutton
 // and urlbar spacing. The possible values are 0=normal, 1=compact, 2=touch.
 pref("browser.uidensity", 0);
 // Whether Firefox will automatically override the uidensity to "touch"
 // while the user is in a touch environment (such as Windows tablet mode).
 pref("browser.touchmode.auto", true);
 
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -194,25 +194,23 @@ panelview[mainview] > .panel-header {
 .tab-icon-image:not([fadein]),
 .tab-close-button:not([fadein]),
 .tabbrowser-tab:not([fadein])::after,
 .tab-background:not([fadein]) {
   visibility: hidden;
 }
 
 .tab-label:not([fadein]),
-.tab-throbber:not([fadein]),
-.tab-throbber-fallback:not([fadein]) {
+.tab-throbber:not([fadein]) {
   display: none;
 }
 
 %ifdef NIGHTLY_BUILD
 @supports -moz-bool-pref("browser.tabs.hideThrobber") {
-  .tab-throbber,
-  .tab-throbber-fallback {
+  .tab-throbber {
     display: none !important;
   }
 }
 %endif
 
 #tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab[pinned] {
   position: fixed !important;
   display: block; /* position:fixed already does this (bug 579776), but let's be explicit */
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -47,17 +47,16 @@ XPCOMUtils.defineLazyModuleGetters(this,
   ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
   PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
   ReaderMode: "resource://gre/modules/ReaderMode.jsm",
   ReaderParent: "resource:///modules/ReaderParent.jsm",
   SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
   Sanitizer: "resource:///modules/Sanitizer.jsm",
   SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
   SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
-  SchedulePressure: "resource:///modules/SchedulePressure.jsm",
   ShortcutUtils: "resource://gre/modules/ShortcutUtils.jsm",
   SimpleServiceDiscovery: "resource://gre/modules/SimpleServiceDiscovery.jsm",
   SiteDataManager: "resource:///modules/SiteDataManager.jsm",
   SitePermissions: "resource:///modules/SitePermissions.jsm",
   TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
   TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
   Translation: "resource:///modules/translation/Translation.jsm",
   UITour: "resource:///modules/UITour.jsm",
--- a/browser/base/content/tabbrowser.css
+++ b/browser/base/content/tabbrowser.css
@@ -10,17 +10,16 @@
 #tabbrowser-tabs[closebuttons="activetab"] > .tabbrowser-tab > .tab-stack > .tab-content > .tab-close-button:not([selected="true"]),
 .tab-icon-pending:not([pendingicon]),
 .tab-icon-pending[busy],
 .tab-icon-pending[pinned],
 .tab-icon-image:not([src]):not([pinned]):not([crashed])[selected],
 .tab-icon-image:not([src]):not([pinned]):not([crashed]):not([sharing]),
 .tab-icon-image[busy],
 .tab-throbber:not([busy]),
-.tab-throbber-fallback:not([busy]),
 .tab-icon-sound:not([soundplaying]):not([muted]):not([activemedia-blocked]),
 .tab-icon-sound[pinned],
 .tab-sharing-icon-overlay,
 .tab-icon-overlay {
   display: none;
 }
 
 .tab-sharing-icon-overlay[sharing]:not([selected]),
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -57,18 +57,16 @@ window._gBrowser = {
 
     // To correctly handle keypresses for potential FindAsYouType, while
     // the tab's find bar is not yet initialized.
     messageManager.addMessageListener("Findbar:Keypress", this);
     this._setFindbarData();
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "animationsEnabled",
       "toolkit.cosmeticAnimations.enabled");
-    XPCOMUtils.defineLazyPreferenceGetter(this, "schedulePressureDefaultCount",
-      "browser.schedulePressure.defaultCount");
 
     this._setupEventListeners();
   },
 
   ownerGlobal: window,
 
   ownerDocument: document,
 
@@ -4986,60 +4984,30 @@ class TabProgressListener {
       }
 
       if (this._shouldShowProgress(aRequest)) {
         if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) &&
             aWebProgress && aWebProgress.isTopLevel) {
           this.mTab.setAttribute("busy", "true");
           gBrowser._tabAttrModified(this.mTab, ["busy"]);
           this.mTab._notselectedsinceload = !this.mTab.selected;
-          SchedulePressure.startMonitoring(window, {
-            highPressureFn() {
-              // Only switch back to the SVG loading indicator after getting
-              // three consecutive low pressure callbacks. Used to prevent
-              // switching quickly between the SVG and APNG loading indicators.
-              gBrowser.tabContainer._schedulePressureCount = gBrowser.schedulePressureDefaultCount;
-              gBrowser.tabContainer.setAttribute("schedulepressure", "true");
-            },
-            lowPressureFn() {
-              if (!gBrowser.tabContainer._schedulePressureCount ||
-                --gBrowser.tabContainer._schedulePressureCount <= 0) {
-                gBrowser.tabContainer.removeAttribute("schedulepressure");
-              }
-
-              // If tabs are closed while they are loading we need to
-              // stop monitoring schedule pressure. We don't stop monitoring
-              // during high pressure times because we want to eventually
-              // return to the SVG tab loading animations.
-              let continueMonitoring = true;
-              if (!document.querySelector(".tabbrowser-tab[busy]")) {
-                SchedulePressure.stopMonitoring(window);
-                continueMonitoring = false;
-              }
-              return { continueMonitoring };
-            },
-          });
           gBrowser.syncThrobberAnimations(this.mTab);
         }
 
         if (this.mTab.selected) {
           gBrowser._isBusy = true;
         }
       }
     } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
                aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
 
       let modifiedAttrs = [];
       if (this.mTab.hasAttribute("busy")) {
         this.mTab.removeAttribute("busy");
         modifiedAttrs.push("busy");
-        if (!document.querySelector(".tabbrowser-tab[busy]")) {
-          SchedulePressure.stopMonitoring(window);
-          gBrowser.tabContainer.removeAttribute("schedulepressure");
-        }
 
         // Only animate the "burst" indicating the page has loaded if
         // the top-level page is the one that finished loading.
         if (aWebProgress.isTopLevel && !aWebProgress.isLoadingDocument &&
             Components.isSuccessCode(aStatus) &&
             !gBrowser.tabAnimationsInProgress &&
             Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled")) {
           if (this.mTab._notselectedsinceload) {
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1904,20 +1904,16 @@
                   anonid="tab-loading-burst"
                   class="tab-loading-burst"/>
         <xul:hbox xbl:inherits="pinned,selected=visuallyselected,titlechanged,attention"
                   class="tab-content" align="center">
           <xul:hbox xbl:inherits="fadein,pinned,busy,progress,selected=visuallyselected"
                     anonid="tab-throbber"
                     class="tab-throbber"
                     layer="true"/>
-          <xul:image xbl:inherits="fadein,pinned,busy,progress,selected=visuallyselected"
-                     class="tab-throbber-fallback"
-                     role="presentation"
-                     layer="true"/>
           <xul:hbox xbl:inherits="fadein,pinned,busy,progress,selected=visuallyselected,pendingicon"
                     anonid="tab-icon-pending"
                     class="tab-icon-pending"/>
           <xul:image xbl:inherits="src=image,triggeringprincipal=iconloadingprincipal,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
                      anonid="tab-icon-image"
                      class="tab-icon-image"
                      validate="never"
                      role="presentation"/>
deleted file mode 100644
--- a/browser/modules/SchedulePressure.jsm
+++ /dev/null
@@ -1,124 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var EXPORTED_SYMBOLS = ["SchedulePressure"];
-
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyPreferenceGetter(this, "SCHEDULE_PRESSURE_ENABLED",
-  "browser.schedulePressure.enabled", true);
-XPCOMUtils.defineLazyPreferenceGetter(this, "TIMEOUT_AMOUNT",
-  "browser.schedulePressure.timeoutMs", 300);
-
-/**
- * The SchedulePressure object provides the ability to alter
- * the behavior of a program based on the idle activity of the
- * host machine.
- */
-var SchedulePressure = {
-  _idleCallbackWeakMap: new WeakMap(),
-  _setTimeoutWeakMap: new WeakMap(),
-  _telemetryCallbackWeakMap: new WeakMap(),
-
-  _createTimeoutFn(window, callbackFn) {
-    return () => {
-      if (window.closed) {
-        TelemetryStopwatch.cancel("FX_SCHEDULE_PRESSURE_IDLE_SAMPLE_MS", window);
-        this._telemetryCallbackWeakMap.delete(window);
-        return;
-      }
-      let nextCallbackId = window.requestIdleCallback(callbackFn, {timeout: TIMEOUT_AMOUNT});
-      this._idleCallbackWeakMap.set(window, nextCallbackId);
-
-      // Don't create another timeout-less idle callback if the first
-      // one hasn't completed yet.
-      if (!this._telemetryCallbackWeakMap.has(window) &&
-          TelemetryStopwatch.start("FX_SCHEDULE_PRESSURE_IDLE_SAMPLE_MS", window)) {
-        let telemetryCallbackId = window.requestIdleCallback(() => {
-          TelemetryStopwatch.finish("FX_SCHEDULE_PRESSURE_IDLE_SAMPLE_MS", window);
-          this._telemetryCallbackWeakMap.delete(window);
-        });
-        this._telemetryCallbackWeakMap.set(window, telemetryCallbackId);
-      }
-    };
-  },
-
-  /**
-   * Starts an interval timeout that periodically waits for
-   * an idle callback. If the idle callback fails to get called
-   * within the timeout specified by TIMEOUT_AMOUNT, the
-   * highPressureFn callback will get called. Otherwise the
-   * lowPressureFn callback will get called.
-   *
-   * @param  window
-   *         The DOM window of the requestee.
-   * @param  options
-   *           highPressureFn
-   *           A function that will be called when the idle callback
-   *           fails to be called within the time specified by TIMEOUT_AMOUNT.
-   *           Returning an object with property of `continueMonitoring` set
-   *           to `false` will prevent further monitoring.
-   *           lowPressureFn
-   *           A function that will be called when the idle callback
-   *           gets called within the time specified by TIMEOUT_AMOUNT.
-   *           Returning an object with property of `continueMonitoring` set
-   *           to `false` will prevent further monitoring.
-   */
-  startMonitoring(window, {highPressureFn, lowPressureFn}) {
-    if (!SCHEDULE_PRESSURE_ENABLED ||
-        this._setTimeoutWeakMap.has(window) ||
-        this._idleCallbackWeakMap.has(window)) {
-      return;
-    }
-
-    let callbackFn = idleDeadline => {
-      if (window.closed) {
-        return;
-      }
-
-      let result;
-      if (idleDeadline.didTimeout) {
-        try {
-          result = highPressureFn();
-        } catch (ex) {}
-      } else {
-        try {
-          result = lowPressureFn();
-        } catch (ex) {}
-      }
-
-      if (result && !result.continueMonitoring) {
-        return;
-      }
-
-      this._setTimeoutWeakMap.set(window,
-        window.setTimeout(this._createTimeoutFn(window, callbackFn), TIMEOUT_AMOUNT));
-    };
-
-    this._setTimeoutWeakMap.set(window,
-      window.setTimeout(this._createTimeoutFn(window, callbackFn), TIMEOUT_AMOUNT));
-  },
-
-  /**
-   * Stops the interval timeout that periodically waits for
-   * an idle callback.
-   *
-   * @param  window
-   *         The DOM window of the requestee.
-   */
-  stopMonitoring(window) {
-    function removeFromMapAndCancelTimeout(map, cancelFn) {
-      if (map.has(window)) {
-        cancelFn(map.get(window));
-        map.delete(window);
-      }
-    }
-
-    TelemetryStopwatch.cancel("FX_SCHEDULE_PRESSURE_IDLE_SAMPLE_MS", window);
-    removeFromMapAndCancelTimeout(this._setTimeoutWeakMap, window.clearTimeout);
-    removeFromMapAndCancelTimeout(this._idleCallbackWeakMap, window.cancelIdleCallback);
-    removeFromMapAndCancelTimeout(this._telemetryCallbackWeakMap, window.cancelIdleCallback);
-  },
-};
--- a/browser/modules/TabsList.jsm
+++ b/browser/modules/TabsList.jsm
@@ -267,22 +267,22 @@ class TabsPanel extends TabsListBase {
     });
   }
 
   _setImageAttributes(row, tab) {
     let button = row.firstElementChild;
     let image = this.doc.getAnonymousElementByAttribute(
       button, "class", "toolbarbutton-icon") ||
       this.doc.getAnonymousElementByAttribute(
-        button, "class", "toolbarbutton-icon tab-throbber-fallback");
+        button, "class", "toolbarbutton-icon tab-throbber-tabslist");
 
     if (image) {
       let busy = tab.getAttribute("busy");
       let progress = tab.getAttribute("progress");
       setAttributes(image, {busy, progress});
       if (busy) {
-        image.classList.add("tab-throbber-fallback");
+        image.classList.add("tab-throbber-tabslist");
       } else {
-        image.classList.remove("tab-throbber-fallback");
+        image.classList.remove("tab-throbber-tabslist");
       }
     }
   }
 }
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -144,17 +144,16 @@ EXTRA_JS_MODULES += [
     'OpenInTabsUtils.jsm',
     'PageActions.jsm',
     'PermissionUI.jsm',
     'PingCentre.jsm',
     'ProcessHangMonitor.jsm',
     'ReaderParent.jsm',
     'RemotePrompt.jsm',
     'Sanitizer.jsm',
-    'SchedulePressure.jsm',
     'SelectionChangedMenulist.jsm',
     'SiteDataManager.jsm',
     'SitePermissions.jsm',
     'TabsList.jsm',
     'ThemeVariableMap.jsm',
     'TransientPrefs.jsm',
     'webrtcUI.jsm',
     'ZoomUI.jsm',
--- a/browser/themes/shared/tabs.inc.css
+++ b/browser/themes/shared/tabs.inc.css
@@ -144,36 +144,36 @@
   }
   100% {
     opacity: 0;
     transform: scale(40);
   }
 }
 
 .tab-throbber,
-.tab-throbber-fallback,
+.tab-throbber-tabslist,
 .tab-icon-pending,
 .tab-icon-image,
 .tab-sharing-icon-overlay,
 .tab-icon-sound,
 .tab-close-button {
   margin-top: 1px;
 }
 
 .tab-throbber,
-.tab-throbber-fallback,
+.tab-throbber-tabslist,
 .tab-icon-pending,
 .tab-icon-image,
 .tab-sharing-icon-overlay {
   height: 16px;
   width: 16px;
 }
 
 .tab-throbber:not([pinned]),
-.tab-throbber-fallback:not([pinned]),
+.tab-throbber-tabslist:not([pinned]),
 .tab-sharing-icon-overlay:not([pinned]),
 .tab-icon-pending:not([pinned]),
 .tab-icon-image:not([pinned]) {
   margin-inline-end: 6px;
 }
 
 :root[sessionrestored] .tab-throbber[busy] {
   position: relative;
@@ -236,21 +236,16 @@
 }
 
 #TabsToolbar[brighttext] .tab-throbber[progress]:not([selected=true])::before {
   /* Don't change the --tab-loading-fill variable because this should only affect
      tabs that are not visually selected. */
   fill: #84c1ff;
 }
 
-#tabbrowser-tabs[schedulepressure] .tab-throbber,
-#tabbrowser-tabs:not([schedulepressure]) .tab-throbber-fallback {
-  display: none;
-}
-
 .tab-icon-image {
   list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.svg");
   -moz-context-properties: fill;
   fill: currentColor;
 }
 
 .tab-icon-image[sharing]:not([selected]),
 .tab-sharing-icon-overlay {
@@ -334,38 +329,38 @@
 .tab-icon-overlay[muted]:not([crashed]) {
   list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-muted-small.svg");
 }
 
 .tab-icon-overlay[activemedia-blocked]:not([crashed]) {
   list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-blocked-small.svg");
 }
 
-.tab-throbber-fallback[busy] {
+.tab-throbber-tabslist[busy] {
   list-style-image: url("chrome://browser/skin/tabbrowser/tab-connecting.png");
 }
 
-.tab-throbber-fallback[progress] {
+.tab-throbber-tabslist[progress] {
   list-style-image: url("chrome://browser/skin/tabbrowser/tab-loading.png");
 }
 
-#TabsToolbar[brighttext] .tab-throbber-fallback[progress]:not([selected=true]) {
+#TabsToolbar[brighttext] .tab-throbber-tabslist[progress]:not([selected=true]) {
   list-style-image: url("chrome://browser/skin/tabbrowser/tab-loading-inverted.png");
 }
 
 @media (min-resolution: 1.1dppx) {
-  .tab-throbber-fallback[busy] {
+  .tab-throbber-tabslist[busy] {
     list-style-image: url("chrome://browser/skin/tabbrowser/tab-connecting@2x.png");
   }
 
-  .tab-throbber-fallback[progress] {
+  .tab-throbber-tabslist[progress] {
     list-style-image: url("chrome://browser/skin/tabbrowser/tab-loading@2x.png");
   }
 
-  #TabsToolbar[brighttext] .tab-throbber-fallback[progress]:not([selected=true]) {
+  #TabsToolbar[brighttext] .tab-throbber-tabslist[progress]:not([selected=true]) {
     list-style-image: url("chrome://browser/skin/tabbrowser/tab-loading-inverted@2x.png");
   }
 }
 
 .tab-label {
   margin-inline-end: 0;
   margin-inline-start: 0;
   /* Maintain consistent alignment in case of font fallback for non-Latin characters. */
@@ -765,17 +760,17 @@
 }
 
 .all-tabs-item:hover > .all-tabs-button,
 .all-tabs-item:hover > .all-tabs-secondary-button {
   /* Since the background is set on the item, don't set it on the children. */
   background-color: transparent !important;
 }
 
-.all-tabs-item > .all-tabs-button > .tab-throbber-fallback {
+.tab-throbber-tabslist {
   display: block;
   margin-inline-end: 0;
 }
 
 .all-tabs-item[selected] {
   font-weight: bold;
   box-shadow: inset 4px 0 var(--blue-40);
 }