Back out cf07667d28cb (bug 880259) for Android crashes, timeouts, test failures and misrenderings
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 12 Jul 2013 17:20:26 -0700
changeset 138408 855854e0545335e97b57298dc80bccb9503e75e1
parent 138407 67eb0198434e93de33312c01cd58cb0c8654130c
child 138409 78b3873cd79e22f463778d73ba7e085816a1b100
push id30962
push userphilringnalda@gmail.com
push dateSat, 13 Jul 2013 00:21:52 +0000
treeherdermozilla-inbound@855854e05453 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs880259
milestone25.0a1
backs outcf07667d28cbe131200a01dd98288038fd80eb2d
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
Back out cf07667d28cb (bug 880259) for Android crashes, timeouts, test failures and misrenderings CLOSED TREE
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoThread.java
mobile/android/base/GeckoView.java
mobile/android/base/resources/layout/shared_ui_components.xml
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -169,16 +169,17 @@ abstract public class GeckoApp
     protected RelativeLayout mGeckoLayout;
     public View getView() { return mGeckoLayout; }
     private View mCameraView;
     private OrientationEventListener mCameraOrientationEventListener;
     public List<GeckoAppShell.AppStateListener> mAppStateListeners;
     private static GeckoApp sAppContext;
     protected MenuPanel mMenuPanel;
     protected Menu mMenu;
+    private static GeckoThread sGeckoThread;
     private GeckoProfile mProfile;
     public static int mOrientation;
     protected boolean mIsRestoringActivity;
     private String mCurrentResponse = "";
     public static boolean sIsUsingCustomProfile = false;
 
     private PromptService mPromptService;
     private TextSelection mTextSelection;
@@ -1237,17 +1238,17 @@ abstract public class GeckoApp
         // handle this event if "Don't keep activities" is enabled (filed as
         // bug 889082).
         if (((GeckoApplication)getApplication()).needsRestart()) {
             doRestart();
             System.exit(0);
             return;
         }
 
-        if (GeckoThread.sGeckoThread != null) {
+        if (sGeckoThread != null) {
             // This happens when the GeckoApp activity is destroyed by Android
             // without killing the entire application (see Bug 769269).
             mIsRestoringActivity = true;
             Telemetry.HistogramAdd("FENNEC_RESTORING_ACTIVITY", 1);
         }
 
         // Fix for Bug 830557 on Tegra boards running Froyo.
         // This fix must be done before doing layout.
@@ -1389,18 +1390,16 @@ abstract public class GeckoApp
         String action = intent.getAction();
 
         String passedUri = null;
         String uri = getURIFromIntent(intent);
         if (uri != null && uri.length() > 0) {
             passedUri = uri;
         }
 
-        GeckoThread.setStartupArgs(passedUri, intent.getStringExtra("args"), action);
-
         final boolean isExternalURL = passedUri != null && !passedUri.equals("about:home");
         StartupAction startupAction;
         if (isExternalURL) {
             startupAction = StartupAction.URL;
         } else {
             startupAction = StartupAction.NORMAL;
         }
 
@@ -1452,26 +1451,29 @@ abstract public class GeckoApp
         }
 
         if (mRestoreMode == RESTORE_NONE) {
             Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);
         }
 
         Telemetry.HistogramAdd("FENNEC_STARTUP_GECKOAPP_ACTION", startupAction.ordinal());
 
+        if (!mIsRestoringActivity) {
+            sGeckoThread = new GeckoThread(intent, passedUri);
+        }
         if (!ACTION_DEBUG.equals(action) &&
             GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.Launching, GeckoThread.LaunchState.Launched)) {
-            GeckoThread.getInstance().start();
+            sGeckoThread.start();
         } else if (ACTION_DEBUG.equals(action) &&
             GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.Launching, GeckoThread.LaunchState.WaitForDebugger)) {
             ThreadUtils.getUiHandler().postDelayed(new Runnable() {
                 @Override
                 public void run() {
                     GeckoThread.setLaunchState(GeckoThread.LaunchState.Launching);
-                    GeckoThread.getInstance().start();
+                    sGeckoThread.start();
                 }
             }, 1000 * 5 /* 5 seconds */);
         }
 
         // Check if launched from data reporting notification.
         if (ACTION_LAUNCH_SETTINGS.equals(action)) {
             Intent settingsIntent = new Intent(GeckoApp.this, GeckoPreferences.class);
             // Copy extras.
--- a/mobile/android/base/GeckoThread.java
+++ b/mobile/android/base/GeckoThread.java
@@ -32,38 +32,22 @@ public class GeckoThread extends Thread 
         WaitForDebugger,
         Launched,
         GeckoRunning,
         GeckoExiting
     };
 
     private static LaunchState sLaunchState = LaunchState.Launching;
 
-    static GeckoThread sGeckoThread;
-    static String sUri;
-    static String sArgs;
-    static String sAction;
+    private Intent mIntent;
+    private final String mUri;
 
