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

Commit 59d9d5fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent onHandleDestroyed from being called w/ mStateLock" into qt-dev

parents d076fdd5 fce31b82
Loading
Loading
Loading
Loading
+30 −22
Original line number Diff line number Diff line
@@ -3520,24 +3520,31 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags,
}

bool SurfaceFlinger::flushTransactionQueues() {
    Mutex::Autolock _l(mStateLock);
    // to prevent onHandleDestroyed from being called while the lock is held,
    // we must keep a copy of the transactions (specifically the composer
    // states) around outside the scope of the lock
    std::vector<const TransactionState> transactions;
    bool flushedATransaction = false;
    {
        Mutex::Autolock _l(mStateLock);

        auto it = mTransactionQueues.begin();
        while (it != mTransactionQueues.end()) {
            auto& [applyToken, transactionQueue] = *it;

            while (!transactionQueue.empty()) {
            const auto&
                    [states, displays, flags, desiredPresentTime, uncacheBuffer, listenerCallbacks,
                     postTime, privileged] = transactionQueue.front();
            if (!transactionIsReadyToBeApplied(desiredPresentTime, states)) {
                const auto& transaction = transactionQueue.front();
                if (!transactionIsReadyToBeApplied(transaction.desiredPresentTime,
                                                   transaction.states)) {
                    setTransactionFlags(eTransactionFlushNeeded);
                    break;
                }
            applyTransactionState(states, displays, flags, mPendingInputWindowCommands,
                                  desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime,
                                  privileged, /*isMainThread*/ true);
                transactions.push_back(transaction);
                applyTransactionState(transaction.states, transaction.displays, transaction.flags,
                                      mPendingInputWindowCommands, transaction.desiredPresentTime,
                                      transaction.buffer, transaction.callback,
                                      transaction.postTime, transaction.privileged,
                                      /*isMainThread*/ true);
                transactionQueue.pop();
                flushedATransaction = true;
            }
@@ -3549,6 +3556,7 @@ bool SurfaceFlinger::flushTransactionQueues() {
                std::next(it, 1);
            }
        }
    }
    return flushedATransaction;
}