Bug 1352877 - Avoid false negative assertion during shutdown. r=mattwoodrow

This commit is contained in:
Nicolas Silva 2018-09-11 16:50:30 +02:00
Родитель ab644b087f
Коммит 645517471b
1 изменённых файлов: 13 добавлений и 4 удалений

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

@ -117,6 +117,16 @@ using namespace std;
using base::ProcessId; using base::ProcessId;
using base::Thread; using base::Thread;
/// Equivalent to asserting CompositorThreadHolder::IsInCompositorThread with the
/// addition that it doesn't assert if the compositor thread holder is already gone
/// during late shutdown.
static void AssertIsInCompositorThread()
{
MOZ_RELEASE_ASSERT(!CompositorThread() ||
CompositorThreadHolder::IsInCompositorThread());
}
CompositorBridgeParentBase::CompositorBridgeParentBase(CompositorManagerParent* aManager) CompositorBridgeParentBase::CompositorBridgeParentBase(CompositorManagerParent* aManager)
: mCanSend(true) : mCanSend(true)
, mCompositorManager(aManager) , mCompositorManager(aManager)
@ -1667,15 +1677,14 @@ CompositorBridgeParent::DeallocPLayerTransactionParent(PLayerTransactionParent*
CompositorBridgeParent* CompositorBridgeParent::GetCompositorBridgeParent(uint64_t id) CompositorBridgeParent* CompositorBridgeParent::GetCompositorBridgeParent(uint64_t id)
{ {
MOZ_RELEASE_ASSERT(CompositorThreadHolder::IsInCompositorThread()); AssertIsInCompositorThread();
CompositorMap::iterator it = sCompositorMap->find(id); CompositorMap::iterator it = sCompositorMap->find(id);
return it != sCompositorMap->end() ? it->second : nullptr; return it != sCompositorMap->end() ? it->second : nullptr;
} }
void CompositorBridgeParent::AddCompositor(CompositorBridgeParent* compositor, uint64_t* outID) void CompositorBridgeParent::AddCompositor(CompositorBridgeParent* compositor, uint64_t* outID)
{ {
MOZ_RELEASE_ASSERT(CompositorThreadHolder::IsInCompositorThread()); AssertIsInCompositorThread();
static uint64_t sNextID = 1; static uint64_t sNextID = 1;
@ -1686,7 +1695,7 @@ void CompositorBridgeParent::AddCompositor(CompositorBridgeParent* compositor, u
CompositorBridgeParent* CompositorBridgeParent::RemoveCompositor(uint64_t id) CompositorBridgeParent* CompositorBridgeParent::RemoveCompositor(uint64_t id)
{ {
MOZ_RELEASE_ASSERT(CompositorThreadHolder::IsInCompositorThread()); AssertIsInCompositorThread();
CompositorMap::iterator it = sCompositorMap->find(id); CompositorMap::iterator it = sCompositorMap->find(id);
if (it == sCompositorMap->end()) { if (it == sCompositorMap->end()) {