-    static void setStartupArgs(String uri, String args, String action) {
-        if (uri != null)
-            sUri = uri;
-        if (args != null)
-            sArgs = args;
-        if (action != null)
-            sAction = action;
-    }
-
-    static GeckoThread getInstance() {
-        if (sGeckoThread == null) {
-            sGeckoThread = new GeckoThread();
-        }
-        return sGeckoThread;
-    }
-
-    private GeckoThread() {
+    GeckoThread(Intent intent, String uri) {
+        mIntent = intent;
+        mUri = uri;
         setName("Gecko");
         GeckoAppShell.getEventDispatcher().registerEventListener("Gecko:Ready", this);
     }
 
     private String initGeckoEnvironment() {
         // 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();
@@ -122,53 +106,51 @@ public class GeckoThread extends Thread 
     public void run() {
         Looper.prepare();
         ThreadUtils.setGeckoThread(this, new Handler());
 
         String path = initGeckoEnvironment();
 
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");
 
-        String args = addCustomProfileArg(sArgs);
-        String type = getTypeFromAction(sAction != null ? sAction :
-                                        sUri != null ? Intent.ACTION_VIEW : Intent.ACTION_MAIN);
+        String args = addCustomProfileArg(mIntent.getStringExtra("args"));
+        String type = getTypeFromAction(mIntent.getAction());
+        mIntent = null;
 
         // and then fire us up
         Log.i(LOGTAG, "RunGecko - args = " + args);
-        GeckoAppShell.runGecko(path, args, sUri, type);
+        GeckoAppShell.runGecko(path, args, mUri, type);
     }
 
-    static Object sLock = new Object();
-
     @Override
     public void handleMessage(String event, JSONObject message) {
         if ("Gecko:Ready".equals(event)) {
             GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
             setLaunchState(LaunchState.GeckoRunning);
             GeckoAppShell.sendPendingEventsToGecko();
         }
     }
 
     public static boolean checkLaunchState(LaunchState checkState) {
-        synchronized (sLock) {
+        synchronized (sLaunchState) {
             return sLaunchState == checkState;
         }
     }
 
     static void setLaunchState(LaunchState setState) {
-        synchronized (sLock) {
+        synchronized (sLaunchState) {
             sLaunchState = setState;
         }
     }
 
     /**
      * Set the launch state to <code>setState</code> and return true if the current launch
      * state is <code>checkState</code>; otherwise do nothing and return false.
      */
     static boolean checkAndSetLaunchState(LaunchState checkState, LaunchState setState) {
-        synchronized (sLock) {
+        synchronized (sLaunchState) {
             if (sLaunchState != checkState)
                 return false;
             sLaunchState = setState;
             return true;
         }
     }
 }
--- a/mobile/android/base/GeckoView.java
+++ b/mobile/android/base/GeckoView.java
@@ -23,42 +23,47 @@ import android.os.Bundle;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
 import android.os.Handler;
 
 public class GeckoView extends LayerView
     implements GeckoEventListener, ContextGetter {
+    static GeckoThread sGeckoThread;
 
     public GeckoView(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GeckoView);
         String url = a.getString(R.styleable.GeckoView_url);
         a.recycle();
 
-        if (url != null) {
-            GeckoThread.setStartupArgs(url, null, null);
+        Intent intent;
+        if (url == null) {
+            intent = new Intent(Intent.ACTION_MAIN);
+        } else {
+            intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
             GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(url));
         }
         GeckoAppShell.setContextGetter(this);
         if (context instanceof Activity) {
             Tabs tabs = Tabs.getInstance();
             tabs.attachToActivity((Activity) context);
         }
         GeckoProfile profile = GeckoProfile.get(context);
         BrowserDB.initialize(profile.getName());
         GeckoAppShell.registerEventListener("Gecko:Ready", this);
 
+        sGeckoThread = new GeckoThread(intent, url);
         ThreadUtils.setUiThread(Thread.currentThread(), new Handler());
         initializeView(GeckoAppShell.getEventDispatcher());
-        GeckoAppShell.setLayerView(this);
         if (GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.Launching, GeckoThread.LaunchState.Launched)) {
-            GeckoThread.getInstance().start();
+            GeckoAppShell.setLayerView(this);
+            sGeckoThread.start();
         }
     }
 
     @Override
     public void onWindowFocusChanged(boolean hasFocus) {
         super.onWindowFocusChanged(hasFocus);
 
         if (hasFocus) {
--- a/mobile/android/base/resources/layout/shared_ui_components.xml
+++ b/mobile/android/base/resources/layout/shared_ui_components.xml
@@ -3,19 +3,19 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <!-- This file is used to include shared UI components in different gecko app
      layouts, such as gecko_app.xml and web_app.xml -->
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <org.mozilla.gecko.GeckoView android:id="@+id/layer_view"
-                                 android:layout_width="fill_parent"
-                                 android:layout_height="fill_parent"/>
+    <org.mozilla.gecko.gfx.LayerView android:id="@+id/layer_view"
+                                     android:layout_width="fill_parent"
+                                     android:layout_height="fill_parent"/>
 
     <AbsoluteLayout android:id="@+id/plugin_container"
                     android:background="@android:color/transparent"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"/>
 
     <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
                                        android:layout_width="fill_parent"