Bug 1176019 - Don't let cache interfere with tab warming r?mconley
While working to reproduce the stale content bug with tab warming
I realized that my work here had inadvertently clobbered tab
warming by immediately calling the tab unload code. This wasn't
necessary, and I didn't need to put the cached tab deactivation
code in the unload method, it just seemed initially convenient.
This should make more sense overall.
MozReview-Commit-ID: 9v9dYZTa1Dv
--- a/browser/modules/AsyncTabSwitcher.jsm
+++ b/browser/modules/AsyncTabSwitcher.jsm
@@ -617,20 +617,22 @@ class AsyncTabSwitcher {
// handlers, which might cause finish() to already have been called.
// Check for that before calling finish() again.
if (!this.tabbrowser._switcher) {
return;
}
this.maybeFinishTabSwitch();
- if (numWarming > gTabWarmingMax || numBackgroundCached > 0) {
- if (numWarming > gTabWarmingMax) {
- this.logState("Hit tabWarmingMax");
- }
+ if (numBackgroundCached > 0) {
+ this.deactivateCachedBackgroundTabs();
+ }
+
+ if (numWarming > gTabWarmingMax) {
+ this.logState("Hit tabWarmingMax");
if (this.unloadTimer) {
this.clearTimer(this.unloadTimer);
}
this.unloadNonRequiredTabs();
}
if (numPending == 0) {
this.finish();
@@ -645,32 +647,34 @@ class AsyncTabSwitcher {
this.preActions();
this.unloadTimer = null;
this.unloadNonRequiredTabs();
this.postActions();
}
+ deactivateCachedBackgroundTabs() {
+ for (let tab of this.tabLayerCache) {
+ if (tab !== this.requestedTab) {
+ let browser = tab.linkedBrowser;
+ browser.preserveLayers(true);
+ browser.docShellIsActive = false;
+ }
+ }
+ }
+
// If there are any non-visible and non-requested tabs in
// STATE_LOADED, sets them to STATE_UNLOADING. Also queues
// up the unloadTimer to run onUnloadTimeout if there are still
// tabs in the process of unloading.
unloadNonRequiredTabs() {
this.warmingTabs = new WeakSet();
let numPending = 0;
- for (let tab of this.tabLayerCache) {
- if (tab !== this.requestedTab) {
- let browser = tab.linkedBrowser;
- browser.preserveLayers(true);
- browser.docShellIsActive = false;
- }
- }
-
// Unload any tabs that can be unloaded.
for (let [tab, state] of this.tabState) {
if (this.tabbrowser._printPreviewBrowsers.has(tab.linkedBrowser)) {
continue;
}
let isInLayerCache = this.tabLayerCache.includes(tab);