зеркало из https://github.com/mozilla/gecko-dev.git
Bug 774388 - Patch 14: block on ImageBridgeParent shutdown before we destroy the compositor thread - r=mattwoodrow
This commit is contained in:
Родитель
1a2d3576a2
Коммит
31db832664
|
@ -101,43 +101,30 @@ static void DestroyCompositorMap()
|
|||
// See ImageBridgeChild.cpp
|
||||
void ReleaseImageBridgeParentSingleton();
|
||||
|
||||
class CompositorThreadHolder MOZ_FINAL
|
||||
CompositorThreadHolder::CompositorThreadHolder()
|
||||
: mCompositorThread(CreateCompositorThread())
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorThreadHolder)
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_COUNT_CTOR(CompositorThreadHolder);
|
||||
}
|
||||
|
||||
public:
|
||||
CompositorThreadHolder()
|
||||
: mCompositorThread(CreateCompositorThread())
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_COUNT_CTOR(CompositorThreadHolder);
|
||||
}
|
||||
CompositorThreadHolder::~CompositorThreadHolder()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Thread* GetCompositorThread() const {
|
||||
return mCompositorThread;
|
||||
}
|
||||
MOZ_COUNT_DTOR(CompositorThreadHolder);
|
||||
|
||||
private:
|
||||
~CompositorThreadHolder()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_COUNT_DTOR(CompositorThreadHolder);
|
||||
|
||||
DestroyCompositorThread(mCompositorThread);
|
||||
}
|
||||
|
||||
Thread* const mCompositorThread;
|
||||
|
||||
static Thread* CreateCompositorThread();
|
||||
static void DestroyCompositorThread(Thread* aCompositorThread);
|
||||
|
||||
friend class CompositorParent;
|
||||
};
|
||||
DestroyCompositorThread(mCompositorThread);
|
||||
}
|
||||
|
||||
static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder;
|
||||
static bool sFinishedCompositorShutDown = false;
|
||||
|
||||
CompositorThreadHolder* GetCompositorThreadHolder()
|
||||
{
|
||||
return sCompositorThreadHolder;
|
||||
}
|
||||
|
||||
/* static */ Thread*
|
||||
CompositorThreadHolder::CreateCompositorThread()
|
||||
{
|
||||
|
@ -174,7 +161,6 @@ CompositorThreadHolder::DestroyCompositorThread(Thread* aCompositorThread)
|
|||
MOZ_ASSERT(!sCompositorThreadHolder, "We shouldn't be destroying the compositor thread yet.");
|
||||
|
||||
DestroyCompositorMap();
|
||||
ReleaseImageBridgeParentSingleton();
|
||||
delete aCompositorThread;
|
||||
sFinishedCompositorShutDown = true;
|
||||
}
|
||||
|
@ -201,6 +187,8 @@ void CompositorParent::ShutDown()
|
|||
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main Thread!");
|
||||
MOZ_ASSERT(sCompositorThreadHolder, "The compositor thread has already been shut down!");
|
||||
|
||||
ReleaseImageBridgeParentSingleton();
|
||||
|
||||
sCompositorThreadHolder = nullptr;
|
||||
|
||||
// No locking is needed around sFinishedCompositorShutDown because it is only
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ShadowLayersManager.h" // for ShadowLayersManager
|
||||
#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS
|
||||
#include "base/platform_thread.h" // for PlatformThreadId
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
||||
#include "mozilla/Monitor.h" // for Monitor
|
||||
|
@ -64,7 +65,27 @@ private:
|
|||
uint64_t mLayersId;
|
||||
};
|
||||
|
||||
class CompositorThreadHolder;
|
||||
class CompositorThreadHolder MOZ_FINAL
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorThreadHolder)
|
||||
|
||||
public:
|
||||
CompositorThreadHolder();
|
||||
|
||||
base::Thread* GetCompositorThread() const {
|
||||
return mCompositorThread;
|
||||
}
|
||||
|
||||
private:
|
||||
~CompositorThreadHolder();
|
||||
|
||||
base::Thread* const mCompositorThread;
|
||||
|
||||
static base::Thread* CreateCompositorThread();
|
||||
static void DestroyCompositorThread(base::Thread* aCompositorThread);
|
||||
|
||||
friend class CompositorParent;
|
||||
};
|
||||
|
||||
class CompositorParent : public PCompositorParent,
|
||||
public ShadowLayersManager
|
||||
|
|
|
@ -46,12 +46,16 @@ std::map<base::ProcessId, ImageBridgeParent*> ImageBridgeParent::sImageBridges;
|
|||
|
||||
MessageLoop* ImageBridgeParent::sMainLoop = nullptr;
|
||||
|
||||
// defined in CompositorParent.cpp
|
||||
CompositorThreadHolder* GetCompositorThreadHolder();
|
||||
|
||||
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
||||
Transport* aTransport,
|
||||
ProcessId aChildProcessId)
|
||||
: mMessageLoop(aLoop)
|
||||
, mTransport(aTransport)
|
||||
, mChildProcessId(aChildProcessId)
|
||||
, mCompositorThreadHolder(GetCompositorThreadHolder())
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
sMainLoop = MessageLoop::current();
|
||||
|
@ -295,6 +299,7 @@ MessageLoop * ImageBridgeParent::GetMessageLoop() const {
|
|||
void
|
||||
ImageBridgeParent::DeferredDestroy()
|
||||
{
|
||||
mCompositorThreadHolder = nullptr;
|
||||
mSelfRef = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h> // for uint32_t, uint64_t
|
||||
#include "CompositableTransactionParent.h"
|
||||
#include "CompositorParent.h"
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
@ -153,6 +154,8 @@ private:
|
|||
static std::map<base::ProcessId, ImageBridgeParent*> sImageBridges;
|
||||
|
||||
static MessageLoop* sMainLoop;
|
||||
|
||||
nsRefPtr<CompositorThreadHolder> mCompositorThreadHolder;
|
||||
};
|
||||
|
||||
} // layers
|
||||
|
|
Загрузка…
Ссылка в новой задаче