mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-25 01:01:52 +00:00
Bug 1049501: Don't let the GMPThread event loop recurse while handling IPDL shutdowns r=bsmedberg
This commit is contained in:
parent
1c39379cd6
commit
7ecd01e5fb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user