Closed Bug 1651249 Opened 4 years ago Closed 4 years ago

nsTimer should dispatch to the current serial event loop by default

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: jya, Assigned: jya)

References

Details

Attachments

(1 file)

In bug 1650277, I removed a Google's MessageLoop to use a TaskQueue instead (a background taskqueue)

I was hit with high intermittent failures, they turned out to be due to the use of nsTimer which by default dispatch a task on the current EventTarget, not the current SerialEventTarget.

This is problematic as it will lead the called code to run outside the taskqueue and can lead to data races.

When not specifying the event target the nsTimer should be using, we should default to the current SerialEventTarget as it prevents shooting yourself in the foot.

Dispatching to the underlying thread of what could be a thread-pool can lead to data-race as the code won't be run where you expect it to.

Pushed by jyavenard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/15f79cf4a022
Dispatch to the current SerialEventTarget by default. r=froydnj
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: