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

Commit ec0ab384 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Lock access to InputWindowCommands

Fixes regression caused by ag/6260282.
Create a pending list of InputWindowCommands so that we can apply the commands without
holding on to the mStateLock to better align with the current and drawing state locking
strategy.

Bug: 124061013
Test: go/wm-smoke
Change-Id: I9ccec72da0d2139ca546e34df8e62c58c178d292
parent 101843de
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -383,6 +383,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
    other.mListenerCallbacks.clear();

    mInputWindowCommands.merge(other.mInputWindowCommands);
    other.mInputWindowCommands.clear();

    return *this;
}
+9 −3
Original line number Diff line number Diff line
@@ -3098,6 +3098,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
        });
    }

    commitInputWindowCommands();
    commitTransaction();
}

@@ -3128,6 +3129,11 @@ void SurfaceFlinger::updateInputWindowInfo() {
    mInputFlinger->setInputWindows(inputHandles);
}

void SurfaceFlinger::commitInputWindowCommands() {
    mInputWindowCommands.merge(mPendingInputWindowCommands);
    mPendingInputWindowCommands.clear();
}

void SurfaceFlinger::executeInputWindowCommands() {
    for (const auto& transferTouchFocusCommand : mInputWindowCommands.transferTouchFocusCommands) {
        if (transferTouchFocusCommand.fromToken != nullptr &&
@@ -3706,7 +3712,7 @@ bool SurfaceFlinger::flushTransactionQueues() {
            if (!transactionIsReadyToBeApplied(desiredPresentTime, states)) {
                break;
            }
            applyTransactionState(states, displays, flags, mInputWindowCommands);
            applyTransactionState(states, displays, flags, mPendingInputWindowCommands);
            transactionQueue.pop();
        }

@@ -4174,7 +4180,7 @@ uint32_t SurfaceFlinger::addInputWindowCommands(const InputWindowCommands& input
        flags |= eTraversalNeeded;
    }

    mInputWindowCommands.merge(inputWindowCommands);
    mPendingInputWindowCommands.merge(inputWindowCommands);
    return flags;
}

@@ -4390,7 +4396,7 @@ void SurfaceFlinger::onInitializeDisplays() {
    d.width = 0;
    d.height = 0;
    displays.add(d);
    setTransactionState(state, displays, 0, nullptr, mInputWindowCommands, -1);
    setTransactionState(state, displays, 0, nullptr, mPendingInputWindowCommands, -1);

    setPowerModeInternal(display, HWC_POWER_MODE_NORMAL);

+4 −0
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ private:

    void updateInputFlinger();
    void updateInputWindowInfo();
    void commitInputWindowCommands();
    void executeInputWindowCommands();
    void updateCursorAsync();

@@ -1144,6 +1145,9 @@ private:
    /* ------------------------------------------------------------------------ */
    sp<IInputFlinger> mInputFlinger;

    // Access must be protected by mStateLock.
    InputWindowCommands mPendingInputWindowCommands;
    // Should only be accessed by the drawing thread.
    InputWindowCommands mInputWindowCommands;

    ui::DisplayPrimaries mInternalDisplayPrimaries;