Fix Transaction tracking for FrameTimeline
The current setup only supports one SurfaceFrame per DrawingState for
Transactions. This becomes problematic if more than one Transaction is
submitted for the same vsync, on the same layer. On top of this, the
Blast transactions can have a buffer that could result in a buffer drop.
This change adds the support to hold multiple SurfaceFrames in the
Layer's State. It also adds a bufferSurfaceFrame that's intended only
for Blast Transactions with a Buffer. All other Transactions are tracked
in the bufferlessSurfaceFrames.
Additionally, this change also adds a lastLatchTime. It is needed for
classifying BufferStuffing properly.
Bug: 176106798
Test: open any app from the launcher and at the same time check dumpsys
Change-Id: Id3b8369ca206f8b89be3041e5fc018f1f1be1d23
Merged-In: Id3b8369ca206f8b89be3041e5fc018f1f1be1d23
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 5219787..3615a02 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -282,8 +282,7 @@
mConsumer->mergeSurfaceDamage(mQueueItems[0].item.mSurfaceDamage);
mFlinger->mTimeStats->removeTimeRecord(layerId, mQueueItems[0].item.mFrameNumber);
if (mQueueItems[0].surfaceFrame) {
- mQueueItems[0].surfaceFrame->setPresentState(PresentState::Dropped);
- mFlinger->mFrameTimeline->addSurfaceFrame(mQueueItems[0].surfaceFrame);
+ addSurfaceFrameDroppedForBuffer(mQueueItems[0].surfaceFrame);
}
mQueueItems.erase(mQueueItems.begin());
mQueuedFrames--;
@@ -298,8 +297,7 @@
Mutex::Autolock lock(mQueueItemLock);
for (auto& [item, surfaceFrame] : mQueueItems) {
if (surfaceFrame) {
- surfaceFrame->setPresentState(PresentState::Dropped);
- mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
+ addSurfaceFrameDroppedForBuffer(surfaceFrame);
}
}
mQueueItems.clear();
@@ -329,8 +327,7 @@
mConsumer->mergeSurfaceDamage(mQueueItems[0].item.mSurfaceDamage);
mFlinger->mTimeStats->removeTimeRecord(layerId, mQueueItems[0].item.mFrameNumber);
if (mQueueItems[0].surfaceFrame) {
- mQueueItems[0].surfaceFrame->setPresentState(PresentState::Dropped);
- mFlinger->mFrameTimeline->addSurfaceFrame(mQueueItems[0].surfaceFrame);
+ addSurfaceFrameDroppedForBuffer(mQueueItems[0].surfaceFrame);
}
mQueueItems.erase(mQueueItems.begin());
mQueuedFrames--;
@@ -342,11 +339,9 @@
FrameTracer::FrameEvent::LATCH);
if (mQueueItems[0].surfaceFrame) {
- mQueueItems[0].surfaceFrame->setAcquireFenceTime(
- mQueueItems[0].item.mFenceTime->getSignalTime());
- mQueueItems[0].surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime);
- mFlinger->mFrameTimeline->addSurfaceFrame(mQueueItems[0].surfaceFrame);
- mLastLatchTime = latchTime;
+ addSurfaceFramePresentedForBuffer(mQueueItems[0].surfaceFrame,
+ mQueueItems[0].item.mFenceTime->getSignalTime(),
+ latchTime);
}
mQueueItems.erase(mQueueItems.begin());
}
@@ -444,10 +439,7 @@
}
}
- auto surfaceFrame =
- mFlinger->mFrameTimeline->createSurfaceFrameForToken(mFrameTimelineInfo, mOwnerPid,
- mOwnerUid, mName, mName);
- surfaceFrame->setActualQueueTime(systemTime());
+ auto surfaceFrame = createSurfaceFrameForBuffer(mFrameTimelineInfo, systemTime(), mName);
mQueueItems.push_back({item, surfaceFrame});
mQueuedFrames++;
@@ -483,10 +475,7 @@
return;
}
- auto surfaceFrame =
- mFlinger->mFrameTimeline->createSurfaceFrameForToken(mFrameTimelineInfo, mOwnerPid,
- mOwnerUid, mName, mName);
- surfaceFrame->setActualQueueTime(systemTime());
+ auto surfaceFrame = createSurfaceFrameForBuffer(mFrameTimelineInfo, systemTime(), mName);
mQueueItems[mQueueItems.size() - 1].item = item;
mQueueItems[mQueueItems.size() - 1].surfaceFrame = std::move(surfaceFrame);