Bug 1443187 - Avoid crashing if a previously-uncomposited layer tree gets adopted. r?botond
MozReview-Commit-ID: FZYwS7IwdKq
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -249,24 +249,25 @@ APZCTreeManager::~APZCTreeManager()
}
void
APZCTreeManager::NotifyLayerTreeAdopted(uint64_t aLayersId,
const RefPtr<APZCTreeManager>& aOldApzcTreeManager)
{
APZThreadUtils::AssertOnSamplerThread();
- MOZ_ASSERT(aOldApzcTreeManager);
- aOldApzcTreeManager->mFocusState.RemoveFocusTarget(aLayersId);
- // While we could move the focus target information from the old APZC tree
- // manager into this one, it's safer to not do that, as we'll probably have
- // that information repopulated soon anyway (on the next layers update).
+ if (aOldApzcTreeManager) {
+ aOldApzcTreeManager->mFocusState.RemoveFocusTarget(aLayersId);
+ // While we could move the focus target information from the old APZC tree
+ // manager into this one, it's safer to not do that, as we'll probably have
+ // that information repopulated soon anyway (on the next layers update).
+ }
UniquePtr<APZTestData> adoptedData;
- { // scope lock for removal on oldApzcTreeManager
+ if (aOldApzcTreeManager) {
MutexAutoLock lock(aOldApzcTreeManager->mTestDataLock);
auto it = aOldApzcTreeManager->mTestData.find(aLayersId);
if (it != aOldApzcTreeManager->mTestData.end()) {
adoptedData = Move(it->second);
aOldApzcTreeManager->mTestData.erase(it);
}
}
if (adoptedData) {
--- a/gfx/layers/apz/src/APZSampler.cpp
+++ b/gfx/layers/apz/src/APZSampler.cpp
@@ -61,18 +61,17 @@ APZSampler::UpdateHitTestingTree(uint64_
aOriginatingLayersId, aPaintSequenceNumber);
}
void
APZSampler::NotifyLayerTreeAdopted(uint64_t aLayersId,
const RefPtr<APZSampler>& aOldSampler)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
- MOZ_ASSERT(aOldSampler);
- mApz->NotifyLayerTreeAdopted(aLayersId, aOldSampler->mApz);
+ mApz->NotifyLayerTreeAdopted(aLayersId, aOldSampler ? aOldSampler->mApz : nullptr);
}
void
APZSampler::NotifyLayerTreeRemoved(uint64_t aLayersId)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
mApz->NotifyLayerTreeRemoved(aLayersId);
}
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1738,20 +1738,25 @@ CompositorBridgeParent::RecvAdoptChild(c
if (cpcp) {
TimeStamp now = TimeStamp::Now();
cpcp->DidCompositeLocked(child, now, now);
}
}
parent = sIndirectLayerTrees[child].mApzcTreeManagerParent;
}
- // We don't support moving a child from a APZ-enabled compositor to a
- // APZ-disabled compostior. The mOptions assertion above should already
- // ensure this, since APZ-ness is one of the things in mOptions.
- MOZ_ASSERT((oldApzSampler != nullptr) == (mApzSampler != nullptr));
+ if (oldApzSampler) {
+ // We don't support moving a child from an APZ-enabled compositor to a
+ // APZ-disabled compositor. The mOptions assertion above should already
+ // ensure this, since APZ-ness is one of the things in mOptions. Note
+ // however it is possible for mApzSampler to be non-null here with
+ // oldApzSampler null, because the child may not have been previously
+ // composited.
+ MOZ_ASSERT(mApzSampler);
+ }
if (mApzSampler) {
if (parent) {
MOZ_ASSERT(mApzcTreeManager);
parent->ChildAdopted(mApzcTreeManager);
}
mApzSampler->NotifyLayerTreeAdopted(child, oldApzSampler);
}
return IPC_OK();