зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1553555 - Release RemoteDecoderChild on manager thread in the case of an InitIPDL error. r=jya
Differential Revision: https://phabricator.services.mozilla.com/D32178 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ccfd01b031
Коммит
3de5584fce
|
@ -94,9 +94,21 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateAudioDecoder(
|
|||
|
||||
RefPtr<RemoteAudioDecoderChild> child = new RemoteAudioDecoderChild();
|
||||
MediaResult result(NS_OK);
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderModule::CreateAudioDecoder", [&, child]() {
|
||||
// We can use child as a ref here because this is a sync dispatch. In
|
||||
// the error case for InitIPDL, we can't just let the RefPtr go out of
|
||||
// scope at the end of the method because it will release the
|
||||
// RemoteAudioDecoderChild on the wrong thread. This will assert in
|
||||
// RemoteDecoderChild's destructor. Passing the RefPtr by reference
|
||||
// allows us to release the RemoteAudioDecoderChild on the manager
|
||||
// thread during this single dispatch.
|
||||
RefPtr<Runnable> task =
|
||||
NS_NewRunnableFunction("RemoteDecoderModule::CreateAudioDecoder", [&]() {
|
||||
result = child->InitIPDL(aParams.AudioConfig(), aParams.mOptions);
|
||||
if (NS_FAILED(result)) {
|
||||
// Release RemoteAudioDecoderChild here, while we're on
|
||||
// manager thread. Don't just let the RefPtr go out of scope.
|
||||
child = nullptr;
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(mManagerThread, task);
|
||||
|
||||
|
@ -124,10 +136,22 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateVideoDecoder(
|
|||
|
||||
RefPtr<RemoteVideoDecoderChild> child = new RemoteVideoDecoderChild();
|
||||
MediaResult result(NS_OK);
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"RemoteDecoderModule::CreateVideoDecoder", [&, child]() {
|
||||
// We can use child as a ref here because this is a sync dispatch. In
|
||||
// the error case for InitIPDL, we can't just let the RefPtr go out of
|
||||
// scope at the end of the method because it will release the
|
||||
// RemoteVideoDecoderChild on the wrong thread. This will assert in
|
||||
// RemoteDecoderChild's destructor. Passing the RefPtr by reference
|
||||
// allows us to release the RemoteVideoDecoderChild on the manager
|
||||
// thread during this single dispatch.
|
||||
RefPtr<Runnable> task =
|
||||
NS_NewRunnableFunction("RemoteDecoderModule::CreateVideoDecoder", [&]() {
|
||||
result = child->InitIPDL(aParams.VideoConfig(), aParams.mRate.mValue,
|
||||
aParams.mOptions);
|
||||
if (NS_FAILED(result)) {
|
||||
// Release RemoteVideoDecoderChild here, while we're on
|
||||
// manager thread. Don't just let the RefPtr go out of scope.
|
||||
child = nullptr;
|
||||
}
|
||||
});
|
||||
SyncRunnable::DispatchToThread(mManagerThread, task);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче