Bug 1360389 - Have ChromiumCDMParent inform CDMProxy of shutdown. r=gerald
The ChromiumCDMParent is informed of the shutdown of its plugin, so we can
use that to inform the CDMProxy that its connection to the CDM has been
severed. This means we shutdown cleanly if the browser closes while playing.
MozReview-Commit-ID: HphQ2exu1gj
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -1062,16 +1062,27 @@ ChromiumCDMParent::Shutdown()
{
GMP_LOG("ChromiumCDMParent::Shutdown(this=%p)", this);
if (mIsShutdown) {
return;
}
mIsShutdown = true;
+ // If we're shutting down due to the plugin shutting down due to application
+ // shutdown, we should tell the CDM proxy to also shutdown. Otherwise the
+ // proxy will shutdown when the owning MediaKeys is destroyed during cycle
+ // collection, and that will not shut down cleanly as the GMP thread will be
+ // shutdown by then.
+ if (mProxy) {
+ RefPtr<Runnable> task =
+ NewRunnableMethod(mProxy, &ChromiumCDMProxy::Shutdown);
+ NS_DispatchToMainThread(task.forget());
+ }
+
// We may be called from a task holding the last reference to the proxy, so
// let's clear our local weak pointer to ensure it will not be used afterward
// (including from an already-queued task, e.g.: ActorDestroy).
mProxy = nullptr;
for (RefPtr<DecryptJob>& decrypt : mDecrypts) {
decrypt->PostResult(AbortedErr);
}