[SurfaceFlinger] Adjust missed frame tracking
Before, missed frame tracking may be inaccurate if a frame takes longer
than one vsync and either an invalidate message is not immediately
scheduled afterwards, or the frame takes almost as long as two vsyncs
but manages to be on time to be presented for that second vsync. Those
scenarios can cause visual jank, but they are not tracked by missed
frames which affects testing.
* Rename the previous missedFrames to pendingFrames
* pendingFrames is used to check for backpressure propagation so there
is no change to device behavior
* Compute a new missedFrames count by relaxing the check for
pendingFrames - if the expected present time of the previous frame was
earlier than the actual present time then that frame was missed. We add
half a vsync of slop to correct for scheduling drift.
Bug: 143647283
Test: boots
Test: systrace
Change-Id: I0f76d06737f5182c512ca6f36b332b68192250c3
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index e6b91e6..5f490d6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -839,7 +839,21 @@
bool isDisplayConfigAllowed(HwcConfigIndexType configId) const REQUIRES(mStateLock);
- bool previousFrameMissed(int graceTimeMs = 0);
+ // Gets the fence for the previous frame.
+ // Must be called on the main thread.
+ sp<Fence> previousFrameFence();
+
+ // Whether the previous frame has not yet been presented to the display.
+ // If graceTimeMs is positive, this method waits for at most the provided
+ // grace period before reporting if the frame missed.
+ // Must be called on the main thread.
+ bool previousFramePending(int graceTimeMs = 0);
+
+ // Returns the previous time that the frame was presented. If the frame has
+ // not been presented yet, then returns Fence::SIGNAL_TIME_PENDING. If there
+ // is no pending frame, then returns Fence::SIGNAL_TIME_INVALID.
+ // Must be called on the main thread.
+ nsecs_t previousFramePresentTime();
// Populates the expected present time for this frame. For negative offsets, performs a
// correction using the predicted vsync for the next frame instead.