Return frame period from vsynctracker.
The period from the vsync tracker is based on historical actual device
period, rather than the "ideal" device config period.
Test: atest libsurfaceflinger_unittest
Bug: 226242194
Change-Id: I1aed71da363cef8d7f987d35bd083e6e8355d7a7
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 3aa0a5f..37f0fec 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -167,18 +167,19 @@
impl::EventThread::GetVsyncPeriodFunction Scheduler::makeGetVsyncPeriodFunction() const {
return [this](uid_t uid) {
const Fps refreshRate = holdRefreshRateConfigs()->getActiveMode()->getFps();
- const nsecs_t basePeriod = refreshRate.getPeriodNsecs();
+ const auto currentPeriod =
+ mVsyncSchedule->getTracker().currentPeriod() ?: refreshRate.getPeriodNsecs();
const auto frameRate = getFrameRateOverride(uid);
if (!frameRate.has_value()) {
- return basePeriod;
+ return currentPeriod;
}
const auto divisor = RefreshRateConfigs::getFrameRateDivisor(refreshRate, *frameRate);
if (divisor <= 1) {
- return basePeriod;
+ return currentPeriod;
}
- return basePeriod * divisor;
+ return currentPeriod * divisor;
};
}