Bug 1752305 AsyncShutdown() MediaTrackGrph thread r=padenot

This avoids putting a nested event loop on the stack, which may not unwind if
further threads are shutdown, leading to stack exhaustion.

GraphDriver::Shutdown() is called only after control of the graph has been
handed to the main thread so the graph is not running while this is called and
so MediaTrackGraphShutDownRunnable on the main thread should not need to wait
for thread shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D151357
This commit is contained in:
Karl Tomlinson 2022-08-17 21:33:16 +00:00
parent 99789192be
commit 382bffd9a0
3 changed files with 3 additions and 5 deletions

View File

@ -83,7 +83,7 @@ class MediaTrackGraphShutdownThreadRunnable : public Runnable {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mThread);
mThread->Shutdown();
mThread->AsyncShutdown();
mThread = nullptr;
return NS_OK;
}
@ -154,7 +154,7 @@ void ThreadedDriver::Shutdown() {
if (mThread) {
LOG(LogLevel::Debug,
("%p: Stopping ThreadedDriver's %p thread", Graph(), this));
mThread->Shutdown();
mThread->AsyncShutdown();
mThread = nullptr;
}
}

View File

@ -275,7 +275,7 @@ class GraphDriver {
* A driver cannot be started twice, it must be shutdown
* before being started again. */
virtual void Start() = 0;
/* Shutdown GraphDriver (synchronously) */
/* Shutdown GraphDriver */
MOZ_CAN_RUN_SCRIPT virtual void Shutdown() = 0;
/* Rate at which the GraphDriver runs, in ms. This can either be user
* controlled (because we are using a {System,Offline}ClockDriver, and decide

View File

@ -1737,8 +1737,6 @@ class MediaTrackGraphShutDownRunnable : public Runnable {
RefPtr<GraphRunner>(mGraph->mGraphRunner)->Shutdown();
}
// This will wait until it's shutdown since
// we'll start tearing down the graph after this
RefPtr<GraphDriver>(mGraph->mDriver)->Shutdown();
// Release the driver now so that an AudioCallbackDriver will release its