Skip to content

Commit f57c138

Browse files
critsecAndroid (Google) Code Review
authored andcommitted
Merge "SurfaceFlinger: fix layer removal race condition" into ics-mr1
2 parents 2a7b5ab + 8a7c940 commit f57c138

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,14 @@ void SurfaceFlinger::computeVisibleRegions(
710710

711711
void SurfaceFlinger::commitTransaction()
712712
{
713+
if (!mLayersPendingRemoval.isEmpty()) {
714+
// Notify removed layers now that they can't be drawn from
715+
for (size_t i = 0; i < mLayersPendingRemoval.size(); i++) {
716+
mLayersPendingRemoval[i]->onRemoved();
717+
}
718+
mLayersPendingRemoval.clear();
719+
}
720+
713721
mDrawingState = mCurrentState;
714722
mTransationPending = false;
715723
mTransactionCV.broadcast();
@@ -1162,7 +1170,7 @@ status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
11621170
mLayerPurgatory.add(layerBase);
11631171
}
11641172

1165-
layerBase->onRemoved();
1173+
mLayersPendingRemoval.push(layerBase);
11661174

11671175
// it's possible that we don't find a layer, because it might
11681176
// have been destroyed already -- this is not technically an error

services/surfaceflinger/SurfaceFlinger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class SurfaceFlinger :
345345
Condition mTransactionCV;
346346
SortedVector< sp<LayerBase> > mLayerPurgatory;
347347
bool mTransationPending;
348+
Vector< sp<LayerBase> > mLayersPendingRemoval;
348349

349350
// protected by mStateLock (but we could use another lock)
350351
GraphicPlane mGraphicPlanes[1];

0 commit comments

Comments
 (0)