Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e338df1c authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

SF: detachLayer from Client earlier on destruction

- When a Layer is destroyed the Layer destructor isn't called until
  the next vsync refresh. However, the onRemoved() callback is called
  on the next invalidate. So it's possible to submit a transaction on
  the layer in between the call to onRemoved() and the destructor
  being called.
- Call detachLayer() from onRemoved() instead of from the destructor
  so that any transactions on a destroyed Layer will fail to get the
  Layer object even if the destructor has yet to be called.

Bug 25887783

Change-Id: Ic2371f695bc91aa7120bf6506bb834ceb536420e
parent 438afe17
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -147,10 +147,6 @@ void Layer::onFirstRef() {
}

Layer::~Layer() {
    sp<Client> c(mClientRef.promote());
    if (c != 0) {
        c->detachLayer(this);
    }
    mFlinger->deleteTextureAsync(mTextureName);
    mFrameTracker.logAndResetStats(mName);
}
@@ -252,6 +248,10 @@ void Layer::onSidebandStreamChanged() {
// the layer has been remove from the current state list (and just before
// it's removed from the drawing state list)
void Layer::onRemoved() {
    sp<Client> c(mClientRef.promote());
    if (c != 0) {
        c->detachLayer(this);
    }
    mSurfaceFlingerConsumer->abandon();
}