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

Commit 87d42635 authored by Steven Thomas's avatar Steven Thomas Committed by android-build-merger
Browse files

Merge "Fix deadlock when transitioning to vr flinger" into oc-mr1-dev

am: c026c52e

Change-Id: I1703d835bba529afdc4c7b9d6b8a3c195b1686df
parents 3819afa4 c026c52e
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -630,11 +630,18 @@ void SurfaceFlinger::init() {

    if (useVrFlinger) {
        auto vrFlingerRequestDisplayCallback = [this] (bool requestDisplay) {
            // This callback is called from the vr flinger dispatch thread. We
            // need to call signalTransaction(), which requires holding
            // mStateLock when we're not on the main thread. Acquiring
            // mStateLock from the vr flinger dispatch thread might trigger a
            // deadlock in surface flinger (see b/66916578), so post a message
            // to be handled on the main thread instead.
            sp<LambdaMessage> message = new LambdaMessage([=]() {
                ALOGI("VR request display mode: requestDisplay=%d", requestDisplay);
                mVrFlingerRequestsDisplay = requestDisplay;
            ConditionalLock _l(mStateLock,
                    std::this_thread::get_id() != mMainThreadId);
                signalTransaction();
            });
            postMessageAsync(message);
        };
        mVrFlinger = dvr::VrFlinger::Create(mHwc->getComposer(),
                                            vrFlingerRequestDisplayCallback);