Bug 1405192 - Return if onResume has already been called and onPause hasn't. Add telemetry ping for future investigations. r?mcomella draft
authorVlad Baicu <vlad.baicu@softvision.ro>
Wed, 25 Apr 2018 18:56:55 +0300
changeset 787891 3e0319ce81e169f87d1347cbe0765629678f24bd
parent 787539 6eeb97ca94f40189d5aa552da9e0b0b11bfa0441
child 791445 4c6ac48ef6a1f2a66a4c665a792344ebc30667d4
push id107829
push uservbaicu@mozilla.com
push dateWed, 25 Apr 2018 15:58:19 +0000
reviewersmcomella
bugs1405192
milestone61.0a1
Bug 1405192 - Return if onResume has already been called and onPause hasn't. Add telemetry ping for future investigations. r?mcomella After investigating and analyzing the crash reports this type of scenario can occur due to multi-window or some popups. We are tracking this scenario for further investiagion with a telemetry event. Also added a constant for the hardcoded telemetry event when onPause gets called before onResume. MozReview-Commit-ID: 2qXCYFyjlce
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
@@ -38,16 +38,19 @@ import java.util.List;
 /**
  * An activity-lifecycle delegate for uploading the core ping.
  */
 public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
         implements SearchEngineManager.SearchEngineCallback, AttributionHelperListener {
     private static final String LOGTAG = StringUtils.safeSubstring(
             "Gecko" + TelemetryCorePingDelegate.class.getSimpleName(), 0, 23);
 
+    private static final String TELEMETRY_EXTRA_ONRESUME_ALREADY_CALLED = "onResumeAlreadyCalled";
+    private static final String TELEMETRY_EXTRA_ONPAUSE_CALLED_BEFORE_ONRESUME = "onPauseCalledBeforeOnResume";
+
     private boolean isOnResumeCalled = false;
     private TelemetryDispatcher telemetryDispatcher; // lazy
     private final SessionMeasurements sessionMeasurements = new SessionMeasurements();
 
     @Override
     public void onStart(final BrowserApp browserApp) {
         TelemetryPreferences.initPreferenceObserver(browserApp, GeckoThread.getActiveProfile().getName());
 
@@ -84,24 +87,28 @@ public class TelemetryCorePingDelegate e
 
     private void uploadPing(final BrowserApp browserApp) {
         final SearchEngineManager searchEngineManager = browserApp.getSearchEngineManager();
         searchEngineManager.getEngine(this);
     }
 
     @Override
     public void onResume(BrowserApp browserApp) {
+        if (isOnResumeCalled) {
+            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.SYSTEM, TELEMETRY_EXTRA_ONRESUME_ALREADY_CALLED);
+            return;
+        }
         isOnResumeCalled = true;
         sessionMeasurements.recordSessionStart();
     }
 
     @Override
     public void onPause(BrowserApp browserApp) {
         if (!isOnResumeCalled) {
-            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.SYSTEM, "onPauseCalledBeforeOnResume");
+            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.SYSTEM, TELEMETRY_EXTRA_ONPAUSE_CALLED_BEFORE_ONRESUME);
             return;
         }
         isOnResumeCalled = false;
         // onStart/onStop is ideal over onResume/onPause. However, onStop is not guaranteed to be called and
         // dealing with that possibility adds a lot of complexity that we don't want to handle at this point.
         sessionMeasurements.recordSessionEnd(browserApp);
     }