Bug 760152 - Start library decompression earlier. r=blassey
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 04 Jun 2012 16:58:54 +0200
changeset 95773 d945ae198516661dcbb9fab1820e2bde1f63bca2
parent 95772 7dd03f6f21d9758c56dc003e11566b7a1c3e40f0
child 95774 2b2f7ab4304f63709dcdae388fce0e4ec4e42555
push id22851
push usergeoff@darktrojan.net
push dateTue, 05 Jun 2012 12:52:39 +0000
treeherdermozilla-central@c76497029f0d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs760152
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 760152 - Start library decompression earlier. r=blassey
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoThread.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1768,16 +1768,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;
@@ -1866,27 +1871,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