diff options
author | Rachel Lee <rnlee@google.com> | 2022-09-08 19:51:32 -0700 |
---|---|---|
committer | Rachel Lee <rnlee@google.com> | 2022-09-09 19:50:34 +0000 |
commit | 4bce2e19ea8893805eae836b85730ffd302d9f3b (patch) | |
tree | 9247ec0af69486fbe04f5d0218a06ad0bdb6f43b | |
parent | 7fa3483dfb0b6eefdb8eeb990172d673bbed2665 (diff) | |
download | native-4bce2e19ea8893805eae836b85730ffd302d9f3b.tar.gz |
Fix getLatestVsyncEventData deadline.
Bug: 239775097
Test: atest libsurfaceflinger_unittest
Test: pixel 4xl camera preview test (see bug)
Change-Id: Ib92849291458f59c2ef2238d3586211b87174c7f
(cherry picked from commit 0679cf200ea30c2e791cd79b27a26676e8848932)
Merged-In: Ib92849291458f59c2ef2238d3586211b87174c7f
-rw-r--r-- | services/surfaceflinger/Scheduler/DispSyncSource.cpp | 6 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/DispSyncSourceTest.cpp | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/services/surfaceflinger/Scheduler/DispSyncSource.cpp b/services/surfaceflinger/Scheduler/DispSyncSource.cpp index 747032be0d..4af1f5c65f 100644 --- a/services/surfaceflinger/Scheduler/DispSyncSource.cpp +++ b/services/surfaceflinger/Scheduler/DispSyncSource.cpp @@ -188,10 +188,10 @@ void DispSyncSource::onVsyncCallback(nsecs_t vsyncTime, nsecs_t targetWakeupTime VSyncSource::VSyncData DispSyncSource::getLatestVSyncData() const { std::lock_guard lock(mVsyncMutex); - nsecs_t expectedPresentTime = mVSyncTracker.nextAnticipatedVSyncTimeFrom( + nsecs_t expectedPresentationTime = mVSyncTracker.nextAnticipatedVSyncTimeFrom( systemTime() + mWorkDuration.get().count() + mReadyDuration.count()); - nsecs_t deadline = expectedPresentTime - mWorkDuration.get().count() - mReadyDuration.count(); - return {expectedPresentTime, deadline}; + nsecs_t deadline = expectedPresentationTime - mReadyDuration.count(); + return {expectedPresentationTime, deadline}; } void DispSyncSource::dump(std::string& result) const { diff --git a/services/surfaceflinger/tests/unittests/DispSyncSourceTest.cpp b/services/surfaceflinger/tests/unittests/DispSyncSourceTest.cpp index ec27edac6e..67ace1af83 100644 --- a/services/surfaceflinger/tests/unittests/DispSyncSourceTest.cpp +++ b/services/surfaceflinger/tests/unittests/DispSyncSourceTest.cpp @@ -292,9 +292,10 @@ TEST_F(DispSyncSourceTest, waitForCallbacksWithDurationChange) { TEST_F(DispSyncSourceTest, getLatestVsyncData) { const nsecs_t now = systemTime(); - const nsecs_t vsyncInternalDuration = mWorkDuration.count() + mReadyDuration.count(); + const nsecs_t expectedPresentationTime = + now + mWorkDuration.count() + mReadyDuration.count() + 1; EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) - .WillOnce(Return(now + vsyncInternalDuration + 1)); + .WillOnce(Return(expectedPresentationTime)); { InSequence seq; EXPECT_CALL(*mVSyncDispatch, registerCallback(_, mName)).Times(1); @@ -306,10 +307,8 @@ TEST_F(DispSyncSourceTest, getLatestVsyncData) { EXPECT_TRUE(mDispSyncSource); const auto vsyncData = mDispSyncSource->getLatestVSyncData(); - ASSERT_GT(vsyncData.deadlineTimestamp, now); - ASSERT_GT(vsyncData.expectedPresentationTime, vsyncData.deadlineTimestamp); - EXPECT_EQ(vsyncData.deadlineTimestamp, - vsyncData.expectedPresentationTime - vsyncInternalDuration); + ASSERT_EQ(vsyncData.expectedPresentationTime, expectedPresentationTime); + EXPECT_EQ(vsyncData.deadlineTimestamp, expectedPresentationTime - mReadyDuration.count()); } } // namespace |