Unable to open menu while gecko is busy; possibly results in ANR

VERIFIED FIXED in Firefox 20

Status

()

Firefox for Android
General
P2
normal
VERIFIED FIXED
5 years ago
5 years ago

People

(Reporter: kats, Assigned: jchen)

Tracking

19 Branch
Firefox 20
All
Android
Points:
---

Firefox Tracking Flags

(firefox20 verified)

Details

Attachments

(1 attachment)

On recent builds if I try to open the Fennec menu while gecko is busy, the fennec UI blocks on gecko and is unresponsive. This can result in the ANR dialog from Android in some cases. The ANR traces show that the main thread is blocked here:

"main" prio=5 tid=1 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x419489a0 self=0x4013e010
  | sysTid=11687 nice=0 sched=0/0 cgrp=apps handle=1075155932
  | state=S schedstat=( 0 0 0 ) utm=621 stm=186 core=0
  at java.lang.Object.wait(Native Method)
  - waiting on <0x41948da0> (a java.lang.VMThread) held by tid=1 (main)
  at java.lang.Thread.parkFor(Thread.java:1231)
  at sun.misc.Unsafe.park(Unsafe.java:323)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:159)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:810)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:940)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1258)
  at java.util.concurrent.Semaphore.acquireUninterruptibly(Semaphore.java:308)
  at org.mozilla.gecko.GeckoEditable$ActionQueue.syncWithGecko(GeckoEditable.java:228)
  at org.mozilla.gecko.GeckoEditable.invoke(GeckoEditable.java:621)
  at $Proxy0.length(Native Method)
  at android.view.inputmethod.BaseInputConnection.removeComposingSpans(BaseInputConnection.java:77)
  at android.view.inputmethod.BaseInputConnection.finishComposingText(BaseInputConnection.java:270)
  at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:1300)
  at android.view.inputmethod.InputMethodManager.onWindowFocus(InputMethodManager.java:1344)
  at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2934)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5039)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)
(Note that this is reproducible even on pages without any input boxes)
(Assignee)

Comment 2

5 years ago
Thanks kats. I think I know how to fix it.

Is there a more definite STR? Maybe a specific website?
Assignee: nobody → nchen
Status: NEW → ASSIGNED
Priority: -- → P2
The way I initially encountered it was:
1. Go to planet.mozilla.org
2. Turn on the "pinch to reflow text" option in the settings
3. Pinch to reflow
4. Immediately open the menu

The pinch to reflow takes a while and so opening the menu blocks. This was on a slow device (Motorola milestone) so it hit the ANR. Since then I was also able to reproduce this on my oom test page at http://people.mozilla.com/~kgupta/tmp/oom.html - this page allocates 100,000 divs every 5 seconds, so if you open and close the menu repeatedly while on that page within a few seconds you should hit one of the allocation periods and the menu will block.
(Assignee)

Comment 4

5 years ago
Created attachment 683831 [details] [diff] [review]
Don't perform IME sync when there is no focus (v1)

This patch skips IME synching when there is no focus. This does not impact any functionality because all GeckoEditable operations are effectively nops when there is no focus.

Unfortunately, when there is focus, synching is required and to alleviate this bug, this patch also prevents synching during removeSpan() calls which have no effect. removeSpan() seems to be the biggest culprit that's causing this bug.
Attachment #683831 - Flags: review?(cpeterson)
(Assignee)

Comment 5

5 years ago
kats: can you try this build on the Milestone? http://people.mozilla.org/~nchen/bug813602-fennec-20.0a1.apk

The patch should fix the bug, but I think the Milestone is the best device to verify that.
Comment on attachment 683831 [details] [diff] [review]
Don't perform IME sync when there is no focus (v1)

Review of attachment 683831 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #683831 - Flags: review?(cpeterson) → review+
(In reply to Jim Chen [:jchen :nchen] from comment #5)
> kats: can you try this build on the Milestone?
> http://people.mozilla.org/~nchen/bug813602-fennec-20.0a1.apk
> 

Yup, seems to work. Thanks for the quick fix!
https://hg.mozilla.org/mozilla-central/rev/249112c154d0
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 20
I cannot reproduce this issue on the latest Nightly using the STR from comment #3. Closing bug as verified fixed on:

Firefox 20.0a1 (2012-11-28)
Device: Galaxy Nexus
OS: Android 4.1.1
Status: RESOLVED → VERIFIED
status-firefox20: --- → verified
You need to log in before you can comment on or make changes to this bug.