Clean up dangling layer hierarchy references
In order to support detached mirrors, we introduced a different path for
mirroring a hierarchy that excludes the root layer's transform. However,
when the mirrored layer was destroyed, references to this layer were not
properly removed from its mirroring hierarchy. Fix this and introduce a test
to cover this scenario.
Flag: EXEMPT bug fix
Fixes: 343901186
Test: presumbit
Change-Id: I32f41fc2c9db00590ede4509d75000ab0a38f116
diff --git a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp
index 4b0618e..dd5e8bd 100644
--- a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp
@@ -152,6 +152,10 @@
if (swapErase(linkedLayer->mirrorIds, layer.id)) {
linkedLayer->changes |= RequestedLayerState::Changes::Mirror;
}
+ if (linkedLayer->layerIdToMirror == layer.id) {
+ linkedLayer->layerIdToMirror = UNASSIGNED_LAYER_ID;
+ linkedLayer->changes |= RequestedLayerState::Changes::Mirror;
+ }
if (linkedLayer->touchCropId == layer.id) {
linkedLayer->touchCropId = UNASSIGNED_LAYER_ID;
}