From afb6b50ee815108a6f5f290e1b3753069f3bd9d3 Mon Sep 17 00:00:00 2001 From: Rachel Lee Date: Fri, 12 May 2023 15:53:05 -0700 Subject: Populate preferred frame timeline always `getLatestVsyncEventData` sometimes ends up with 0 length frame timelines. When `generateFrameTimeline`, always populate with the preferred timeline information from the vsync schedule. Bug: 282110947 Test: atest EventThreadTest Test: atest DisplayEventReceiverTest Change-Id: I936d3b7095ce89ce3bd898f6b6a4f73145c27160 --- services/surfaceflinger/Scheduler/EventThread.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index af9acf3346..281b0ae559 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -612,6 +612,15 @@ void EventThread::generateFrameTimeline(VsyncEventData& outVsyncEventData, nsecs preferredExpectedPresentationTime + multiplier * frameInterval; if (expectedPresentationTime >= preferredExpectedPresentationTime + scheduler::VsyncConfig::kEarlyLatchMaxThreshold.count()) { + if (currentIndex == 0) { + ALOGW("%s: Expected present time is too far in the future but no timelines are " + "valid. preferred EPT=%" PRId64 ", Calculated EPT=%" PRId64 + ", multiplier=%" PRId64 ", frameInterval=%" PRId64 ", threshold=%" PRId64, + __func__, preferredExpectedPresentationTime, expectedPresentationTime, + multiplier, frameInterval, + static_cast( + scheduler::VsyncConfig::kEarlyLatchMaxThreshold.count())); + } break; } @@ -625,6 +634,20 @@ void EventThread::generateFrameTimeline(VsyncEventData& outVsyncEventData, nsecs .expectedPresentationTime = expectedPresentationTime}; currentIndex++; } + + if (currentIndex == 0) { + ALOGW("%s: No timelines are valid. preferred EPT=%" PRId64 ", frameInterval=%" PRId64 + ", threshold=%" PRId64, + __func__, preferredExpectedPresentationTime, frameInterval, + static_cast(scheduler::VsyncConfig::kEarlyLatchMaxThreshold.count())); + outVsyncEventData.frameTimelines[currentIndex] = + {.vsyncId = generateToken(timestamp, preferredDeadlineTimestamp, + preferredExpectedPresentationTime), + .deadlineTimestamp = preferredDeadlineTimestamp, + .expectedPresentationTime = preferredExpectedPresentationTime}; + currentIndex++; + } + outVsyncEventData.frameTimelinesLength = currentIndex; } -- cgit v1.2.3-59-g8ed1b