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

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

Implement timeout for barriers in SF

Previously a barrier would cause SF to stall transaction processing for
all transactions sharing the apply token until the barrier frame
arrived. Implement a timeout incase the barrier frame never arrives.

Cl also adds a speculative fix for BBQ to not set a barrier if the surfacecontrol changes.


Bug: 402059710, 422754680
Test: presubmit
Flag: EXEMPT bug fix


Change-Id: I4dbbe08b8eafc72278f6a63d344c12d0ebe3a194
parent 34f08473
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -270,6 +270,7 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width,
    const bool surfaceControlChanged = !SurfaceControl::isSameSurface(mSurfaceControl, surface);
    if (surfaceControlChanged && mSurfaceControl != nullptr) {
        BQA_LOGD("Updating SurfaceControl without recreating BBQ");
        mSetBufferBarrier = false;
    }

    // Always update the native object even though they might have the same layer handle, so we can
@@ -708,8 +709,11 @@ status_t BLASTBufferQueue::acquireNextBufferLocked(
                            mName.c_str(), status);
        mAppliedLastTransaction = true;
        mLastAppliedFrameNumber = bufferItem.mFrameNumber;
        mSetBufferBarrier = true;
    } else {
        if (mSetBufferBarrier) {
          t->setBufferHasBarrier(mSurfaceControl, mLastAppliedFrameNumber);
        }
        mAppliedLastTransaction = false;
    }

+1 −0
Original line number Diff line number Diff line
@@ -230,6 +230,7 @@ private:
    ui::Size mSize GUARDED_BY(mMutex);
    ui::Size mRequestedSize GUARDED_BY(mMutex);
    int32_t mFormat GUARDED_BY(mMutex);
    bool mSetBufferBarrier GUARDED_BY(mMutex) = false;

    // Keep a copy of the current picture profile handle, so it can be moved to a new
    // SurfaceControl when BBQ migrates via ::update.
+12 −2
Original line number Diff line number Diff line
@@ -4946,11 +4946,21 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                                           " < %" PRId64,
                                           layer->name.c_str(), layer->barrierFrameNumber,
                                           s.bufferData->barrierFrameNumber);
                            bool timeout = std::chrono::nanoseconds(flushState.queueProcessTime -
                                                                    transaction.postTime) >
                                    std::chrono::seconds(4);
                            if (timeout) {
                                TransactionTraceWriter::getInstance()
                                .invoke("IgnoreBarrierDueToTimeout",
                                        /* overwrite= */ false);
                                SFTRACE_FORMAT("IgnoreBarrierDueToTimeout %s", layer->name.c_str());
                            } else {
                                ready = TransactionReadiness::NotReadyBarrier;
                                return TraverseBuffersReturnValues::STOP_TRAVERSAL;
                            }
                        }
                    }
                }

                // If backpressure is enabled and we already have a buffer to commit, keep
                // the transaction in the queue.
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ perfetto::protos::TransactionState TransactionProtoParser::toProto(
    for (auto& mergedTransactionId : t.mergedTransactionIds) {
        proto.mutable_merged_transaction_ids()->Add(mergedTransactionId);
    }
    proto.set_apply_token(reinterpret_cast<uint64_t>(t.applyToken.get()));

    return proto;
}