From 3be61905f09f265de9732eed00985e324540e5b8 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 26 Apr 2023 19:47:29 -0700 Subject: [sf] Properly update clones of clones Relanding with the change to only update onscreen mirror roots and cleaning up some debug logs. When updating a cloned layer hierarchy that contains another cloned layer hierarchy, we are dependent on the order in which we update each hierarchy. The inner cloned hierarchy must be updated first otherwise the outer clone will not capture the entire tree and some layers might be omitted from composition. To fix this we track all layer mirror roots. When updating each root, we check to see if they mirror another root. If they do mirror another root and that root has not been updated, we update the root again at the end. Test: repro steps in bug Fixes: 279622227 Change-Id: I125f7c788716d59909b77a88ef4098b7cac08919 --- services/surfaceflinger/SurfaceFlinger.cpp | 39 ++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index dfe8c72bca..84ad551c62 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -4025,8 +4025,24 @@ void SurfaceFlinger::doCommitTransactions() { } commitOffscreenLayers(); - if (mNumClones > 0) { - mDrawingState.traverse([&](Layer* layer) { layer->updateMirrorInfo(); }); + if (mLayerMirrorRoots.size() > 0) { + std::deque pendingUpdates; + pendingUpdates.insert(pendingUpdates.end(), mLayerMirrorRoots.begin(), + mLayerMirrorRoots.end()); + std::vector needsUpdating; + for (Layer* cloneRoot : mLayerMirrorRoots) { + pendingUpdates.pop_front(); + if (cloneRoot->isRemovedFromCurrentState()) { + continue; + } + if (cloneRoot->updateMirrorInfo(pendingUpdates)) { + } else { + needsUpdating.push_back(cloneRoot); + } + } + for (Layer* cloneRoot : needsUpdating) { + cloneRoot->updateMirrorInfo({}); + } } } @@ -4133,7 +4149,7 @@ bool SurfaceFlinger::latchBuffers() { mBootStage = BootStage::BOOTANIMATION; } - if (mNumClones > 0) { + if (mLayerMirrorRoots.size() > 0) { mDrawingState.traverse([&](Layer* layer) { layer->updateCloneBufferInfo(); }); } @@ -4158,8 +4174,8 @@ status_t SurfaceFlinger::addClientLayer(LayerCreationArgs& args, const sp parent = sp::fromExisting(layer); while (parent) { - ALOGE("Parent Layer: %s handleIsAlive: %s", parent->getName().c_str(), - std::to_string(parent->isHandleAlive()).c_str()); + ALOGE("Parent Layer: %s%s", parent->getName().c_str(), + (parent->isHandleAlive() ? "handleAlive" : "")); parent = parent->getParent(); } // Sample up to 100 layers @@ -4174,21 +4190,28 @@ status_t SurfaceFlinger::addClientLayer(LayerCreationArgs& args, const spgetName().c_str()); + ALOGE("Layer: %s%s", layer->getName().c_str(), + (layer->isHandleAlive() ? "handleAlive" : "")); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } }); ALOGE("Dumping random sampling of off-screen layers total(%zu): ", mOffscreenLayers.size()); for (Layer* offscreenLayer : mOffscreenLayers) { if (rand() % 20 == 13) { - ALOGE("Offscreen-layer: %s", offscreenLayer->getName().c_str()); + ALOGE("Offscreen-layer: %s%s", offscreenLayer->getName().c_str(), + (offscreenLayer->isHandleAlive() ? "handleAlive" : "")); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } } })); -- cgit v1.2.3-59-g8ed1b