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

Commit c026c52e authored by Steven Thomas's avatar Steven Thomas Committed by Android (Google) Code Review
Browse files

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

parents 17209ec9 be6cbae3
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -604,11 +604,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);