Bug 1315938 - Don't crash if tabs aren't initialised yet r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 08 Nov 2016 13:07:24 +0100
changeset 435328 4bb7607609e76f4161ceabee257b95f349dd5c98
parent 435182 f13e90d496cf1bc6dfc4fd398da33e4afe785bde
child 435331 204e3b675c8836251aeed0dc749e23e389523d59
child 435383 25c298336dde28e90beb4274294e82ccac9d9103
push id35004
push userahunt@mozilla.com
push dateTue, 08 Nov 2016 12:42:02 +0000
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);