DON'T LAND - Debug logging draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Mon, 18 Apr 2016 19:30:41 +0200
changeset 356907 751dcc2b0c4e291c9f1aaace6b3ad6277c8ae72e
parent 356906 a39c8987e95a9bc690302327c1cfb7dd3144ddfc
child 519516 46c6c8f5dcd370b59efb7f627cccfba855bbed50
push id16637
push usermozilla@buttercookie.de
push dateWed, 27 Apr 2016 13:50:52 +0000
milestone49.0a1
DON'T LAND - Debug logging Just grep "PREFS_CRASHED" in logcat. Note: PREFS_CRASHED has now been replaced by mLastSessionCrashed, but for easier filtering it's still referred to as PREFS_CRASHED in the logs. MozReview-Commit-ID: K7pqMlkloA4
mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/CrashReporter.java
@@ -132,16 +132,17 @@ public class CrashReporter extends AppCo
 
         mExtrasStringMap = new HashMap<String, String>();
         readStringsFromFile(mPendingExtrasFile.getPath(), mExtrasStringMap);
 
         // Notify GeckoApp that we've crashed, so it can react appropriately during the next start.
         try {
             File crashFlag = new File(GeckoProfileDirectories.getMozillaDirectory(this), "CRASHED");
             crashFlag.createNewFile();
+            Log.d(LOGTAG, "PREFS_CRASHED writing crash flag");
         } catch (GeckoProfileDirectories.NoMozillaDirectoryException | IOException e) {
             Log.e(LOGTAG, "Cannot set crash flag: ", e);
         }
 
         final CheckBox allowContactCheckBox = (CheckBox) findViewById(R.id.allow_contact);
         final CheckBox includeUrlCheckBox = (CheckBox) findViewById(R.id.include_url);
         final CheckBox sendReportCheckBox = (CheckBox) findViewById(R.id.send_report);
         final EditText commentsEditText = (EditText) findViewById(R.id.comment);
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1420,16 +1420,17 @@ public abstract class GeckoApp
      * If we've temporarily disabled restoring to break out of a crash loop, we'll
      * show the recent tabs panel so the user can manually restore tabs as needed.
      * If we restore tabs, we don't need to create a new tab.
      */
     protected void loadStartupTab(final int flags) {
         if (!mShouldRestore) {
             if (mLastSessionCrashed) {
                 Tabs.getInstance().loadUrl(AboutPages.getURLForBuiltinPanelType(PanelType.RECENT_TABS), flags);
+                Log.d(LOGTAG, "PREFS_CRASHED showing recent tabs panel after crash");
             } else {
                 final String homepage = getHomepage();
                 Tabs.getInstance().loadUrl(!TextUtils.isEmpty(homepage) ? homepage : AboutPages.HOME, flags);
             }
         }
     }
 
     /**
@@ -1734,16 +1735,17 @@ public abstract class GeckoApp
      * @param savedInstanceState Saved instance state given to the activity
      * @return                   Whether to restore
      */
     protected boolean getSessionRestoreState(Bundle savedInstanceState) {
         final SharedPreferences prefs = getSharedPreferences();
         boolean shouldRestore = false;
 
         final int versionCode = getVersionCode();
+        Log.d(LOGTAG, "getSessionRestoreState() PREFS_CRASHED currently reads " + mLastSessionCrashed);
         if (mLastSessionCrashed) {
             if (incrementCrashCount(prefs) <= getSessionStoreMaxCrashResumes(prefs) &&
                     getSessionRestoreAfterCrashPreference(prefs)) {
                 shouldRestore = true;
             } else {
                 shouldRestore = false;
             }
         } else if (prefs.getInt(PREFS_VERSION_CODE, 0) != versionCode) {
@@ -1760,16 +1762,17 @@ public abstract class GeckoApp
         }
 
         return shouldRestore;
     }
 
     private int incrementCrashCount(SharedPreferences prefs) {
         final int crashCount = getSuccessiveCrashesCount(prefs) + 1;
         prefs.edit().putInt(PREFS_CRASHED_COUNT, crashCount).apply();
+        Log.d(LOGTAG, "incrementing PREFS_CRASHED_COUNT to " + crashCount);
         return crashCount;
     }
 
     private int getSuccessiveCrashesCount(SharedPreferences prefs) {
         return prefs.getInt(PREFS_CRASHED_COUNT, 0);
     }
 
     private int getSessionStoreMaxCrashResumes(SharedPreferences prefs) {
@@ -2011,20 +2014,22 @@ public abstract class GeckoApp
                 // Now construct the new session on HealthRecorder's behalf. We do this here
                 // so it can benefit from a single near-startup prefs commit.
                 SessionInformation currentSession = new SessionInformation(now, realTime);
 
                 SharedPreferences prefs = GeckoApp.this.getSharedPreferences();
                 SharedPreferences.Editor editor = prefs.edit();
                 editor.putBoolean(GeckoApp.PREFS_WAS_STOPPED, false);
 
+                Log.d(LOGTAG, "onResume() PREFS_CRASHED currently reads " + mLastSessionCrashed);
                 if (!mLastSessionCrashed) {
                     // The last session terminated normally,
                     // so we can reset the count of successive crashes.
                     editor.putInt(GeckoApp.PREFS_CRASHED_COUNT, 0);
+                    Log.d(LOGTAG, "onResume() setting PREFS_CRASHED_COUNT to 0");
                 }
 
                 currentSession.recordBegin(editor);
                 editor.apply();
 
                 final HealthRecorder rec = mHealthRecorder;
                 if (rec != null) {
                     rec.setCurrentSession(currentSession);
@@ -2071,16 +2076,17 @@ public abstract class GeckoApp
                 editor.putBoolean(GeckoApp.PREFS_WAS_STOPPED, true);
                 if (rec != null) {
                     rec.recordSessionEnd("P", editor);
                 }
 
                 // onPause might in fact be called even after a crash, but in that case the
                 // crash reporter will record this fact for us and we'll pick it up in onCreate.
                 mLastSessionCrashed = false;
+                Log.d(LOGTAG, "onPause() setting PREFS_CRASHED to false");
 
                 // If we haven't done it before, cleanup any old files in our old temp dir
                 if (prefs.getBoolean(GeckoApp.PREFS_CLEANUP_TEMP_FILES, true)) {
                     File tempDir = GeckoLoader.getGREDir(GeckoApp.this);
                     FileUtils.delTree(tempDir, new FileUtils.NameAndAgeFilter(null, ONE_DAY_MS), false);
 
                     editor.putBoolean(GeckoApp.PREFS_CLEANUP_TEMP_FILES, false);
                 }