The issue was properly described by Nicolas in bug 1223193. When shutting down, ShutdownXPCOM is called which notifies its observers with NS_XPCOM_SHUTDOWN_OBSERVER_ID so that they can shutdown. XPCOM expects these operations to be synchronous. One of those observers is the MediaShutdownManager which will loop over all its registered MediaDecoders and call MediaDecoder::Shutdown(), expecting things to be synchronous too. Once the XPCOM observers have been notified , gfxPlatform::ShutdownLayersIPC() is called. However, MediaDecoder::Shutdown() itself isn't synchronous. Internally it will call MediaDecoderStateMachine::Shutdown() which is async which itself calls MediaDecoderReader::Shutdown() also async. So when the MediaShutdownManager loop over the registered MediaDecoder, there are still potentially tasks running. Should those tasks happen to run after gfxPlatform::ShutdownLayersIPC() has been called: we'll typically get some crashes. The gfx team has papered over the issue for years, but fundamentally the issue is that shutting down of the MediaDecoder / MediaShutdownManager is asyncronous. Ideally we would want to use MozPromise/AllPromiseHolder to continue shutting down XPCOM once all the decoders have completed their shutdown. However this is likely too big of a task. so in the mean time, MediaShutdownManager should block until all decoders have fully shutdown.
Unfortunately it isn't what's causing bug 1236167. It does fix assertion #4, but not the others which seem to be genuine races.
No longer blocks: 1236167
Created attachment 8703502 [details] [diff] [review] Ensure MediaShutdownManager waits until all MediaDecoder have completed their shutdown. XPCOM when shutting down expects all tasks to be run synchronously. As such, we must ensure that the remaining MediaDecoder are shut down before continuing on the next task. In particular destroying gfxPlatforms must only ever happen after, as it is possible for the MediaDecoderReader to make use of gfx resources during shutdown.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1207220
Comment on attachment 8703502 [details] [diff] [review] Ensure MediaShutdownManager waits until all MediaDecoder have completed their shutdown. Given this bug is duped, I'll clear the review request.
You need to log in before you can comment on or make changes to this bug.