Bug 1385453 - Make it possible to disable tab warming. r?billm
MozReview-Commit-ID: LTxerOEQyQq
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1548,18 +1548,19 @@ pref("browser.tabs.remote.desktopbehavio
// We leave it here set to false to reset users' defaults and allow
// us to change everybody to true in the future, when desired.
pref("browser.tabs.remote.autostart.1", false);
pref("browser.tabs.remote.autostart.2", true);
#endif
// For speculatively warming up tabs to improve perceived
// performance while using the async tab switcher.
-pref("browser.tabs.remote.maxWarmingTabs", 3);
-pref("browser.tabs.remote.warmingUnloadDelayMs", 2000);
+pref("browser.tabs.remote.warmup.enabled", true);
+pref("browser.tabs.remote.warmup.maxTabs", 3);
+pref("browser.tabs.remote.warmup.unloadDelayMs", 2000);
// For the about:tabcrashed page
pref("browser.tabs.crashReporting.sendReport", true);
pref("browser.tabs.crashReporting.includeURL", false);
pref("browser.tabs.crashReporting.requestEmail", false);
pref("browser.tabs.crashReporting.emailMe", false);
pref("browser.tabs.crashReporting.email", "");
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4184,20 +4184,22 @@
get minimizedOrFullyOccluded() {
return window.windowState == window.STATE_MINIMIZED ||
window.isFullyOccluded;
},
init() {
this.log("START");
+ XPCOMUtils.defineLazyPreferenceGetter(this, "WARMING_ENABLED",
+ "browser.tabs.remote.warmup.enabled", false);
XPCOMUtils.defineLazyPreferenceGetter(this, "MAX_WARMING_TABS",
- "browser.tabs.remote.maxWarmingTabs", 3);
+ "browser.tabs.remote.warmup.maxTabs", 3);
XPCOMUtils.defineLazyPreferenceGetter(this, "WARMING_UNLOAD_DELAY" /* ms */,
- "browser.tabs.remote.warmingUnloadDelayMs", 2000);
+ "browser.tabs.remote.warmup.unloadDelayMs", 2000);
// If we minimized the window before the switcher was activated,
// we might have set the preserveLayers flag for the current
// browser. Let's clear it.
this.tabbrowser.mCurrentBrowser.preserveLayers(false);
window.addEventListener("MozAfterPaint", this);
window.addEventListener("MozLayerTreeReady", this);
@@ -4738,16 +4740,20 @@
},
activateBrowserForPrintPreview(browser) {
let tab = this.tabbrowser.getTabForBrowser(browser);
this.setTabState(tab, this.STATE_LOADING);
},
canWarmTab(tab) {
+ if (!this.WARMING_ENABLED) {
+ return false;
+ }
+
// If the tab is not yet inserted, closing, not remote,
// crashed, already visible, or already requested, warming
// up the tab makes no sense.
if (this.minimizedOrFullyOccluded ||
!tab.linkedPanel ||
tab.closing ||
!tab.linkedBrowser.isRemoteBrowser ||
!tab.linkedBrowser.frameLoader.tabParent) {
@@ -4783,34 +4789,36 @@
},
// Called when the user asks to switch to a given tab.
requestTab(tab) {
if (tab === this.requestedTab) {
return;
}
- let warmingState = "disqualified";
-
- if (this.warmingTabs.has(tab)) {
- let tabState = this.getTabState(tab);
- if (tabState == this.STATE_LOADING) {
- warmingState = "stillLoading";
- } else if (tabState == this.STATE_LOADED) {
- warmingState = "loaded";
+ if (this.WARMING_ENABLED) {
+ let warmingState = "disqualified";
+
+ if (this.warmingTabs.has(tab)) {
+ let tabState = this.getTabState(tab);
+ if (tabState == this.STATE_LOADING) {
+ warmingState = "stillLoading";
+ } else if (tabState == this.STATE_LOADED) {
+ warmingState = "loaded";
+ }
+ } else if (this.canWarmTab(tab)) {
+ warmingState = "notWarmed";
}
- } else if (this.canWarmTab(tab)) {
- warmingState = "notWarmed";
- }
-
- Services.telemetry
- .getHistogramById("FX_TAB_SWITCH_REQUEST_TAB_WARMING_STATE")
- .add(warmingState);
-
- this.unwarmTab(tab);
+
+ Services.telemetry
+ .getHistogramById("FX_TAB_SWITCH_REQUEST_TAB_WARMING_STATE")
+ .add(warmingState);
+
+ this.unwarmTab(tab);
+ }
this._requestingTab = true;
this.logState("requestTab " + this.tinfo(tab));
this.startTabSwitch();
this.requestedTab = tab;
this.suppressDisplayPortAndQueueUnload(this.requestedTab, this.UNLOAD_DELAY);