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

VERIFIED FIXED in Firefox 16

Status

()

Firefox for Android
General
--
critical
VERIFIED FIXED
5 years ago
9 months ago

People

(Reporter: Scoobidiver (away), Assigned: cpeterson)

Tracking

({crash, topcrash})

14 Branch
Firefox 18
ARM
Android
crash, topcrash
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox14 affected, firefox15+ affected, firefox16+ fixed, firefox17 fixed, firefox18 fixed, fennec+)

Details

(Whiteboard: [native-crash][startupcrash], crash signature)

Attachments

(3 attachments)

(Reporter)

Description

5 years ago
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]
(Reporter)

Comment 1

5 years ago
It has appeared after Google I/O 2012.
Summary: java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] on Galaxy Nexus → java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] on Galaxy Nexus with Jelly Bean
Crash Signature: [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main]] → [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5 main]] [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original …

Updated

5 years ago
Crash Signature: [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5 main]] [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original … → [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main]]
(Reporter)

Comment 2

5 years ago
Naoki, see bug 703102.

Comment 3

5 years ago
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
(Reporter)

Comment 4

5 years ago
It's currently #1 top crasher in 14.0.2.
tracking-fennec: --- → ?
Keywords: topcrash
Summary: java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] on Galaxy Nexus with Jelly Bean → java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] on Galaxy Nexus mainly on JB
(Reporter)

Comment 5

5 years ago
(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.
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%
Keywords: qawanted
(Reporter)

Updated

5 years ago
Summary: java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main] on Galaxy Nexus mainly on JB → 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
(Assignee)

Comment 7

5 years ago
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?
status-firefox14: --- → affected
The only place where the dialog dismissal can happen on background thread is PromptService. I'll post a patch soonish.
(Reporter)

Comment 9

5 years ago
It's #1 top crasher in the first day of 15.0 with many dupes.
status-firefox15: --- → affected
(Assignee)

Comment 10

5 years ago
Sriram, we should try uplift your PromptService patch to Beta 16 (or even Firefox 15).
tracking-firefox15: --- → +
status-firefox16: --- → affected
tracking-firefox16: --- → +
(Assignee)

Comment 11

5 years ago
Here is the correct "More reports" link. Bugzilla did not include the trailing ']' character when it auto-linked the original URL, so I have URL-encoded it here:

https://crash-stats.mozilla.com/report/list?query_search=signature&query_type=contains&reason_type=contains&range_value=3&range_unit=weeks&hang_type=any&process_type=any&signature=java.lang.IllegalStateException%3A%20Hardware%20acceleration%20can%20only%20be%20used%20with%20a%20single%20UI%20thread.%20Original%20thread%3A%20Thread[main%2C5%2Cmain%5D

Updated

5 years ago
Assignee: nobody → sriram
(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?
Duplicate of this bug: 788216
(Assignee)

Comment 14

5 years ago
Sriram and I discussed this bug before we went on PTO. I am testing a possible fix now.
Assignee: sriram → cpeterson
Status: NEW → ASSIGNED
(Assignee)

Comment 15

5 years ago
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.
Attachment #658259 - Flags: review?(mark.finkle)
(Assignee)

Comment 16

5 years ago
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.
Attachment #658265 - Flags: review?(mark.finkle)
(Assignee)

Comment 17

5 years ago
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.
Attachment #658267 - Flags: review?(mark.finkle)
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 ?
Attachment #658259 - Flags: review?(mark.finkle) → review+
Attachment #658265 - Flags: review?(mark.finkle) → review+
Attachment #658267 - Flags: review?(mark.finkle) → review+
You can also use PromptService.this from inside the runnable to reference the outer class directly.
(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 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.
Attachment #658259 - Flags: approval-mozilla-beta+
Attachment #658259 - Flags: approval-mozilla-aurora+

Updated

5 years ago
Attachment #658265 - Flags: approval-mozilla-beta+
Attachment #658265 - Flags: approval-mozilla-aurora+

Updated

5 years ago
Attachment #658267 - Flags: approval-mozilla-beta+
Attachment #658267 - Flags: approval-mozilla-aurora+
(Assignee)

Comment 22

5 years ago
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.
Attachment #658259 - Flags: approval-mozilla-release?
Attachment #658259 - Flags: approval-mozilla-release? → approval-mozilla-release+
(Assignee)

Comment 23

5 years ago
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.
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
status-firefox18: --- → fixed
Resolution: --- → FIXED
(Assignee)

Comment 24

5 years ago
https://hg.mozilla.org/releases/mozilla-aurora/rev/39133328b86b
status-firefox17: --- → fixed
(Assignee)

Comment 25

5 years ago
https://hg.mozilla.org/releases/mozilla-beta/rev/db28559df995
status-firefox16: affected → fixed
(Assignee)

Comment 26

5 years ago
https://hg.mozilla.org/releases/mozilla-release/rev/fa4a5f9a0081
status-firefox15: affected → fixed
Target Milestone: --- → Firefox 15
(Reporter)

Comment 27

5 years ago
The target milestone is the m-c version.
Target Milestone: Firefox 15 → Firefox 18

Updated

5 years ago
Keywords: qawanted
(Assignee)

Comment 28

5 years ago
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
https://hg.mozilla.org/mozilla-central/rev/06fef017a420
https://hg.mozilla.org/mozilla-central/rev/58be0a04c3c4
(Reporter)

Comment 30

5 years ago
There's one crash in 16.0b2(build2) that contains the fix: bp-6a9fc4ce-7d1d-4d18-bf68-865fd2120907.
(Assignee)

Comment 31

5 years ago
(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.

Updated

5 years ago
Depends on: 789572
(Assignee)

Updated

5 years ago
No longer depends on: 789572
(Reporter)

Comment 32

5 years ago
It's #3 top crasher in 15.0.1.
Status: RESOLVED → REOPENED
status-firefox15: fixed → affected
Resolution: FIXED → ---
(Reporter)

Updated

5 years ago
Depends on: 790180
(Assignee)

Comment 33

5 years ago
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?
tracking-fennec: ? → +
(Assignee)

Comment 34

5 years ago
I posted a patch on bug 786312 that should fix this bug.
Depends on: 786312
(Assignee)

Comment 35

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/9980650215af
(Reporter)

Comment 36

5 years ago
https://hg.mozilla.org/mozilla-central/rev/9980650215af
Status: REOPENED → RESOLVED
Last Resolved: 5 years ago5 years ago
status-firefox16: fixed → affected
status-firefox17: fixed → affected
Resolution: --- → FIXED
(Assignee)

Comment 37

5 years ago
https://hg.mozilla.org/releases/mozilla-aurora/rev/541adb1639bb
https://hg.mozilla.org/releases/mozilla-beta/rev/4442bb93e91a
status-firefox17: affected → fixed
(Assignee)

Updated

5 years ago
status-firefox16: affected → fixed
(Reporter)

Comment 38

5 years ago
There are still crashes in 16.0b4.
No crashes listed in the last 4 weeks verifying this.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.