Bug 1657521 - P3. Have the RemoteDecoderManagerChild use its own dedicated thread. r=mattwoodrow

This is a partial revert of "Bug 1650996 - P3. Have RemoteDecoderManagerChild use a TaskQueue over a media threadpool."

The RemoteDecoderManagerChild dispatch tasks synchronously, right now it is doing so on the media controller's thread pool ; however in the following patch it will change the creation to the decoder's thread pool.

If we attempt to instantiate too many decoders at once, we run out of available threads and dead-lock in the sync dispatch.

This issue has bitten us in various places already and the solution was always assuming that the decoder will always be created on the controller's thread and used on the decoder's thread.
This assumption won't hold any longer and was difficult to keep anyway.

So we have the RemoteDecoderManagerChild uses a dedicated thread so that we can guarantee there will always be an available thread to create the decoder.

Depends on D86543

Differential Revision: https://phabricator.services.mozilla.com/D86895
This commit is contained in:
Jean-Yves Avenard 2020-08-13 03:19:36 +00:00
parent 6d550ab425
commit 86a3cf7457
2 changed files with 7 additions and 6 deletions

View File

@ -65,6 +65,7 @@ ProxyResolution
RemoteLzyStream
RWLockTester
RacingServMan
RemVidChild
Sandbox Testing
SaveScripts
Socket Thread

View File

@ -20,7 +20,7 @@ using namespace layers;
using namespace gfx;
// Only modified on the main-thread
StaticRefPtr<TaskQueue> sRemoteDecoderManagerChildThread;
StaticRefPtr<nsIThread> sRemoteDecoderManagerChildThread;
// Only accessed from sRemoteDecoderManagerChildThread
static StaticRefPtr<RemoteDecoderManagerChild>
@ -39,9 +39,10 @@ void RemoteDecoderManagerChild::InitializeThread() {
// RemoteDecoderModule runs on it and dispatch synchronous tasks to the
// manager thread, should more than 4 concurrent videos being instantiated
// at the same time, we could end up in a deadlock.
sRemoteDecoderManagerChildThread = new TaskQueue(
GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER), "RemVidChild");
RefPtr<nsIThread> childThread;
nsresult rv = NS_NewNamedThread("RemVidChild", getter_AddRefs(childThread));
NS_ENSURE_SUCCESS_VOID(rv);
sRemoteDecoderManagerChildThread = childThread;
sRecreateTasks = MakeUnique<nsTArray<RefPtr<Runnable>>>();
}
}
@ -84,8 +85,7 @@ void RemoteDecoderManagerChild::Shutdown() {
sRemoteDecoderManagerChildForGPUProcess = nullptr;
})));
sRemoteDecoderManagerChildThread->BeginShutdown();
sRemoteDecoderManagerChildThread->AwaitShutdownAndIdle();
sRemoteDecoderManagerChildThread->Shutdown();
sRemoteDecoderManagerChildThread = nullptr;
sRecreateTasks = nullptr;