Bug 1238763 - Part 1: Don't run onPromptFinished on the UI thread. r=liuche draft
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 12 Jan 2016 12:07:07 -0800
changeset 321001 5edd4db1d1307e508f172d8c97f3096cccb16672
parent 321000 1f27320505b3c2e62b2d30919408b041b50fb1bf
child 512844 f198f9ae21c9cf42266a685f1eeab45ec3c297cf
push id9318
push userahunt@mozilla.com
push dateTue, 12 Jan 2016 20:08:32 +0000
reviewersliuche
bugs1238763
milestone46.0a1
Bug 1238763 - Part 1: Don't run onPromptFinished on the UI thread. r=liuche
mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
@@ -477,30 +477,35 @@ public class Prompt implements OnClickLi
         addInputValues(ret);
 
         notifyClosing(ret);
     }
 
     /* Called any time we're closing the dialog to cleanup and notify listeners that the dialog
      * is closing.
      */
-    private void notifyClosing(JSONObject aReturn) {
+    private void notifyClosing(final JSONObject aReturn) {
         try {
             aReturn.put("guid", mGuid);
         } catch(JSONException ex) { }
 
         if (mTabId != Tabs.INVALID_TAB_ID) {
             Tabs.unregisterOnTabsChangedListener(this);
         }
 
         // poke the Gecko thread in case it's waiting for new events
         GeckoAppShell.sendEventToGecko(GeckoEvent.createNoOpEvent());
 
         if (mCallback != null) {
-            mCallback.onPromptFinished(aReturn.toString());
+            ThreadUtils.postToBackgroundThread(new Runnable() {
+                @Override
+                public void run() {
+                    mCallback.onPromptFinished(aReturn.toString());
+                }
+            });
         }
     }
 
     // Called when the prompt inputs on the dialog change
     @Override
     public void onChange(PromptInput input) {
         // If there are no buttons on this dialog, assuming that "changing" an input
         // means something was selected and we can close. This provides a way to tap