ResyncCallback in getLatestVsyncEventData.
Without resyncing, getLatestVsyncEventData might have wrong refresh rate
compared to hardware. `getLatestVsyncEventData` is an alternate way
to get vsync information, instead of posting callbacks to Choreographer.
Choreographer only needs to resync when the main thread is hogged by an
application for more than the threshold (currently 750ms), and simulated
vsync is no longer accurate.
Bug: 205721584
Test: atest libsurfaceflinger_unittest
Change-Id: I32c69b0368365c860fa0eb75f932e283e05a1302
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index 14d8f98..6293fe8 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -414,6 +414,10 @@
EXPECT_CALL(*mVSyncSource, getLatestVSyncData()).WillOnce(Return(preferredData));
VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection);
+
+ // Check EventThread immediately requested a resync.
+ EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());
+
EXPECT_GT(vsyncEventData.frameTimelines[0].deadlineTimestamp, now)
<< "Deadline timestamp should be greater than frame time";
for (size_t i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {