BrowserApp startup tab selection debug logging draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 08 Apr 2017 22:59:16 +0200
changeset 568918 2416d92b0470b6aa6edee2cb224eff9f110061a7
parent 568917 ef23bdfd3719f44f080df1bea14ff8d34c3ca26e
child 568919 b9de096d2e678fa6dd7329f30879cc6efa385c21
push id56020
push usermozilla@buttercookie.de
push dateWed, 26 Apr 2017 18:35:14 +0000
milestone55.0a1
BrowserApp startup tab selection debug logging MozReview-Commit-ID: 79QnUF1Edg3
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1158,46 +1158,55 @@ public class BrowserApp extends GeckoApp
 
         for (BrowserAppDelegate delegate : delegates) {
             delegate.onResume(this);
         }
     }
 
     @Override
     protected void restoreLastSelectedTab() {
+        Log.d(LOGTAG, "GeckoTabs, restore selected, mIsRestoringActivity: " + mIsRestoringActivity +
+        " mResumingAfterOnCreate: " + mResumingAfterOnCreate);
         if (mResumingAfterOnCreate && !mIsRestoringActivity) {
             // We're the first activity to run, so our startup code will (have) handle(d) tab selection.
             return;
         }
 
+        Log.d(LOGTAG, "GeckoTabs, restore selected, mLastSelectedTabId: " + mLastSelectedTabId);
         if (mLastSelectedTabId < 0) {
             // Normally, session restore will select the correct tab when starting up, however this
             // is linked to Gecko powering up. If we're not the first activity to launch, the
             // previously running activity might have already overwritten this by selecting a tab of
             // its own.
             // Therefore we check whether the session file parser has left a note for us with the
             // correct tab to be initially selected on *BrowserApp* startup.
             SharedPreferences prefs = getSharedPreferencesForProfile();
             mLastSelectedTabId = prefs.getInt(STARTUP_SELECTED_TAB, INVALID_TAB_ID);
             mLastSessionUUID = prefs.getString(STARTUP_SESSION_UUID, null);
+            Log.d(LOGTAG, "GeckoTabs, read from prefs, mLastSelectedTabId: " + mLastSelectedTabId +
+            " mLastSessionUUID: " + (mLastSessionUUID != null ? mLastSessionUUID.toString() : "<none>"));
 
             SharedPreferences.Editor editor = prefs.edit();
             editor.remove(STARTUP_SELECTED_TAB);
             editor.remove(STARTUP_SESSION_UUID);
             editor.apply();
         }
 
         final Tabs tabs = Tabs.getInstance();
         final Tab tabToSelect = tabs.getTab(mLastSelectedTabId);
+        Log.d(LOGTAG, "GeckoTabs, found tab: " + (tabToSelect != null ? tabToSelect.getId() : "<none>"));
 
         if (tabToSelect != null && GeckoApplication.getSessionUUID().equals(mLastSessionUUID) &&
                 tabToSelect.getType() == TabType.BROWSING) {
+            Log.d(LOGTAG, "GeckoTabs, selecting found tab");
             tabs.selectTab(mLastSelectedTabId);
         } else {
+            Log.d(LOGTAG, "GeckoTabs, selecting fallback");
             if (!tabs.selectLastTab(TabType.BROWSING)) {
+                Log.d(LOGTAG, "GeckoTabs, opening fallback");
                 tabs.loadUrl(Tabs.getHomepageForStartupTab(this), Tabs.LOADURL_NEW_TAB);
             }
         }
     }
 
     @Override
     public void onPause() {
         super.onPause();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1302,23 +1302,25 @@ public abstract class GeckoApp
         mResumingAfterOnCreate = true;
 
         if (sAlreadyLoaded) {
             // This happens when the GeckoApp activity is destroyed by Android
             // without killing the entire application (see Bug 769269).
             // Now that we've got multiple GeckoApp-based activities, this can
             // also happen if we're not the first activity to run within a session.
             mIsRestoringActivity = true;
+            Log.d("LOGTAG", "GeckoTabs onCreate, this = " + getClass().getName() + ", setting mIsRestoringActivity = true");
             Telemetry.addToHistogram("FENNEC_RESTORING_ACTIVITY", 1);
 
         } else {
             final String action = intent.getAction();
             final String args = intent.getStringExtra("args");
 
             sAlreadyLoaded = true;
+            Log.d("LOGTAG", "GeckoTabs onCreate, this = " + getClass().getName() + ", setting sAlreadyLoaded = true");
             GeckoThread.initMainProcess(/* profile */ null, args,
                                         /* debugging */ ACTION_DEBUG.equals(action));
 
             // Speculatively pre-fetch the profile in the background.
             ThreadUtils.postToBackgroundThread(new Runnable() {
                 @Override
                 public void run() {
                     getProfile();
@@ -2399,16 +2401,19 @@ public abstract class GeckoApp
             return;
         }
 
         foregrounded = true;
 
         GeckoAppShell.setGeckoInterface(this);
         GeckoAppShell.setScreenOrientationDelegate(this);
 
+        Log.d(LOGTAG, "GeckoTabs resuming, this = " + getClass().getName() +
+                ", last active = " + (mLastActiveGeckoApp != null ? mLastActiveGeckoApp.get().getClass().getName() :
+        "none" + ", check on resume = " + mCheckTabSelectionOnResume));
         if (mLastActiveGeckoApp == null || mLastActiveGeckoApp.get() != this ||
                 mCheckTabSelectionOnResume) {
             mCheckTabSelectionOnResume = false;
             restoreLastSelectedTab();
         }
 
         int newOrientation = getResources().getConfiguration().orientation;
         if (GeckoScreenOrientation.getInstance().update(newOrientation)) {