Bug 1574965 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

In light of recent MediaStreamGraph lifetime issues (see See Also) we could simplifiy things by deciding on main thread in advance when a graph will be shutdown.

We can do this by keeping a MediaStream count that's incremented in [`AddStream()`]() and decremented in [`MediaStream::Destroy()`](). When this reaches 0 after having been non-zero we remove the graph from gGraphs. Like proposed in bug 1572858 comment 3 we should assert in `AddStream()` that the current graph is present in gGraphs to catch invalid uses.

Possibly we need a tail-dispatched runnable to take the decision to shut down, such that an event loop task doing `stream->Destroy(); graph->AddStream(stream2);` doesn't shut the graph down. Perhaps an audit of existing uses of both `Destroy` and `AddStream` could shine some light on the need for this.

Remaining lifetime logic can remain in place, so that the graph shuts down automatically when things have been cleaned up on the graph thread.

This effectively also removes the use case and need for `GraphDriver::Revive`, allowing us to do a bunch of bonus cleanup in both `MediaStreamGraph` and `GraphDriver`.
In light of recent `MediaStreamGraph` lifetime issues (see See Also) we could simplifiy things by deciding on main thread in advance when a graph will be shutdown.

We can do this by keeping a `MediaStream` count that's incremented in [`AddStream()`]() and decremented in [`MediaStream::Destroy()`](). When this reaches zero after having been non-zero we remove the graph from `gGraphs`. Like proposed in bug 1572858 comment 3 we should assert in `AddStream()` that the current graph is present in gGraphs to catch invalid uses.

Possibly we need a tail-dispatched runnable to take the decision to shut down, such that an event loop task doing `stream->Destroy(); graph->AddStream(stream2);` doesn't shut the graph down. Perhaps an audit of existing uses of both `Destroy` and `AddStream` could shine some light on the need for this.

Remaining lifetime logic can remain in place, so that the graph shuts down automatically when things have been cleaned up on the graph thread.

This effectively also removes the use case and need for `GraphDriver::Revive`, allowing us to do a bunch of bonus cleanup in both `MediaStreamGraph` and `GraphDriver`.

Back to Bug 1574965 Comment 0