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
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 62e31b9..f2a8d44 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -772,7 +772,7 @@
// transaction
// ----------------------------------------------------------------------------
-uint32_t Layer::doTransaction(uint32_t flags) {
+uint32_t Layer::doTransaction(uint32_t flags, nsecs_t latchTime) {
ATRACE_CALL();
// TODO: This is unfortunate.
@@ -800,23 +800,24 @@
mFlinger->mUpdateInputInfo = true;
}
- commitTransaction(mDrawingState);
+ commitTransaction(mDrawingState, latchTime);
return flags;
}
-void Layer::commitTransaction(State&) {
+void Layer::commitTransaction(State&, nsecs_t currentLatchTime) {
// Set the present state for all bufferlessSurfaceFramesTX to Presented. The
// bufferSurfaceFrameTX will be presented in latchBuffer.
for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) {
if (surfaceFrame->getPresentState() != PresentState::Presented) {
// With applyPendingStates, we could end up having presented surfaceframes from previous
// states
- surfaceFrame->setPresentState(PresentState::Presented);
+ surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime);
mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
}
}
mDrawingState.bufferlessSurfaceFramesTX.clear();
+ mLastLatchTime = currentLatchTime;
}
uint32_t Layer::clearTransactionFlags(uint32_t mask) {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 429dfb0..8424d7d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -614,7 +614,7 @@
* doTransaction - process the transaction. This is a good place to figure
* 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
@@ -846,7 +846,7 @@
void preparePerFrameCompositionState();
void preparePerFrameBufferCompositionState();
void preparePerFrameEffectsCompositionState();
- virtual void commitTransaction(State& stateToCommit);
+ virtual void commitTransaction(State& stateToCommit, nsecs_t currentLatchTime = 0);
void gatherBufferInfo();
void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>&);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e3649ec..f223de6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3771,7 +3771,7 @@
for (Layer* offscreenLayer : mOffscreenLayers) {
offscreenLayer->traverse(LayerVector::StateSet::Drawing, [](Layer* layer) {
if (layer->clearTransactionFlags(eTransactionNeeded)) {
- layer->doTransaction(0);
+ layer->doTransaction(0, 0);
layer->commitChildList();
}
});
@@ -3807,7 +3807,7 @@
// second frame. But layer 0's second frame could be waiting on display.
mDrawingState.traverse([&](Layer* layer) {
if (layer->clearTransactionFlags(eTransactionNeeded) || mForceTransactionDisplayChange) {
- const uint32_t flags = layer->doTransaction(0);
+ const uint32_t flags = layer->doTransaction(0, latchTime);
if (flags & Layer::eVisibleRegion) {
mVisibleRegionsDirty = true;
}