From 136e2f6570d68e86dca1b2bfa23fc61abcee149e Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 8 Feb 2017 17:54:29 -0800 Subject: [PATCH] Remove erroneous log message It seems we always get a duplicate remove from the layer-cleaner so this was showing up any time any layer was removed. We didn't have this message before the child layers CL so lets get rid of it quickly. Test: Deleting a line of logging code. It builds! Change-Id: I16cc0c0b325e43d36cae684b06a93c099baa1aa6 --- services/surfaceflinger/SurfaceFlinger.cpp | 9 ++++++++- services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 215628de0f..2781e8c4f9 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2539,11 +2539,18 @@ status_t SurfaceFlinger::removeLayer(const wp& weakLayer) { const ssize_t index = (p != nullptr) ? p->removeChild(layer) : mCurrentState.layersSortedByZ.remove(layer); - if (index < 0) { + // As a matter of normal operation, the LayerCleaner will produce a second + // attempt to remove the surface. The Layer will be kept alive in mDrawingState + // so we will succeed in promoting it, but it's already been removed + // from mCurrentState. As long as we can find it in mDrawingState we have no problem + // otherwise something has gone wrong and we are leaking the layer. + if (index < 0 && mDrawingState.layersSortedByZ.indexOf(layer) < 0) { ALOGE("Failed to find layer (%s) in layer parent (%s).", layer->getName().string(), (p != nullptr) ? p->getName().string() : "no-parent"); return BAD_VALUE; + } else if (index < 0) { + return NO_ERROR; } mLayersPendingRemoval.add(layer); diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index e6ab29a4fb..5aaaab1f5e 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -2325,11 +2325,18 @@ status_t SurfaceFlinger::removeLayer(const wp& weakLayer) { const ssize_t index = (p != nullptr) ? p->removeChild(layer) : mCurrentState.layersSortedByZ.remove(layer); - if (index < 0) { + // As a matter of normal operation, the LayerCleaner will produce a second + // attempt to remove the surface. The Layer will be kept alive in mDrawingState + // so we will succeed in promoting it, but it's already been removed + // from mCurrentState. As long as we can find it in mDrawingState we have no problem + // otherwise something has gone wrong and we are leaking the layer. + if (index < 0 && mDrawingState.layersSortedByZ.indexOf(layer) < 0) { ALOGE("Failed to find layer (%s) in layer parent (%s).", layer->getName().string(), (p != nullptr) ? p->getName().string() : "no-parent"); return BAD_VALUE; + } else if (index < 0) { + return NO_ERROR; } mLayersPendingRemoval.add(layer); -- 2.11.0