Closed Bug 1412192 Opened 2 years ago Closed 2 years ago

Use main-thread JSContext in SystemZoneResource::IsAvailable

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: billm, Assigned: billm)

Details

Attachments

(1 file)

Attached patch patchSplinter Review
The problem here is that SystemZoneResource::IsAvailable can be called from any thread. On non-main threads, dom::danger::GetJSContext will return null or a worker JSContext. We always want to get a main-thread JSContext (although it doesn't matter which one). This patch just picks an arbitrary cooperative thread's context.
Attachment #8922633 - Flags: review?(nfroyd)
Comment on attachment 8922633 [details] [diff] [review]
patch

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

Is SystemZoneAvailable safe to call from any thread?  It looks like it accesses quite a bunch of stuff...but I guess we're calling it under a lock of some sort, which would ensure that we're not modifying the cx from the (a) main thread.
Attachment #8922633 - Flags: review?(nfroyd) → review+
Pushed by wmccloskey@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/af490228394e
Use main-thread JSContext in SystemZoneResource::IsAvailable (r=froydnj)
https://hg.mozilla.org/mozilla-central/rev/af490228394e
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.