Bug 760152 - Start library decompression earlier. r=blassey a=akeybl
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 04 Jun 2012 16:58:54 +0200
changeset 100278 b4e4ba4d5d6f7b7f24aef4e40c0a20a247906124
parent 100277 97a2af80999bfbcbe9d398fe4b984a5a578a811d
child 100279 b04c6364ebf6471674e520ea0496100fb6d78ea7
push id1128
push userbnicholson@mozilla.com
push dateThu, 19 Jul 2012 04:06:03 +0000
treeherdermozilla-beta@b2487714085b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, akeybl
bugs760152
milestone15.0
Bug 760152 - Start library decompression earlier. r=blassey a=akeybl
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoThread.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1728,16 +1728,21 @@ abstract public class GeckoApp
         }
 
         // StrictMode is set by defaults resource flag |enableStrictMode|.
         if (getResources().getBoolean(R.bool.enableStrictMode)) {
             enableStrictMode();
         }
 
         GeckoAppShell.loadMozGlue();
+        sGeckoThread = new GeckoThread();
+        String uri = getURIFromIntent(getIntent());
+        if (uri != null && uri.length() > 0 && !uri.equals("about:home"))
+            sGeckoThread.start();
+
         mMainHandler = new Handler();
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
 
         LayoutInflater.from(this).setFactory(GeckoViewsFactory.getInstance());
 
         super.onCreate(savedInstanceState);
 
         mOrientation = getResources().getConfiguration().orientation;
@@ -1814,27 +1819,27 @@ abstract public class GeckoApp
             // We're going to handle this uri with the redirector, so setting
             // the action to MAIN and clearing the uri data prevents us from
             // loading it twice
             intent.setAction(Intent.ACTION_MAIN);
             intent.setData(null);
             passedUri = "about:empty";
         }
 
-        sGeckoThread = new GeckoThread(intent, passedUri, mRestoreMode);
+        sGeckoThread.init(intent, passedUri, mRestoreMode);
         if (!ACTION_DEBUG.equals(action) &&
             checkAndSetLaunchState(LaunchState.Launching, LaunchState.Launched)) {
-            sGeckoThread.start();
+            sGeckoThread.reallyStart();
         } else if (ACTION_DEBUG.equals(action) &&
             checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {
             mMainHandler.postDelayed(new Runnable() {
                 public void run() {
                     Log.i(LOGTAG, "Launching from debug intent after 5s wait");
                     setLaunchState(LaunchState.Launching);
-                    sGeckoThread.start();
+                    sGeckoThread.reallyStart();
                 }
             }, 1000 * 5 /* 5 seconds */);
             Log.i(LOGTAG, "Intent : ACTION_DEBUG - waiting 5s before launching");
         }
 
         mFavicons = new Favicons(this);
 
         Tabs.getInstance().setContentResolver(getContentResolver());
--- a/mobile/android/base/GeckoThread.java
+++ b/mobile/android/base/GeckoThread.java
@@ -13,46 +13,62 @@ import android.util.Log;
 import android.widget.AbsoluteLayout;
 
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Date;
 import java.util.Locale;
+import java.util.concurrent.CountDownLatch;
 
 public class GeckoThread extends Thread {
     private static final String LOGTAG = "GeckoThread";
 
     Intent mIntent;
     String mUri;
     int mRestoreMode;
+    CountDownLatch mStartSignal;
 
-    GeckoThread(Intent intent, String uri, int restoreMode) {
+    GeckoThread() {
+        mStartSignal = new CountDownLatch(1);
+        setName("Gecko");
+    }
+
+    public void init(Intent intent, String uri, int restoreMode) {
         mIntent = intent;
         mUri = uri;
         mRestoreMode = restoreMode;
+    }
 
-        setName("Gecko");
+    public void reallyStart() {
+        mStartSignal.countDown();
+        if (getState() == Thread.State.NEW)
+            start();
     }
 
     public void run() {
         final GeckoApp app = GeckoApp.mAppContext;
 
         // At some point while loading the gecko libs our default locale gets set
         // so just save it to locale here and reset it as default after the join
         Locale locale = Locale.getDefault();
 
         String resourcePath = app.getApplication().getPackageResourcePath();
         GeckoAppShell.setupGeckoEnvironment(app);
         GeckoAppShell.loadSQLiteLibs(app, resourcePath);
         GeckoAppShell.loadNSSLibs(app, resourcePath);
         GeckoAppShell.loadGeckoLibs(resourcePath);
 
         Locale.setDefault(locale);
+
+        try {
+            mStartSignal.await();
+        } catch (Exception e) { }
+
         Resources res = app.getBaseContext().getResources();
         Configuration config = res.getConfiguration();
         config.locale = locale;
         res.updateConfiguration(config, res.getDisplayMetrics());
 
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");
 
         // find the right intent type