From 870eefecb16fae80d6aa1111d775dbfac45ddf68 Mon Sep 17 00:00:00 2001 From: trav90 Date: Sun, 5 Mar 2017 02:37:53 -0600 Subject: [PATCH] Don't wait for a drain complete that will never happen This prevents a deadlock that is due to the HTMLMediaElement calling MediaDecoder::NotifyOwnerActivityChanged() , attempt to grab the monitor, which is held by the SharedDecoderManager which is waiting for SetIdle() to complete. --- dom/media/platforms/SharedDecoderManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dom/media/platforms/SharedDecoderManager.cpp b/dom/media/platforms/SharedDecoderManager.cpp index 75cd7fd18b..ffe46e98e5 100644 --- a/dom/media/platforms/SharedDecoderManager.cpp +++ b/dom/media/platforms/SharedDecoderManager.cpp @@ -98,9 +98,12 @@ SharedDecoderManager::CreateVideoDecoder( mPDM = nullptr; return nullptr; } - mPDM = aPDM; nsresult rv = mDecoder->Init(); - NS_ENSURE_SUCCESS(rv, nullptr); + if (NS_FAILED(rv)) { + mDecoder = nullptr; + return nullptr; + } + mPDM = aPDM; } nsRefPtr proxy(new SharedDecoderProxy(this, aCallback)); @@ -148,10 +151,11 @@ SharedDecoderManager::SetIdle(MediaDataDecoder* aProxy) { if (aProxy && mActiveProxy == aProxy) { mWaitForInternalDrain = true; - mActiveProxy->Drain(); - MonitorAutoLock mon(mMonitor); - while (mWaitForInternalDrain) { - mon.Wait(); + if (NS_SUCCEEDED(mActiveProxy->Drain())) { + MonitorAutoLock mon(mMonitor); + while (mWaitForInternalDrain) { + mon.Wait(); + } } mActiveProxy->Flush(); mActiveProxy = nullptr;