bug 621484 - Hang at org.mozilla.gecko.GeckoInputConnection.getExtractedText(GeckoInputConnection.java:252 r=vlad a=blocking-fennec
authorBrad Lassey <blassey@mozilla.com>
Tue, 28 Dec 2010 15:55:47 -0500
changeset 59710 b016aa1878fa02eed7e1828e49400c02f17311d9
parent 59709 9365fe1a31650bb825107a60991c04c0a79abb26
child 59711 2a25c4d1ed991b232623523b4e08ce46bddaff7e
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersvlad, blocking-fennec
bugs621484
milestone2.0b9pre
bug 621484 - Hang at org.mozilla.gecko.GeckoInputConnection.getExtractedText(GeckoInputConnection.java:252 r=vlad a=blocking-fennec
embedding/android/GeckoAppShell.java
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -59,17 +59,18 @@ import android.location.*;
 import android.util.*;
 import android.net.Uri;
 
 class GeckoAppShell
 {
     // static members only
     private GeckoAppShell() { }
 
-    static private GeckoEvent gPendingResize = null;
+    static private LinkedList<GeckoEvent> gPendingEvents =
+        new LinkedList<GeckoEvent>();
 
     static private boolean gRestartScheduled = false;
 
     static private final Timer mIMETimer = new Timer();
     static private final HashMap<Integer, AlertNotification>
          mAlertNotifications = new HashMap<Integer, AlertNotification>();
 
     static private final int NOTIFY_IME_RESETINPUTSTATE = 0;
@@ -138,26 +139,30 @@ class GeckoAppShell
         if (url != null)
             combinedArgs += " " + url;
         // and go
         GeckoAppShell.nativeRun(combinedArgs);
     }
 
     private static GeckoEvent mLastDrawEvent;
 
+    private static void sendPendingEventsToGecko() {
+        try {
+            while (!gPendingEvents.isEmpty()) {
+                GeckoEvent e = gPendingEvents.removeFirst();
+                notifyGeckoOfEvent(e);
+            }
+        } catch (NoSuchElementException e) {}
+    }
+ 
     public static void sendEventToGecko(GeckoEvent e) {
         if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) {
-            if (gPendingResize != null) {
-                notifyGeckoOfEvent(gPendingResize);
-                gPendingResize = null;
-            }
             notifyGeckoOfEvent(e);
         } else {
-            if (e.mType == GeckoEvent.SIZE_CHANGED)
-                gPendingResize = e;
+            gPendingEvents.addLast(e);
         }
     }
 
     // Tell the Gecko event loop that an event is available.
     public static native void notifyGeckoOfEvent(GeckoEvent event);
 
     /*
      *  The Gecko-side API: API methods that Gecko calls
@@ -330,20 +335,17 @@ class GeckoAppShell
         } catch (InterruptedException e) {
         }
     }
 
     static void onAppShellReady()
     {
         // mLaunchState can only be Launched at this point
         GeckoApp.setLaunchState(GeckoApp.LaunchState.GeckoRunning);
-        if (gPendingResize != null) {
-            notifyGeckoOfEvent(gPendingResize);
-            gPendingResize = null;
-        }
+        sendPendingEventsToGecko();
     }
 
     static void onXreExit() {
         // mLaunchState can only be Launched or GeckoRunning at this point
         GeckoApp.setLaunchState(GeckoApp.LaunchState.GeckoExiting);
         Log.i("GeckoAppJava", "XRE exited");
         if (gRestartScheduled) {
             GeckoApp.mAppContext.doRestart();