Closed Bug 769894 Opened 12 years ago Closed 12 years ago

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

Categories

(Firefox for Android Graveyard :: General, defect)

14 Branch
ARM
Android
defect
Not set
critical

Tracking

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

VERIFIED FIXED
Firefox 18
Tracking Status
firefox14 --- affected
firefox15 + affected
firefox16 + fixed
firefox17 --- fixed
firefox18 --- fixed
fennec + ---

People

(Reporter: scoobidiver, Assigned: cpeterson)

References

Details

(Keywords: crash, topcrash, Whiteboard: [native-crash][startupcrash])

Crash Data

Attachments

(3 files)

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]
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 thread:…
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:… → [@ java.lang.IllegalStateException: Hardware acceleration can only be used with a single UI thread. Original thread: Thread[main,5,main]]
Naoki, see bug 703102.
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
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
(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
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
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?
The only place where the dialog dismissal can happen on background thread is PromptService. I'll post a patch soonish.
It's #1 top crasher in the first day of 15.0 with many dupes.
Sriram, we should try uplift your PromptService patch to Beta 16 (or even Firefox 15).
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?
Sriram and I discussed this bug before we went on PTO. I am testing a possible fix now.
Assignee: sriram → cpeterson
Status: NEW → ASSIGNED
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)
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)
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+
Attachment #658265 - Flags: approval-mozilla-beta+
Attachment #658265 - Flags: approval-mozilla-aurora+
Attachment #658267 - Flags: approval-mozilla-beta+
Attachment #658267 - Flags: approval-mozilla-aurora+
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+
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
Closed: 12 years ago
Resolution: --- → FIXED
The target milestone is the m-c version.
Target Milestone: Firefox 15 → Firefox 18
Keywords: qawanted
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
There's one crash in 16.0b2(build2) that contains the fix: bp-6a9fc4ce-7d1d-4d18-bf68-865fd2120907.
(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.
Depends on: 789572
No longer depends on: 789572
It's #3 top crasher in 15.0.1.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Depends on: 790180
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: ? → +
I posted a patch on bug 786312 that should fix this bug.
Depends on: 786312
https://hg.mozilla.org/mozilla-central/rev/9980650215af
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
There are still crashes in 16.0b4.
No crashes listed in the last 4 weeks verifying this.
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: