Open Bug 1824189 Opened 2 years ago Updated 10 months ago

Consider adding a non-leaking (fallible) variant of `nsIEventTarget::Dispatch`

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

People

(Reporter: nika, Unassigned)

References

Details

Dispatches to event targets are currently quite inconsistent. Some event targets (like nsThread) will leak if the dispatch fails, making them effectively infallible, while others (like TaskQueue) will not leak the runnable if the dispatch fails, meaning that dispatched runnables may be released on the wrong thread.

We should consider adding a new variant of Dispatch to nsIEventTarget which is explicitly fallible, and doesn't take ownership from the caller over the runnable unless it successfully dispatches. This could be combined with migrating all existing Dispatch calls to consistently leak on failure, making it possible for callers to make the correct decisions for their use cases.

Alternatively, if changing the existing Dispatch method to be consistent is too difficult (e.g. because of there being code depending on the existing behaviour), it may also be possible to add two explicit variants with leaking and non-leaking, and slowly migrate away from the existing Dispatch call, however due to the number of consumers of the existing API this feels somewhat unappealing.

See Also: → 1800752
See Also: → 1803948
See Also: → 1814771
See Also: → 1237213
See Also: → 1870423
See Also: → 1870784
You need to log in before you can comment on or make changes to this bug.