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

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

[sf] only update the last latch time if the layer has a buffer

If we apply a transaction that does not latch a buffer, we
incorrectly updated the last latch time. In the next vsync,
if we presented a buffer late, we would misclassify the
jank as buffer stuffing.

Fix this by only updating the latch time if the layer has
a buffer.

Test: verify in perfetto traces
Fixes: 270041584
Change-Id: I423a28803a2660ada80ef554469f3977c389fbfa
parent a0cff095
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3037,6 +3037,10 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
                                      mLastClientCompositionFence);
            mLastClientCompositionFence = nullptr;
        }
    } else {
        // if we are latching a buffer for the first time then clear the mLastLatchTime since
        // we don't want to incorrectly classify a frame if we miss the desired present time.
        updateLastLatchTime(0);
    }

    mDrawingState.producerId = bufferData.producerId;
+1 −0
Original line number Diff line number Diff line
@@ -852,6 +852,7 @@ public:
                                   const sp<GraphicBuffer>& buffer, uint64_t framenumber,
                                   const sp<Fence>& releaseFence);
    bool setFrameRateForLayerTree(FrameRate);
    bool hasBuffer() const { return mBufferInfo.mBuffer != nullptr; }

protected:
    // For unit tests
+8 −2
Original line number Diff line number Diff line
@@ -3954,9 +3954,15 @@ bool SurfaceFlinger::latchBuffers() {
            mLayersWithQueuedFrames.emplace(sp<Layer>::fromExisting(layer));
        } else {
            layer->useEmptyDamage();
            // If the layer has frames we will update the latch time when latching the buffer.
            if (!layer->hasBuffer()) {
                // The last latch time is used to classify a missed frame as buffer stuffing
                // instead of a missed frame. This is used to identify scenarios where we
                // could not latch a buffer or apply a transaction due to backpressure.
                // We only update the latch time for buffer less layers here, the latch time
                // is updated for buffer layers when the buffer is latched.
                layer->updateLastLatchTime(latchTime);
            }
        }
    });
    mForceTransactionDisplayChange = false;