Bug 1523013 - Clear SamplesWaitingForKey::mProxy in Shutdown(). r=cpearce

There's a strong cycle of references between SamplesWaitingForKey and
CDMProxy that does not get cleared unless keys actually come in. This
causes a leak. One way to avoid that leak is to clear the proxy
reference when the things holding the SamplesWaitingForKey is shut
down.

Differential Revision: https://phabricator.services.mozilla.com/D17960

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-01-30 22:56:21 +00:00
Родитель bf0e86a9dc
Коммит 0f605627fd
3 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -251,6 +251,7 @@ class EMEDecryptor : public MediaDataDecoder,
return InvokeAsync(mTaskQueue, __func__, [self, this]() {
MOZ_ASSERT(!mIsShutdown);
mIsShutdown = true;
mSamplesWaitingForKey->BreakCycles();
mSamplesWaitingForKey = nullptr;
RefPtr<MediaDataDecoder> decoder = mDecoder.forget();
mProxy = nullptr;
@ -347,6 +348,7 @@ RefPtr<MediaDataDecoder::FlushPromise> EMEMediaDataDecoderProxy::Flush() {
RefPtr<ShutdownPromise> EMEMediaDataDecoderProxy::Shutdown() {
RefPtr<EMEMediaDataDecoderProxy> self = this;
return InvokeAsync(mThread, __func__, [self, this]() {
mSamplesWaitingForKey->BreakCycles();
mSamplesWaitingForKey = nullptr;
mProxy = nullptr;
return MediaDataDecoderProxy::Shutdown();

Просмотреть файл

@ -69,4 +69,9 @@ void SamplesWaitingForKey::Flush() {
mSamples.Clear();
}
void SamplesWaitingForKey::BreakCycles() {
MutexAutoLock lock(mMutex);
mProxy = nullptr;
}
} // namespace mozilla

Просмотреть файл

@ -42,6 +42,8 @@ class SamplesWaitingForKey {
void Flush();
void BreakCycles();
protected:
~SamplesWaitingForKey();