Bug 905223 - Part 3 - Move the session parsing in front of the layout initialisation. r=margaret
Since we're doing this in background now anyway, we might as well start doing it slightly earlier and run 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
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1245,37 +1245,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
@@ -1310,16 +1289,37 @@ public abstract class GeckoApp
mRestoreMessage = restoreMessage;
mSessionRestoreParsingFinished.countDown();
// 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.