MediaDecoder shutting down after gfx has been shutdown

RESOLVED DUPLICATE of bug 1207220

Status

()

RESOLVED DUPLICATE of bug 1207220
3 years ago
3 years ago

People

(Reporter: jya, Assigned: jya)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox46 affected)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
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.
(Assignee)

Updated

3 years ago
Blocks: 1214462
(Assignee)

Comment 1

3 years ago
This is the likely underlying cause of bug 1236167
Blocks: 1236167
(Assignee)

Comment 2

3 years ago
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
(Assignee)

Comment 3

3 years ago
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.
Attachment #8703502 - Flags: review?(cpearce)
(Assignee)

Updated

3 years ago
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.
Attachment #8703502 - Flags: review?(cpearce)
You need to log in before you can comment on or make changes to this bug.