Bug 1315938 - Don't crash if tabs aren't initialised yet r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 08 Nov 2016 13:07:24 +0100
changeset 352054 bc22ca7ff05bbe74b770f9c41ca7bcadfe188d98
parent 352053 86d2e155758ce5eb42f29f3cfae120a647189e95
child 352055 8d8337d3199c80c015caf726e9b205ca82cd8334
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1315938
milestone52.0a1
Bug 1315938 - Don't crash if tabs aren't initialised yet r=sebastian getSelectedTab() specifies that it can return null "if we're doing a session restore after a crash and Gecko isn't ready yet". This seems to occasionally be happening, resulting in crashes. (What isn't clear is why this would be happening more regularly in 51, it's possible some completely unrelated changes are either making the rendering of TopSites faster, causing this call to be made earlier, or session restore has simply gotten slower. We have also had a crash spike recently due to library loading issues, which would likely further exacerbate the whole issue.) MozReview-Commit-ID: GLFOoXFrAkj
mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
@@ -196,17 +196,18 @@ public class TwoLinePageRow extends Line
     }
 
     /**
      * Replaces the page URL with "Switch to tab" if there is already a tab open with that URL.
      * Only looks for tabs that are either private or non-private, depending on the current
      * selected tab.
      */
     protected void updateDisplayedUrl() {
-        boolean isPrivate = Tabs.getInstance().getSelectedTab().isPrivate();
+        final Tab selectedTab = Tabs.getInstance().getSelectedTab();
+        final boolean isPrivate = (selectedTab != null) && (selectedTab.isPrivate());
 
         // We always want to display the underlying page url, however for readermode pages
         // we navigate to the about:reader equivalent, hence we need to use that url when finding
         // existing tabs
         final String navigationUrl = mHasReaderCacheItem ? ReaderModeUtils.getAboutReaderForUrl(mPageUrl) : mPageUrl;
         Tab tab = Tabs.getInstance().getFirstTabForUrl(navigationUrl, isPrivate);