Bug 1049501: Don't let the GMPThread event loop recurse while handling IPDL shutdowns r=bsmedberg

This commit is contained in:
Randell Jesup 2014-08-14 13:50:25 -04:00
parent dad40fbfa9
commit f94dc1d94b

View File

@ -12,6 +12,7 @@
#include "nsAutoRef.h"
#include "GMPParent.h"
#include "mozilla/gmp/GMPTypes.h"
#include "nsThread.h"
#include "nsThreadUtils.h"
#include "runnable_utils.h"
@ -72,7 +73,9 @@ GMPVideoEncoderParent::GMPVideoEncoderParent(GMPParent *aPlugin)
GMPVideoEncoderParent::~GMPVideoEncoderParent()
{
mEncodedThread->Shutdown();
if (mEncodedThread) {
mEncodedThread->Shutdown();
}
}
GMPVideoHostImpl&
@ -238,6 +241,12 @@ GMPVideoEncoderParent::Shutdown()
}
}
static void
ShutdownEncodedThread(nsCOMPtr<nsIThread>& aThread)
{
aThread->Shutdown();
}
// Note: Keep this sync'd up with Shutdown
void
GMPVideoEncoderParent::ActorDestroy(ActorDestroyReason aWhy)
@ -249,6 +258,15 @@ GMPVideoEncoderParent::ActorDestroy(ActorDestroyReason aWhy)
mCallback->Terminated();
mCallback = nullptr;
}
// Must be shut down before VideoEncoderDestroyed(), since this can recurse
// the GMPThread event loop. See bug 1049501
if (mEncodedThread) {
// Can't get it to allow me to use WrapRunnable with a nsCOMPtr<nsIThread>()
NS_DispatchToMainThread(
WrapRunnableNM<decltype(&ShutdownEncodedThread),
nsCOMPtr<nsIThread> >(&ShutdownEncodedThread, mEncodedThread));
mEncodedThread = nullptr;
}
if (mPlugin) {
// Ignore any return code. It is OK for this to fail without killing the process.
mPlugin->VideoEncoderDestroyed(this);