Bug 1292602 - Set notification client before launching Gecko to avoid crash on notification. r=sebastian, a=lizzard
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 19 Aug 2016 09:51:37 -0700
changeset 342536 6fa85d08812d106a9a23aa05f8ff08e0bd2aae15
parent 342535 3ca29b6e9f8c88a97aa438e180fd7bea55f5070a
child 342537 33fa756e769e1548b8f81aee313843eca0de09cf
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, lizzard
Bug 1292602 - Set notification client before launching Gecko to avoid crash on notification. r=sebastian, a=lizzard Gecko could potentially send notifications via ShowAlertNotification (or any related method). It's possible for this to happen very soon after launching Gecko, so we need to set the GeckoAppShell's notificationClient before launching Gecko to ensure that it can handle notifications (this also avoids the associated crash - we could try to do null-checks instead, but that would result in dropped notifications, which doesn't seem useful). MozReview-Commit-ID: 5MG8bBnt12M
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1212,16 +1212,19 @@ public abstract class GeckoApp
         // the app context, because various parts of Fennec (e.g.,
         // GeckoScreenOrientation) use GAS to access the Activity in
         // the guise of fetching a Context.
         // When that's fixed, `this` can change to
         // `(GeckoApplication) getApplication()` here.
+        // We need to set the notification client before launching Gecko, since Gecko could start
+        // sending notifications immediately after startup, which we don't want to lose/crash on.
+        GeckoAppShell.setNotificationClient(makeNotificationClient());
         try {
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
@@ -1465,17 +1468,16 @@ public abstract class GeckoApp
                 // We use per-profile prefs here, because we're tracking against
                 // a Gecko pref. The same applies to the locale switcher!
                 BrowserLocaleManager.storeAndNotifyOSLocale(GeckoSharedPrefs.forProfile(GeckoApp.this), osLocale);
-        GeckoAppShell.setNotificationClient(makeNotificationClient());
     public void onStart() {
         if (mIsAbortingAppLaunch) {