Backed out changeset ba1524e32b04 (bug 1373055) for causing a frequency uptick of bug 1430466

This commit is contained in:
Andreea Pavel 2018-02-25 15:09:08 +02:00
Родитель 1aac7df383
Коммит b469db5c90
5 изменённых файлов: 54 добавлений и 29 удалений

Просмотреть файл

@ -4490,7 +4490,6 @@
window.addEventListener("MozAfterPaint", this);
window.addEventListener("MozLayerTreeReady", this);
window.addEventListener("MozLayerTreeCleared", this);
window.addEventListener("TabBrowserDiscarded", this);
window.addEventListener("TabRemotenessChange", this);
window.addEventListener("sizemodechange", this);
window.addEventListener("occlusionstatechange", this);
@ -4535,7 +4534,6 @@
window.removeEventListener("MozAfterPaint", this);
window.removeEventListener("MozLayerTreeReady", this);
window.removeEventListener("MozLayerTreeCleared", this);
window.removeEventListener("TabBrowserDiscarded", this);
window.removeEventListener("TabRemotenessChange", this);
window.removeEventListener("sizemodechange", this);
window.removeEventListener("occlusionstatechange", this);
@ -4758,26 +4756,26 @@
this.assert(this.tabbrowser._switcher === this);
for (let [tab, ] of this.tabState) {
if (!tab.linkedPanel) {
if (!tab.linkedBrowser) {
this.tabState.delete(tab);
this.unwarmTab(tab);
}
}
if (this.lastVisibleTab && !this.lastVisibleTab.linkedPanel) {
if (this.lastVisibleTab && !this.lastVisibleTab.linkedBrowser) {
this.lastVisibleTab = null;
}
if (this.lastPrimaryTab && !this.lastPrimaryTab.linkedPanel) {
if (this.lastPrimaryTab && !this.lastPrimaryTab.linkedBrowser) {
this.lastPrimaryTab = null;
}
if (this.blankTab && !this.blankTab.linkedPanel) {
if (this.blankTab && !this.blankTab.linkedBrowser) {
this.blankTab = null;
}
if (this.spinnerTab && !this.spinnerTab.linkedPanel) {
if (this.spinnerTab && !this.spinnerTab.linkedBrowser) {
this.spinnerHidden();
this.spinnerTab = null;
}
if (this.loadingTab && !this.loadingTab.linkedPanel) {
if (this.loadingTab && !this.loadingTab.linkedBrowser) {
this.loadingTab = null;
this.clearTimer(this.loadTimer);
this.loadTimer = null;
@ -4979,12 +4977,6 @@
}
},
// Called when a tab is discarded
onTabDiscarded(tab) {
this.logState(`onTabDiscarded(${tab._tPos})`);
this.setTabStateNoAction(tab, this.STATE_UNLOADED);
},
// Called when a tab has been removed, and the browser node is
// about to be removed from the DOM.
onTabRemoved(tab) {
@ -5221,8 +5213,6 @@
this.onLayersCleared(event.originalTarget);
} else if (event.type == "TabRemotenessChange") {
this.onRemotenessChange(event.target);
} else if (event.type == "TabBrowserDiscarded") {
this.onTabDiscarded(event.target);
} else if (event.type == "sizemodechange" ||
event.type == "occlusionstatechange") {
this.onSizeModeOrOcclusionStateChange();
@ -6240,7 +6230,8 @@
if (this.selectedBrowser == browser) {
TabCrashHandler.onSelectedBrowserCrash(browser);
} else {
this.discardBrowser(browser);
this.updateBrowserRemoteness(browser, false);
SessionStore.reviveCrashedTab(tab);
}
tab.removeAttribute("soundplaying");

Просмотреть файл

@ -1901,12 +1901,8 @@ var SessionStoreInternal = {
// Only restore if browser has been lazy.
if (aTab.__SS_lazyData && !browser.__SS_restoreState && TabStateCache.get(browser)) {
if (TabCrashHandler.willShowCrashedTab(browser)) {
this.enterCrashedState(browser);
} else {
let tabState = TabState.clone(aTab);
this.restoreTab(aTab, tabState);
}
let tabState = TabState.clone(aTab);
this.restoreTab(aTab, tabState);
}
// The browser has been inserted now, so lazy data is no longer relevant.
@ -2122,7 +2118,20 @@ var SessionStoreInternal = {
if (browser.__SS_restoreState &&
browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
// If __SS_restoreState is still on the browser and it is
// TAB_STATE_NEEDS_RESTORE, then then we haven't restored
// this tab yet.
//
// It's possible that this tab was recently revived, and that
// we've deferred showing the tab crashed page for it (if the
// tab crashed in the background). If so, we need to re-enter
// the crashed state, since we'll be showing the tab crashed
// page.
if (TabCrashHandler.willShowCrashedTab(browser)) {
this.enterCrashedState(browser);
} else {
this.restoreTabContent(tab);
}
}
}
},
@ -2881,7 +2890,19 @@ var SessionStoreInternal = {
return;
}
// Sanity check - the browser to be revived should not be remote
// at this point.
if (browser.isRemoteBrowser) {
throw new Error("SessionStore.reviveCrashedTab: " +
"Somehow a crashed browser is still remote.");
}
// We put the browser at about:blank in case the user is
// restoring tabs on demand. This way, the user won't see
// a flash of the about:tabcrashed page after selecting
// the revived tab.
aTab.removeAttribute("crashed");
browser.loadURI("about:blank", null, null);
let data = TabState.collect(aTab);
this.restoreTab(aTab, data, {

Просмотреть файл

@ -81,13 +81,22 @@ async function crashBackgroundTabs(tabs) {
Assert.ok(tab.linkedBrowser.isRemoteBrowser, "tab is remote");
}
let remotenessChangePromises = tabs.map((t) => {
return BrowserTestUtils.waitForEvent(t, "TabRemotenessChange");
});
let tabsRevived = tabs.map((t) => {
return promiseTabRestoring(t);
});
await BrowserTestUtils.crashBrowser(tabs[0].linkedBrowser, false);
await Promise.all(remotenessChangePromises);
await Promise.all(tabsRevived);
// Both background tabs should now be in the pending restore
// state.
for (let tab of tabs) {
Assert.ok(!tab.linkedPanel, "The tab should be initially discarded.");
Assert.ok(tab.linkedBrowser.isRemoteBrowser, "tab is still remote");
Assert.ok(!tab.linkedBrowser.isRemoteBrowser, "tab is not remote");
Assert.ok(!tab.linkedBrowser.hasAttribute("crashed"), "tab is not crashed");
Assert.ok(tab.hasAttribute("pending"), "tab is pending");
}
@ -117,9 +126,9 @@ add_task(async function test_background_crash_simple() {
// Selecting the first tab should now send it to the tab crashed page.
let tabCrashedPagePromise =
BrowserTestUtils.waitForEvent(window,
"AboutTabCrashedReady",
false, null, true);
BrowserTestUtils.waitForContentEvent(tab1.linkedBrowser,
"AboutTabCrashedReady",
false, null, true);
await BrowserTestUtils.switchTab(gBrowser, tab1);
await tabCrashedPagePromise;

Просмотреть файл

@ -32,11 +32,15 @@ add_task(async function test_revive_bg_tabs_on_demand() {
await TabStateFlusher.flush(browser2);
// Now crash the selected tab
let windowReady = BrowserTestUtils.waitForEvent(window, "SSWindowStateReady");
await BrowserTestUtils.crashBrowser(browser1);
ok(newTab1.hasAttribute("crashed"), "Selected tab should be crashed");
ok(!newTab2.hasAttribute("crashed"), "Background tab should not be crashed");
// Wait until we've had a chance to restore all tabs immediately
await windowReady;
// But we should not have restored the background tab
ok(newTab2.hasAttribute("pending"), "Background tab should be pending");

Просмотреть файл

@ -323,7 +323,7 @@
<![CDATA[
let {tabParent} = this.frameLoader;
if (!tabParent || !tabParent.hasBeforeUnload) {
if (!tabParent.hasBeforeUnload) {
return { permitUnload: true, timedOut: false };
}