From c09c023a9bfc3c34be38cf95d1691fd712af2d68 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Thu, 2 Mar 2023 03:22:35 +0000 Subject: [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 --- services/surfaceflinger/SurfaceFlinger.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index eecfeb661a..f6063f4a97 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3954,8 +3954,14 @@ bool SurfaceFlinger::latchBuffers() { mLayersWithQueuedFrames.emplace(sp::fromExisting(layer)); } else { layer->useEmptyDamage(); - // If the layer has frames we will update the latch time when latching the buffer. - layer->updateLastLatchTime(latchTime); + 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; -- cgit v1.2.3-59-g8ed1b