bug 674245 - App crashes when device switches its orientation from portrait to landscape and reversal for several times r=dougt
authorBrad Lassey <blassey@mozilla.com>
Tue, 26 Jul 2011 12:12:36 -0400
changeset 73415 0d37af9e506f6eaa1a8e7c627ccb0335becc0d9a
parent 73414 38e2e8f4b0b2792de83342d39af50436d7f8bbea
child 73416 54b8ca3b0c7ac0ab4c8c48909f5f9c9aeb28d488
push id20861
push usereakhgari@mozilla.com
push dateWed, 27 Jul 2011 18:02:44 +0000
treeherdermozilla-central@32c49de2fe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs674245
milestone8.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 674245 - App crashes when device switches its orientation from portrait to landscape and reversal for several times r=dougt
embedding/android/GeckoApp.java
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -78,16 +78,17 @@ abstract public class GeckoApp
     public Handler mMainHandler;
     private IntentFilter mConnectivityFilter;
     private BroadcastReceiver mConnectivityReceiver;
     private PhoneStateListener mPhoneStateListener;
 
     enum LaunchState {PreLaunch, Launching, WaitButton,
                       Launched, GeckoRunning, GeckoExiting};
     private static LaunchState sLaunchState = LaunchState.PreLaunch;
+    private static boolean sTryCatchAttached = false;
 
 
     static boolean checkLaunchState(LaunchState checkState) {
         synchronized(sLaunchState) {
             return sLaunchState == checkState;
         }
     }
 
@@ -183,28 +184,33 @@ abstract public class GeckoApp
 
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
         mAppContext = this;
         mMainHandler = new Handler();
 
-        mMainHandler.post(new Runnable() {
-            public void run() {
-                try {
-                    Looper.loop();
-                } catch (Exception e) {
-                    Log.e("GeckoApp", "top level exception", e);
-                    StringWriter sw = new StringWriter();
-                    e.printStackTrace(new PrintWriter(sw));
-                    GeckoAppShell.reportJavaCrash(sw.toString());
+        if (!sTryCatchAttached) {
+            sTryCatchAttached = true;
+            mMainHandler.post(new Runnable() {
+                public void run() {
+                    try {
+                        Looper.loop();
+                    } catch (Exception e) {
+                        Log.e("GeckoApp", "top level exception", e);
+                        StringWriter sw = new StringWriter();
+                        e.printStackTrace(new PrintWriter(sw));
+                        GeckoAppShell.reportJavaCrash(sw.toString());
+                    }
+                    // resetting this is kinda pointless, but oh well
+                    sTryCatchAttached = false;
                 }
-            }
-        });
+            });
+        }
 
         SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
         String localeCode = settings.getString(getPackageName() + ".locale", "");
         if (localeCode != null && localeCode.length() > 0)
             GeckoAppShell.setSelectedLocale(localeCode);
 
         Log.i("GeckoApp", "create");
         super.onCreate(savedInstanceState);