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

Commit 0779dedb authored by Valerie Hau's avatar Valerie Hau
Browse files

Do not block transaction application on flush

Condition wait in applyTransactionState blocks threads sending a
synchronous transaction until SF can commit the transaction.  However,
the main SF thread can also applyTransactionState on pending
transactions.  In these cases, SF should not be blocked waiting for
itself to commit the transaction.

Bug: 127852667
Test: build, boot, manual
Change-Id: Id6b81529b2f1537ba5ce7aec27789e26225b167b
parent fbf18cc3
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -3478,7 +3478,7 @@ bool SurfaceFlinger::flushTransactionQueues() {
                break;
            }
            applyTransactionState(states, displays, flags, mPendingInputWindowCommands,
                                  desiredPresentTime, postTime, privileged);
                                  desiredPresentTime, postTime, privileged, /*isMainThread*/ true);
            transactionQueue.pop();
        }

@@ -3565,7 +3565,7 @@ void SurfaceFlinger::applyTransactionState(const Vector<ComposerState>& states,
                                           const Vector<DisplayState>& displays, uint32_t flags,
                                           const InputWindowCommands& inputWindowCommands,
                                           const int64_t desiredPresentTime, const int64_t postTime,
                                           bool privileged) {
                                           bool privileged, bool isMainThread) {
    uint32_t transactionFlags = 0;

    if (flags & eAnimation) {
@@ -3629,7 +3629,12 @@ void SurfaceFlinger::applyTransactionState(const Vector<ComposerState>& states,
        }

        mPendingSyncInputWindows = mPendingInputWindowCommands.syncInputWindows;
        while (mTransactionPending || mPendingSyncInputWindows) {

        // applyTransactionState can be called by either the main SF thread or by
        // another process through setTransactionState.  While a given process may wish
        // to wait on synchronous transactions, the main SF thread should never
        // be blocked.  Therefore, we only wait if isMainThread is false.
        while (!isMainThread && (mTransactionPending || mPendingSyncInputWindows)) {
            status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
            if (CC_UNLIKELY(err != NO_ERROR)) {
                // just in case something goes wrong in SF, return to the
+1 −1
Original line number Diff line number Diff line
@@ -576,7 +576,7 @@ private:
                               const Vector<DisplayState>& displays, uint32_t flags,
                               const InputWindowCommands& inputWindowCommands,
                               const int64_t desiredPresentTime, const int64_t postTime,
                               bool privileged) REQUIRES(mStateLock);
                               bool privileged, bool isMainThread = false) REQUIRES(mStateLock);
    bool flushTransactionQueues();
    uint32_t getTransactionFlags(uint32_t flags);
    uint32_t peekTransactionFlags();