Bug 822755 - Don't process reply and always remove from action queue when processing stale actions; r=cpeterson
authorJim Chen <nchen@mozilla.com>
Wed, 26 Dec 2012 10:06:52 -0500
changeset 117045 d7b8336e01d12f4014f21af7afbdf50260f39cdc
parent 117044 1ab05052b3b579732742445876faffc49e2c02df
child 117046 7d531752a0fb293d9c40ab40f6d7b2a698c0fb55
push id20276
push usernchen@mozilla.com
push dateWed, 26 Dec 2012 15:13:46 +0000
treeherdermozilla-inbound@d6c5a0ec5757 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs822755
milestone20.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 822755 - Don't process reply and always remove from action queue when processing stale actions; r=cpeterson
mobile/android/base/GeckoEditable.java
--- a/mobile/android/base/GeckoEditable.java
+++ b/mobile/android/base/GeckoEditable.java
@@ -455,17 +455,17 @@ final class GeckoEditable
         if (update) {
             uiUpdateGecko(false);
         }
         mUpdateGecko = update;
     }
 
     // GeckoEditableListener interface
 
-    void geckoActionReply() {
+    private void geckoActionReply() {
         if (DEBUG) {
             // GeckoEditableListener methods should all be called from the Gecko thread
             GeckoApp.assertOnGeckoThread();
         }
         final Action action = mActionQueue.peek();
 
         switch (action.mType) {
         case Action.TYPE_SET_SELECTION:
@@ -496,27 +496,36 @@ final class GeckoEditable
             break;
         case Action.TYPE_SET_SPAN:
             mText.setSpan(action.mSpanObject, action.mStart, action.mEnd, action.mSpanFlags);
             break;
         }
         if (action.mShouldUpdate) {
             geckoUpdateGecko(false);
         }
-        mActionQueue.poll();
     }
 
     @Override
     public void notifyIME(final int type, final int state) {
         if (DEBUG) {
             // GeckoEditableListener methods should all be called from the Gecko thread
             GeckoApp.assertOnGeckoThread();
         }
         if (type == NOTIFY_IME_REPLY_EVENT) {
-            geckoActionReply();
+            try {
+                if (mFocused) {
+                    // When mFocused is false, the reply is for a stale action,
+                    // and we should not do anything
+                    geckoActionReply();
+                }
+            } finally {
+                // Ensure action is always removed from queue
+                // even if stale action results in exception in geckoActionReply
+                mActionQueue.poll();
+            }
             return;
         }
         geckoPostToUI(new Runnable() {
             public void run() {
                 // Make sure there are no other things going on
                 mActionQueue.syncWithGecko();
                 if (type == NOTIFY_IME_FOCUSCHANGE) {
                     if (state == IME_FOCUS_STATE_BLUR) {