SF: Update RefreshRateOverlay before SF applies transactions
The current implementation of RefreshRateOverlay changes it's buffer
to reflect the upcoming refresh rate after SF applies transaction.
This is causing SF to see a layer update and reset the idle timer,
entering a live loop of refresh rate switches.
Instead, we update the RefreshRateOverlay when the refresh rate change is
done and before SF applies transactions for the next frame.
Bug: 192204776
Test: Enable RefreshRateOverlay on a device with idle timer enabled
Change-Id: Ie904d6f37b7a02126d52a6267246afaf33982eff
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9c04fbf..8df0852 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1189,6 +1189,10 @@
updatePhaseConfiguration(refreshRate);
ATRACE_INT("ActiveConfigFPS", refreshRate.getValue());
+ if (mRefreshRateOverlay) {
+ mRefreshRateOverlay->changeRefreshRate(upcomingMode->getFps());
+ }
+
if (mUpcomingActiveMode.event != Scheduler::ModeEvent::None) {
const nsecs_t vsyncPeriod = refreshRate.getPeriodNsecs();
const auto physicalId = display->getPhysicalId();
@@ -1271,9 +1275,6 @@
}
mScheduler->onNewVsyncPeriodChangeTimeline(outTimeline);
- if (mRefreshRateOverlay) {
- mRefreshRateOverlay->changeRefreshRate(desiredMode->getFps());
- }
// Scheduler will submit an empty frame to HWC if needed.
mSetActiveModePending = true;