Bug 1292602 - Set notification client before launching Gecko to avoid crash on notification r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 19 Aug 2016 09:51:37 -0700
changeset 403374 7bd19c0f04d04877fa8ee52e728106b5b5f805a3
parent 403373 2201eb4cf3a99e668e6eba8e938a74cf9d547f06
child 528894 f4610dd028a84c5f0700277a024de20cea8cd35e
push id26900
push userahunt@mozilla.com
push dateFri, 19 Aug 2016 16:52:40 +0000
reviewerssebastian
bugs1292602
milestone51.0a1
Bug 1292602 - Set notification client before launching Gecko to avoid crash on notification r?sebastian 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
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1217,16 +1217,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.
         GeckoAppShell.setContextGetter(this);
         GeckoAppShell.setApplicationContext(getApplicationContext());
         GeckoAppShell.setGeckoInterface(this);
+        // 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());
 
         Tabs.getInstance().attachToContext(this);
         try {
             Favicons.initializeWithContext(this);
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
         }
 
@@ -1477,17 +1480,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());
         IntentHelper.init(this);
     }
 
     @Override
     public void onStart() {
         super.onStart();
         if (mIsAbortingAppLaunch) {
             return;