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

Commit df3c5e8b authored by chaviw's avatar chaviw
Browse files

Fix some issues with pending buffer traces

1. If there is already something in the pending transactions queue, we
will skip calling transactionIsReadyToBeApplied. This means we won't
increment the buffer count properly. Instead, call
transactionIsReadyToBeApplied first since it's pretty harmless and will
update the buffer count if needed.

2. updateActiveBuffer can be called multiple times with the same buffer.
This is because when checking hasReadyFrame, we only check if something
has been modified and there's a buffer. It's possible that the geometry
was updated, but we didn't receive a new buffer. In that case, we'd still
call updateActiveBuffer. That would call decrementPendingBufferCount which
is incorrect since there's no new buffer.

Instead, check if the buffer has changed in updateActiveBuffer before
calling decrementPendingBufferCount to make sure the buffer getting
updated is a new buffer buffer.

Test: trace isn't going negative
Fixes: 176903239
Change-Id: I0bd492463e5e440db16fc8bef1408b5156e961e4
parent 4d25380c
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -636,7 +636,10 @@ status_t BufferStateLayer::updateActiveBuffer() {
    if (s.buffer == nullptr) {
    if (s.buffer == nullptr) {
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }

    if (s.buffer != mBufferInfo.mBuffer) {
        decrementPendingBufferCount();
        decrementPendingBufferCount();
    }


    mPreviousBufferId = getCurrentBufferId();
    mPreviousBufferId = getCurrentBufferId();
    mBufferInfo.mBuffer = s.buffer;
    mBufferInfo.mBuffer = s.buffer;
+4 −2
Original line number Original line Diff line number Diff line
@@ -3377,8 +3377,10 @@ status_t SurfaceFlinger::setTransactionState(
    const int originPid = ipc->getCallingPid();
    const int originPid = ipc->getCallingPid();
    const int originUid = ipc->getCallingUid();
    const int originUid = ipc->getCallingUid();


    if (pendingTransactions ||
    // Call transactionIsReadyToBeApplied first in case we need to incrementPendingBufferCount
        !transactionIsReadyToBeApplied(isAutoTimestamp ? 0 : desiredPresentTime, states, true)) {
    // if the transaction contains a buffer.
    if (!transactionIsReadyToBeApplied(isAutoTimestamp ? 0 : desiredPresentTime, states, true) ||
        pendingTransactions) {
        mTransactionQueues[applyToken].emplace(frameTimelineVsyncId, states, displays, flags,
        mTransactionQueues[applyToken].emplace(frameTimelineVsyncId, states, displays, flags,
                                               desiredPresentTime, isAutoTimestamp, uncacheBuffer,
                                               desiredPresentTime, isAutoTimestamp, uncacheBuffer,
                                               postTime, privileged, hasListenerCallbacks,
                                               postTime, privileged, hasListenerCallbacks,