Bug 1276340 - Move the session parsing in front of the layout initialisation. draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 23 Apr 2016 20:54:57 +0200
changeset 372218 2eded5c620eb99277861ce7bbf39b6f5784007a0
parent 372205 7ea5f453d7c8df1970ccba297011ec686bf90acb
child 372219 f0fc86a8744ef385df73616ba32f608c4f22c4fd
push id19477
push usermozilla@buttercookie.de
push dateFri, 27 May 2016 19:19:50 +0000
bugs1276340, 905223
milestone49.0a1
Bug 1276340 - Move the session parsing in front of the layout initialisation. Since we're now doing the session data parsing in background anyway (see bug 905223), we might as well start doing it slightly earlier and have it running in parallel to parts of the layout setup, so we don't bump immediately into the the following, preexisting bit of background initialisation. MozReview-Commit-ID: UJwhCQmcEa
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
@@ -1237,37 +1237,16 @@ public abstract class GeckoApp
             // Bug 896992 - This intent has already been handled; reset the intent.
             setIntent(new Intent(Intent.ACTION_MAIN));
         }
 
         super.onCreate(savedInstanceState);
 
         GeckoScreenOrientation.getInstance().update(getResources().getConfiguration().orientation);
 
-        setContentView(getLayout());
-
-        // Set up Gecko layout.
-        mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
-        mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
-        mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
-        mLayerView = (LayerView) findViewById(R.id.layer_view);
-
-        // Use global layout state change to kick off additional initialization
-        mMainLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);
-
-        if (Versions.preMarshmallow) {
-            mTextSelection = new ActionBarTextSelection(
-                    (TextSelectionHandle) findViewById(R.id.anchor_handle),
-                    (TextSelectionHandle) findViewById(R.id.caret_handle),
-                    (TextSelectionHandle) findViewById(R.id.focus_handle));
-        } else {
-            mTextSelection = new FloatingToolbarTextSelection(this, mLayerView);
-        }
-        mTextSelection.create();
-
         // Determine whether we should restore tabs.
         mLastSessionCrashed = updateCrashedState();
         mShouldRestore = getSessionRestoreState(savedInstanceState);
         if (mShouldRestore && savedInstanceState != null) {
             boolean wasInBackground =
                 savedInstanceState.getBoolean(SAVED_STATE_IN_BACKGROUND, false);
 
             // Don't log OOM-kills if only one activity was destroyed. (For example
@@ -1311,16 +1290,37 @@ public abstract class GeckoApp
                     GeckoAppShell.notifyObservers("Session:Restore", restoreMessage);
                 }
 
                 // Make sure sessionstore.bak is either updated or deleted as necessary.
                 getProfile().updateSessionFile(mShouldRestore);
             }
         });
 
+        setContentView(getLayout());
+
+        // Set up Gecko layout.
+        mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
+        mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
+        mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
+        mLayerView = (LayerView) findViewById(R.id.layer_view);
+
+        // Use global layout state change to kick off additional initialization
+        mMainLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);
+
+        if (Versions.preMarshmallow) {
+            mTextSelection = new ActionBarTextSelection(
+                    (TextSelectionHandle) findViewById(R.id.anchor_handle),
+                    (TextSelectionHandle) findViewById(R.id.caret_handle),
+                    (TextSelectionHandle) findViewById(R.id.focus_handle));
+        } else {
+            mTextSelection = new FloatingToolbarTextSelection(this, mLayerView);
+        }
+        mTextSelection.create();
+
         // Perform background initialization.
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
                 final SharedPreferences prefs = GeckoApp.this.getSharedPreferences();
 
                 // Wait until now to set this, because we'd rather throw an exception than
                 // have a caller of BrowserLocaleManager regress startup.