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

Commit 7fe69ede authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Pass latch time for bufferless surface frames

Latch time is used to classify jank type as BufferStuffing.
This jank classification does not  count as missed frames.
Layers without buffers do not pass in a latch time to the
frametimeline logic. Fix this inconsistency so we do not
incorrectly report missed frames for missed layer updates
due to buffer stuffing.

Test: check perfetto traces and see leashes are also classified as
buffer stuffing
Fixes: 266666415

Change-Id: Ie211aa3bd5821f6052cf84a62a2e245132a19d90
parent 412fb031
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -772,7 +772,7 @@ void Layer::transferAvailableJankData(const std::deque<sp<CallbackHandle>>& hand
// transaction
// transaction
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


uint32_t Layer::doTransaction(uint32_t flags) {
uint32_t Layer::doTransaction(uint32_t flags, nsecs_t latchTime) {
    ATRACE_CALL();
    ATRACE_CALL();


    // TODO: This is unfortunate.
    // TODO: This is unfortunate.
@@ -800,23 +800,24 @@ uint32_t Layer::doTransaction(uint32_t flags) {
        mFlinger->mUpdateInputInfo = true;
        mFlinger->mUpdateInputInfo = true;
    }
    }


    commitTransaction(mDrawingState);
    commitTransaction(mDrawingState, latchTime);


    return flags;
    return flags;
}
}


void Layer::commitTransaction(State&) {
void Layer::commitTransaction(State&, nsecs_t currentLatchTime) {
    // Set the present state for all bufferlessSurfaceFramesTX to Presented. The
    // Set the present state for all bufferlessSurfaceFramesTX to Presented. The
    // bufferSurfaceFrameTX will be presented in latchBuffer.
    // bufferSurfaceFrameTX will be presented in latchBuffer.
    for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) {
    for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) {
        if (surfaceFrame->getPresentState() != PresentState::Presented) {
        if (surfaceFrame->getPresentState() != PresentState::Presented) {
            // With applyPendingStates, we could end up having presented surfaceframes from previous
            // With applyPendingStates, we could end up having presented surfaceframes from previous
            // states
            // states
            surfaceFrame->setPresentState(PresentState::Presented);
            surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime);
            mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
            mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
        }
        }
    }
    }
    mDrawingState.bufferlessSurfaceFramesTX.clear();
    mDrawingState.bufferlessSurfaceFramesTX.clear();
    mLastLatchTime = currentLatchTime;
}
}


uint32_t Layer::clearTransactionFlags(uint32_t mask) {
uint32_t Layer::clearTransactionFlags(uint32_t mask) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -614,7 +614,7 @@ public:
     * doTransaction - process the transaction. This is a good place to figure
     * doTransaction - process the transaction. This is a good place to figure
     * out which attributes of the surface have changed.
     * out which attributes of the surface have changed.
     */
     */
    virtual uint32_t doTransaction(uint32_t transactionFlags);
    virtual uint32_t doTransaction(uint32_t transactionFlags, nsecs_t currentLatchTime);


    /*
    /*
     * Remove relative z for the layer if its relative parent is not part of the
     * Remove relative z for the layer if its relative parent is not part of the
@@ -846,7 +846,7 @@ protected:
    void preparePerFrameCompositionState();
    void preparePerFrameCompositionState();
    void preparePerFrameBufferCompositionState();
    void preparePerFrameBufferCompositionState();
    void preparePerFrameEffectsCompositionState();
    void preparePerFrameEffectsCompositionState();
    virtual void commitTransaction(State& stateToCommit);
    virtual void commitTransaction(State& stateToCommit, nsecs_t currentLatchTime = 0);
    void gatherBufferInfo();
    void gatherBufferInfo();
    void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>&);
    void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>&);


+2 −2
Original line number Original line Diff line number Diff line
@@ -3771,7 +3771,7 @@ void SurfaceFlinger::commitOffscreenLayers() {
    for (Layer* offscreenLayer : mOffscreenLayers) {
    for (Layer* offscreenLayer : mOffscreenLayers) {
        offscreenLayer->traverse(LayerVector::StateSet::Drawing, [](Layer* layer) {
        offscreenLayer->traverse(LayerVector::StateSet::Drawing, [](Layer* layer) {
            if (layer->clearTransactionFlags(eTransactionNeeded)) {
            if (layer->clearTransactionFlags(eTransactionNeeded)) {
                layer->doTransaction(0);
                layer->doTransaction(0, 0);
                layer->commitChildList();
                layer->commitChildList();
            }
            }
        });
        });
@@ -3807,7 +3807,7 @@ bool SurfaceFlinger::latchBuffers() {
    // second frame. But layer 0's second frame could be waiting on display.
    // second frame. But layer 0's second frame could be waiting on display.
    mDrawingState.traverse([&](Layer* layer) {
    mDrawingState.traverse([&](Layer* layer) {
        if (layer->clearTransactionFlags(eTransactionNeeded) || mForceTransactionDisplayChange) {
        if (layer->clearTransactionFlags(eTransactionNeeded) || mForceTransactionDisplayChange) {
            const uint32_t flags = layer->doTransaction(0);
            const uint32_t flags = layer->doTransaction(0, latchTime);
            if (flags & Layer::eVisibleRegion) {
            if (flags & Layer::eVisibleRegion) {
                mVisibleRegionsDirty = true;
                mVisibleRegionsDirty = true;
            }
            }