Last Comment Bug 769894 - java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] mainly on ICS and above
: java.lang.IllegalStateException: Hardware acceleration can only be used with ...
Status: VERIFIED FIXED
[native-crash][startupcrash]
: crash, topcrash
Product: Firefox for Android
Classification: Client Software
Component: General (show other bugs)
: 14 Branch
: ARM Android
-- critical (vote)
: Firefox 18
Assigned To: Chris Peterson [:cpeterson]
:
: Sebastian Kaspari (:sebastian)
Mentors:
Depends on: 786312 790180
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-29 23:53 PDT by Scoobidiver (away)
Modified: 2016-07-29 14:26 PDT (History)
10 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
affected
+
affected
+
fixed
fixed
fixed
+


Attachments
part-1-create-dialog-on-UI-thread.patch (2.14 KB, patch)
2012-09-04 15:22 PDT, Chris Peterson [:cpeterson]
mark.finkle: review+
akeybl: approval‑mozilla‑aurora+
akeybl: approval‑mozilla‑beta+
lukasblakk+bugs: approval‑mozilla‑release+
Details | Diff | Splinter Review
part-2-assert-on-UI-thread.patch (2.48 KB, patch)
2012-09-04 15:26 PDT, Chris Peterson [:cpeterson]
mark.finkle: review+
akeybl: approval‑mozilla‑aurora+
akeybl: approval‑mozilla‑beta+
Details | Diff | Splinter Review
part-3-skip-some-ifs.patch (1.53 KB, patch)
2012-09-04 15:31 PDT, Chris Peterson [:cpeterson]
mark.finkle: review+
akeybl: approval‑mozilla‑aurora+
akeybl: approval‑mozilla‑beta+
Details | Diff | Splinter Review

Description User image Scoobidiver (away) 2012-06-29 23:53:07 PDT
It's #102 top crasher in 14.0 and occurs on Galaxy Nexus at startup. Here is a crash report: bp-477a2184-fa24-4504-8862-e650a2120627.

java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread.
Original thread: Thread[main,5,main]
Current thread: Thread[GeckoBackgroundThread,5,main]
	at android.view.HardwareRenderer$GlRenderer.checkCurrent(HardwareRenderer.java:1246)
	at android.view.HardwareRenderer$Gl20Renderer.safelyRun(HardwareRenderer.java:1444)
	at android.view.HardwareRenderer$Gl20Renderer.destroyHardwareResources(HardwareRenderer.java:1468)
	at android.view.ViewRootImpl.destroyHardwareRenderer(ViewRootImpl.java:4005)
	at android.view.ViewRootImpl.die(ViewRootImpl.java:3939)
	at android.view.WindowManagerImpl.removeViewLocked(WindowManagerImpl.java:402)
	at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:350)
	at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
	at android.app.Dialog.dismissDialog(Dialog.java:319)
	at android.app.Dialog$1.run(Dialog.java:119)
	at android.os.Handler.handleCallback(Handler.java:615)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at org.mozilla.gecko.GeckoBackgroundThread.run(GeckoBackgroundThread.java:31)

