Bug 1338893 - Don't use the window on application-foreground if it doesn't yet exist. r=sebastian
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 12 Feb 2017 15:09:32 +0100
changeset 342543 3bfcb88ae88d2372fc8dd14203194cc965652512
parent 342542 db46b66a8c3b0fe571dad420652531d5b548c538
child 342544 e8b1868152413169b2179054851a2bfde9f51f24
push id31357
push userkwierso@gmail.com
push dateTue, 14 Feb 2017 00:49:21 +0000
treeherdermozilla-central@bca082441767 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1338893
milestone54.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 1338893 - Don't use the window on application-foreground if it doesn't yet exist. r=sebastian During a cold startup, depending how this exactly plays out we might receive an application-foreground notification before the browser window is ready. Since the code to restore the selected tab if it has been left zombified while in background is only relevant if Gecko was already running and backgrounded, we can simply add a null check for the window before accessing it. MozReview-Commit-ID: Ahp5NAODKRF
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -351,18 +351,20 @@ SessionStore.prototype = {
         // Reset minimum interval between session store writes back to default.
         log("application-foreground");
         this._interval = Services.prefs.getIntPref("browser.sessionstore.interval");
         this._minSaveDelay = MINIMUM_SAVE_DELAY;
 
         // If we skipped restoring a zombified tab before backgrounding,
         // we might have to do it now instead.
         let window = Services.wm.getMostRecentWindow("navigator:browser");
-        let tab = window.BrowserApp.selectedTab;
-        this.restoreZombieTab(tab);
+        if (window) { // Might not yet be ready during a cold startup.
+          let tab = window.BrowserApp.selectedTab;
+          this.restoreZombieTab(tab);
+        }
         break;
       case "ClosedTabs:StartNotifications":
         this._notifyClosedTabs = true;
         log("ClosedTabs:StartNotifications");
         this._sendClosedTabsToJava(Services.wm.getMostRecentWindow("navigator:browser"));
         break;
       case "ClosedTabs:StopNotifications":
         this._notifyClosedTabs = false;