Improve browser startup time
A number of optimizations are made to improve the time to interact with the UI quicker.
Steps are made to parallelize the web engine initialization while others removed
impediments to the UI bring up.
Changes:
- Engine Initialization is moved to an async task.
- A new NoShow BrowserLauncher activity is added to chain-load BrowserActivity at startup
obviating the blank white screen shown.
- Native libraries are loaded asynchronously in a background thread.
- ResourceExtractor is started much earlier than before.
- BrowserSettings is synced to native only after engine initialization.
- Other parts of UI are made aware of engine initialization state to throttle actions.
Change-Id: Icd4959769fa9813170baf7023c46b696b30dfed1
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index b958854..255aaf8 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -130,6 +130,9 @@
private static String sFactoryResetUrl;
+ private boolean mEngineInitialized = false;
+ private boolean mSyncManagedSettings = false;
+
public static synchronized void initialize(final Context context) {
if (sInstance == null)
sInstance = new BrowserSettings(context);
@@ -142,7 +145,6 @@
private BrowserSettings(Context context) {
mContext = context.getApplicationContext();
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
- mAutofillHandler = new AutofillHandler(mContext);
mManagedSettings = new LinkedList<WeakReference<WebSettings>>();
mCustomUserAgents = new WeakHashMap<WebSettings, String>();
BackgroundHandler.execute(mSetup);
@@ -150,7 +152,16 @@
public void setController(Controller controller) {
mController = controller;
- if (sInitialized) {
+ mNeedsSharedSync = true;
+ }
+
+ public void onEngineInitializationComplete() {
+ mEngineInitialized = true;
+ mAutofillHandler = new AutofillHandler(mContext);
+ if (mSyncManagedSettings) {
+ syncManagedSettings();
+ }
+ if (mNeedsSharedSync) {
syncSharedSettings();
}
}
@@ -402,6 +413,11 @@
}
private void syncManagedSettings() {
+ if (!mEngineInitialized) {
+ mSyncManagedSettings = true;
+ return;
+ }
+ mSyncManagedSettings = false;
syncSharedSettings();
synchronized (mManagedSettings) {
Iterator<WeakReference<WebSettings>> iter = mManagedSettings.iterator();