SF: Reset VsyncModulator on active display change
Between VsyncModulator::onRefreshRateChange{Initiated,Completed}, if the
active display changes, the newly active display's VsyncConfiguration is
propagated to VsyncModulator via updatePhaseConfiguration, which selects
VsyncConfigType::Early due to the `mRefreshRateChangePending` of the now
inactive display.
Clear `mRefreshRateChangePending` and let `onRefreshRateChangeInitiated`
set it for the newly active display if needed.
In practice, the end result is the same due to the forced modeset for an
active display that was just powered on. However, this will no longer be
true with concurrent displays when the new pacesetter is already powered
on.
Bug: 255635821
Test: DisplayModeSwitchingTest.multiDisplay
Change-Id: If264742a107cf5839d2c820eab23712778c1ae2e
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index cfcb4ed..54889fa 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3452,7 +3452,7 @@
// TODO(b/175678251) Call a listener instead.
if (currentState.physical->hwcDisplayId == getHwComposer().getPrimaryHwcDisplayId()) {
- updateActiveDisplayVsyncLocked(*display);
+ resetPhaseConfiguration(display->getActiveMode().fps);
}
}
return;
@@ -3486,9 +3486,11 @@
}
}
-void SurfaceFlinger::updateActiveDisplayVsyncLocked(const DisplayDevice& activeDisplay) {
+void SurfaceFlinger::resetPhaseConfiguration(Fps refreshRate) {
+ // Cancel the pending refresh rate change, if any, before updating the phase configuration.
+ mScheduler->vsyncModulator().cancelRefreshRateChange();
+
mVsyncConfiguration->reset();
- const Fps refreshRate = activeDisplay.getActiveMode().fps;
updatePhaseConfiguration(refreshRate);
mRefreshRateStats->setRefreshRate(refreshRate);
}
@@ -4303,9 +4305,8 @@
// We don't want to latch unsignaled if are in early / client composition
// as it leads to jank due to RenderEngine waiting for unsignaled buffer
// or window animations being slow.
- const auto isDefaultVsyncConfig = mScheduler->vsyncModulator().isVsyncConfigDefault();
- if (!isDefaultVsyncConfig) {
- ALOGV("%s: false (LatchUnsignaledConfig::AutoSingleLayer; !isDefaultVsyncConfig)",
+ if (mScheduler->vsyncModulator().isVsyncConfigEarly()) {
+ ALOGV("%s: false (LatchUnsignaledConfig::AutoSingleLayer; isVsyncConfigEarly)",
__func__);
return false;
}
@@ -7692,7 +7693,8 @@
mActiveDisplayId = activeDisplay.getPhysicalId();
activeDisplay.getCompositionDisplay()->setLayerCachingTexturePoolEnabled(true);
- updateActiveDisplayVsyncLocked(activeDisplay);
+ resetPhaseConfiguration(activeDisplay.getActiveMode().fps);
+
mScheduler->setModeChangePending(false);
mScheduler->setPacesetterDisplay(mActiveDisplayId);