java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread <n> ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java)

VERIFIED FIXED in Firefox 16

Status

()

Firefox for Android
General
P1
critical
VERIFIED FIXED
5 years ago
5 years ago

People

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

Tracking

(Blocks: 1 bug, {crash, regression, reproducible})

16 Branch
Firefox 18
ARM
Android
crash, regression, reproducible
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(firefox16 fixed, firefox17 verified, firefox18 verified, firefox19 verified, firefox20 verified)

Details

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

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
There's one crash in 18.0a1/20120919: bp-249094c2-7759-4ef3-817d-5f49c2120920.

java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread)
	at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java:2658)
	at org.mozilla.gecko.GeckoApp.assertOnUiThread(GeckoApp.java:2645)
	at org.mozilla.gecko.PromptService.show(PromptService.java:186)
	at org.mozilla.gecko.ActivityHandlerHelper$FilePickerPromptRunnable.run(ActivityHandlerHelper.java:240)
	at android.os.Handler.handleCallback(Handler.java:587)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:130)
	at org.mozilla.gecko.util.GeckoBackgroundThread.run(GeckoBackgroundThread.java:31)

More reports at:
https://crash-stats.mozilla.com/report/list?signature=java.lang.IllegalThreadStateException%3A+Expected+thread+1+%28%22main%22%29%2C+but+running+on+thread+9+%28%22GeckoBackgroundThread%29+at+org.mozilla.gecko.GeckoApp.assertOnThread%28GeckoApp.java%29
(Assignee)

Comment 1

5 years ago
kats, I think the FilePickerPromptRunnable should be posted to the UI thread' GeckoAppShell.getMainHandler(), not the GeckoBackgroundThread's GeckoAppShell.getHandler():

https://hg.mozilla.org/mozilla-central/annotate/6a2d1a3556b9/mobile/android/base/ActivityHandlerHelper.java#l151

I think we should rename these GeckoAppShell Handler getters to something clearer like getUiThreadHandler() and getBackgroundThreadHandler() (and remove getGeckoHandler() because it is not used).
Priority: -- → P2
Sounds reasonable to me. Do you want me to do it or will you?
(Assignee)

Comment 3

5 years ago
I can fix the crash, since I added the assertOnUiThread() call when fixing a related PromptService bug. :)

Aurora 17 and Beta 16 don't call assertOnUiThread() here, but they still have the bug. This bug is likely contributing to the CalledFromWrongThreadException topcrashes.
Assignee: nobody → cpeterson
Status: NEW → ASSIGNED
Priority: P2 → P1
(Assignee)

Comment 4

5 years ago
STR:
1. Load http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_type_file
2. Press "Browse..." button
3. Choose a file
4. CRASH!
status-firefox18: --- → affected
Keywords: reproducible
(Assignee)

Comment 5

5 years ago
Created attachment 663128 [details] [diff] [review]
post-FilePicker-to-UI-thread.patch

Post FilePicker dialog to UI thread, not GeckoBackgroundThread.
Attachment #663128 - Flags: review?(bugmail.mozilla)
(Assignee)

Updated

5 years ago
Blocks: 792973
(Assignee)

Comment 6

5 years ago
btw, my fix reveals a bunch of FilePicker StrictMode warnings. I confirmed that these warnings at not a regression from my patch, so I filed new bug 792973.
Attachment #663128 - Flags: review?(bugmail.mozilla) → review+
(Assignee)

Comment 7

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/dbed92805ae7
status-firefox18: affected → fixed
Target Milestone: --- → Firefox 18
(Assignee)

Updated

5 years ago
Blocks: 786312
(Assignee)

Comment 8

5 years ago
Comment on attachment 663128 [details] [diff] [review]
post-FilePicker-to-UI-thread.patch

[Approval Request Comment]
Bug caused by (feature/regressing bug #): bug 786312
User impact if declined: Nightly 18 has 100% repro crashes when trying to use FilePicker (e.g. Bugzilla attachment). Aurora 17 and Beta 16 don't immediately crash here, but they still have the logic bug. This bug is likely contributing to 17 and 16's CalledFromWrongThreadException topcrashes.
Testing completed (on m-c, etc.): Tested locally with 100% STR
Risk to taking this patch (and alternatives if risky): Low risk. Android-only java one-liner. Some UI code was running on a background thread, but it should only run on the UI thread.
String or UUID changes made by this patch: N/A
Attachment #663128 - Flags: approval-mozilla-beta?
Attachment #663128 - Flags: approval-mozilla-aurora?
(Reporter)

Updated

5 years ago
Keywords: regression
Version: Trunk → Firefox 16
(Reporter)

Updated

5 years ago
Crash Signature: [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java)] → [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java)] [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"&hellip;
Summary: java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java) → java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread <n> ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java)
(Reporter)

Updated

5 years ago
Crash Signature: [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java)] [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"&hellip; → [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main"), but running on thread 9 ("GeckoBackgroundThread) at org.mozilla.gecko.GeckoApp.assertOnThread(GeckoApp.java) ] [@ java.lang.IllegalThreadStateException: Expected thread 1 ("main&hellip;
Triage drive-by:  Likely we can take this on Monday if it has been landed on trunk before then without any known fallout.
(Assignee)

Comment 10

5 years ago
(In reply to Lukas Blakk [:lsblakk] from comment #9)
> Triage drive-by:  Likely we can take this on Monday if it has been landed on
> trunk before then without any known fallout.

I am testing a band-aid fix now.
(Assignee)

Comment 11

5 years ago
^ oops! My comment about a "band-aid fix" was intended for bug 747629, not this bug! <:)
https://hg.mozilla.org/mozilla-central/rev/dbed92805ae7
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
(Assignee)

Comment 13

5 years ago
Comment on attachment 663128 [details] [diff] [review]
post-FilePicker-to-UI-thread.patch

(In reply to Lukas Blakk [:lsblakk] from comment #9)
> Triage drive-by:  Likely we can take this on Monday if it has been landed on
> trunk before then without any known fallout.

lsblakk, renomming for aurora? and beta?

I landed my patch on 09-21, so the first build to include my fix was 09-22. Before my fix, I see about a dozen crash reports in builds 09-20 and 09-21. After my fix, I see no crash reports in builds 09-22, 09-23, or 09-24.
Attachment #663128 - Flags: approval-mozilla-beta?
Attachment #663128 - Flags: approval-mozilla-beta+
Attachment #663128 - Flags: approval-mozilla-aurora?
Attachment #663128 - Flags: approval-mozilla-aurora+
status-firefox16: --- → affected
status-firefox17: --- → affected
(Assignee)

Comment 14

5 years ago
https://hg.mozilla.org/releases/mozilla-aurora/rev/628cc50702f8
https://hg.mozilla.org/releases/mozilla-beta/rev/c085464581b6
status-firefox16: affected → fixed
status-firefox17: affected → fixed
This crash doesn't occur on any branch if I perform the STR from comment #4. Closing bug as verified fixed on:

Firefox 20.0a1 (2012-11-21)
Device: Galaxy S2
OS: Android 4.0.3
Status: RESOLVED → VERIFIED
status-firefox17: fixed → verified
status-firefox18: fixed → verified
status-firefox19: --- → verified
status-firefox20: --- → verified
You need to log in before you can comment on or make changes to this bug.