More reports at:
https://crash-stats.mozilla.com/report/list?signature=java.lang.IllegalStateException%3A+Hardware+acceleration+can+only+be+used+with+a+single+UI+thread.+Original+thread%3A+Thread[main%2C5%2Cmain]
Comment 1 User image Scoobidiver (away) 2012-06-30 00:02:16 PDT
It has appeared after Google I/O 2012.
Comment 2 User image Scoobidiver (away) 2012-07-19 09:25:21 PDT
Naoki, see bug 703102.
Comment 3 User image Robert Kaiser 2012-07-19 09:48:36 PDT
This seems to be almost exclusively Galaxy Nexus.
Of 101 crash reports on 14.* release yesterday, this is the device split:
Samsung Galaxy Nexus 	97
Motorola Xoom 	1
Motorola MZ601 	1
Asus Nexus 7 	1
Amazon Kindle Fire 	1
Comment 4 User image Scoobidiver (away) 2012-08-08 14:30:04 PDT
It's currently #1 top crasher in 14.0.2.
Comment 5 User image Scoobidiver (away) 2012-08-09 01:03:57 PDT
(In reply to Scoobidiver from comment #4)
> It's currently #1 top crasher in 14.0.2.
14.0.2 is restricted to JB, so it's only #1 on JB.
Comment 6 User image Naoki Hirata :nhirata (please use needinfo instead of cc) 2012-08-09 09:19:15 PDT
Marking QAwanted for repro steps; most likely just have to turn on hardware acceleration?

No URL listed.

Also ADU is low...

226 crashes	5,072 ADI  = 4.46
23 crashes	257 ADI = 8.95%
Comment 7 User image Chris Peterson [:cpeterson] 2012-08-23 14:14:13 PDT
The problem is that, somehow, a Dialog message was posted to our GeckoBackgroundThread's Handler. This suggests we might be spawning an AsyncTask from GeckoBackgroundThread (which is bad) or we might be confusing GeckoAppShell's getHandler/getGeckoHandler/getMainHandler when posting a UI event.

Sriram, do any of those problems sound familiar?
Comment 8 User image Sriram Ramasubramanian [:sriram] 2012-08-23 14:51:37 PDT
The only place where the dialog dismissal can happen on background thread is PromptService. I'll post a patch soonish.
Comment 9 User image Scoobidiver (away) 2012-08-29 02:06:02 PDT
It's #1 top crasher in the first day of 15.0 with many dupes.
Comment 10 User image Chris Peterson [:cpeterson] 2012-08-29 16:59:01 PDT
Sriram, we should try uplift your PromptService patch to Beta 16 (or even Firefox 15).
Comment 12 User image Lukas Blakk [:lsblakk] use ?needinfo 2012-09-04 09:13:57 PDT
(In reply to Chris Peterson (:cpeterson) from comment #10)
> Sriram, we should try uplift your PromptService patch to Beta 16 (or even
> Firefox 15).

We might be able to take a fix for this as a ride-along in a 15.0 chemspill -- do you have a patch ready? Can we get a build to test?
Comment 13 User image Brad Lassey [:blassey] (use needinfo?) 2012-09-04 11:46:51 PDT
*** Bug 788216 has been marked as a duplicate of this bug. ***
Comment 14 User image Chris Peterson [:cpeterson] 2012-09-04 14:30:53 PDT
Sriram and I discussed this bug before we went on PTO. I am testing a possible fix now.
Comment 15 User image Chris Peterson [:cpeterson] 2012-09-04 15:22:54 PDT
Created attachment 658259 [details] [diff] [review]
part-1-create-dialog-on-UI-thread.patch

Part 1: Create PromptService's AlertDialog on the UI thread.

PromptService.handleMessage() is called on the Gecko thread. It posts a runnable to call PromptService.processMessage() on the GeckoBackgroundThread, but this causes PromptService.show() to create the AlertDialog on the GeckoBackgroundThread. The AlertDialog must be created on the UI thread, so I changed show()() to post the AlertDialog creation to UI thread.

A simpler solution would be for PromptService.handleMessage() to post processMessage() to the UI thread directly, skipping GeckoBackgroundThread. But that would move some possibly expensive operations (JSON parsing and layout inflation) to the UI thread.
Comment 16 User image Chris Peterson [:cpeterson] 2012-09-04 15:26:15 PDT
Created attachment 658265 [details] [diff] [review]
part-2-assert-on-UI-thread.patch

Part 2: Assert that PromptService's AlertDialog is called back on the UI thread.

I plan to uplift patch 1 to Aurora, Beta, and/or Release, so I separated this non-essential debugging code into a separate patch 2. I won't uplift patch 2.
Comment 17 User image Chris Peterson [:cpeterson] 2012-09-04 15:31:03 PDT
Created attachment 658267 [details] [diff] [review]
part-3-skip-some-ifs.patch

Part 3: Skip some unnecessary conditional code when creating PromptService's AlertDialog.

This patch is a trivial micro-optimization.
Comment 18 User image Mark Finkle (:mfinkle) (use needinfo?) 2012-09-04 18:53:46 PDT
Comment on attachment 658259 [details] [diff] [review]
part-1-create-dialog-on-UI-thread.patch

>diff --git a/mobile/android/base/PromptService.java b/mobile/android/base/PromptService.java

>+        final OnCancelListener this_ = this;

nit: Can you rename this_ to self ?
Comment 19 User image Kartikaya Gupta (email:kats@mozilla.com) 2012-09-05 05:04:19 PDT
You can also use PromptService.this from inside the runnable to reference the outer class directly.
Comment 20 User image Mark Finkle (:mfinkle) (use needinfo?) 2012-09-05 05:32:44 PDT
(In reply to Kartikaya Gupta (:kats) from comment #19)
> You can also use PromptService.this from inside the runnable to reference
> the outer class directly.

Damn, I was looking for that style but failed to find confirmation about it.

Yes! Use this style please!
Comment 21 User image Alex Keybl [:akeybl] 2012-09-05 09:35:35 PDT
Comment on attachment 658259 [details] [diff] [review]
part-1-create-dialog-on-UI-thread.patch

Since we're considering this for FF15.0.1 inclusion, a=akeybl for landing on Aurora/Beta.
Comment 22 User image Chris Peterson [:cpeterson] 2012-09-05 09:38:39 PDT
Comment on attachment 658259 [details] [diff] [review]
part-1-create-dialog-on-UI-thread.patch

[Approval Request Comment]
Regression caused by (bug #): bug 694455
User impact if declined: This is the #1 topcrash for Firefox 15.
Testing completed (on m-c, etc.): Tested locally
Risk to taking this patch (and alternatives if risky): Low risk. alert() dialogs are already crashing, so this patch can't make it much worse. :)

Patch part 2 and 3 do NOT need to be uplifted. They are extra cleanups that are not necessary to fix the crash.
Comment 23 User image Chris Peterson [:cpeterson] 2012-09-05 11:41:08 PDT
Landed patch 1 on m-c:
https://hg.mozilla.org/mozilla-central/rev/647fabcaa951

I will land patch 2 and 3 on m-i later. They are extra cleanups that are not necessary to fix the crash.
Comment 24 User image Chris Peterson [:cpeterson] 2012-09-05 11:54:49 PDT
https://hg.mozilla.org/releases/mozilla-aurora/rev/39133328b86b
Comment 25 User image Chris Peterson [:cpeterson] 2012-09-05 11:56:12 PDT
https://hg.mozilla.org/releases/mozilla-beta/rev/db28559df995
Comment 26 User image Chris Peterson [:cpeterson] 2012-09-05 13:13:31 PDT
https://hg.mozilla.org/releases/mozilla-release/rev/fa4a5f9a0081
Comment 27 User image Scoobidiver (away) 2012-09-05 13:53:20 PDT
The target milestone is the m-c version.
Comment 28 User image Chris Peterson [:cpeterson] 2012-09-06 11:32:58 PDT
Landed patches 2 and 3 on m-i. These follow-on patches do not need to be uplifted to m-a+.

https://hg.mozilla.org/integration/mozilla-inbound/rev/06fef017a420
https://hg.mozilla.org/integration/mozilla-inbound/rev/58be0a04c3c4
Comment 30 User image Scoobidiver (away) 2012-09-07 12:33:03 PDT
There's one crash in 16.0b2(build2) that contains the fix: bp-6a9fc4ce-7d1d-4d18-bf68-865fd2120907.
Comment 31 User image Chris Peterson [:cpeterson] 2012-09-07 14:10:34 PDT
(In reply to Scoobidiver from comment #30)
> There's one crash in 16.0b2(build2) that contains the fix:
> bp-6a9fc4ce-7d1d-4d18-bf68-865fd2120907.

Beta 16.0b2 (20120906211157) does not have my fix. I checked the archived sources on ftp.mozilla.org. Build 20120906211157's creation date is after I landed my m-b fix, so I assume that build was snapped before my fix but finished building after my fix.

This crash is not a beta topcrash, so I think waiting for next week's Beta 16.0b3 to pick up my fix is not a big problem.
Comment 32 User image Scoobidiver (away) 2012-09-11 02:25:49 PDT
It's #3 top crasher in 15.0.1.
Comment 33 User image Chris Peterson [:cpeterson] 2012-09-11 10:28:19 PDT
The patch for this bug fixed *a* bug, but it was mostly speculation by Sriram and me that it was the exact stack trace in this crash report.

Sriram, do you have any other ideas why a dialog would be running on our GeckoBackgroundThread?
Comment 34 User image Chris Peterson [:cpeterson] 2012-09-17 12:48:32 PDT
I posted a patch on bug 786312 that should fix this bug.
Comment 35 User image Chris Peterson [:cpeterson] 2012-09-17 17:31:05 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/9980650215af
Comment 36 User image Scoobidiver (away) 2012-09-18 05:56:11 PDT
https://hg.mozilla.org/mozilla-central/rev/9980650215af
Comment 38 User image Scoobidiver (away) 2012-09-22 00:05:26 PDT
There are still crashes in 16.0b4.
Comment 39 User image Kevin Brosnan [:kbrosnan] 2013-01-02 11:26:27 PST
No crashes listed in the last 4 weeks verifying this.

Note You need to log in before you can comment on or make changes to this bug.