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

Commit 86e11906 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SurfaceFlinger: Fix layer creation race

While we create a new layer, the main thread may wake up and set the
layer parent which means we will start traversing the layer parents in
the binder thread. Fix this by updating the transform hint which checks
the parents before pass the layer creation request to the main thread.

Change-Id: Icb87fb4c33bb3a110169d885398f628df319de88
Test: presubmit
Fixes: 243122612
parent d9dd2418
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3572,15 +3572,16 @@ status_t SurfaceFlinger::addClientLayer(const sp<Client>& client, const sp<IBind
        return NO_MEMORY;
    }

    layer->updateTransformHint(mActiveDisplayTransformHint);
    if (outTransformHint) {
        *outTransformHint = mActiveDisplayTransformHint;
    }

    {
        std::scoped_lock<std::mutex> lock(mCreatedLayersLock);
        mCreatedLayers.emplace_back(layer, parent, addToRoot);
    }

    layer->updateTransformHint(mActiveDisplayTransformHint);
    if (outTransformHint) {
        *outTransformHint = mActiveDisplayTransformHint;
    }
    // attach this layer to the client
    if (client != nullptr) {
        client->attachLayer(handle, layer);