summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdy Abraham <adyabr@google.com>2021-07-27 16:27:56 -0700
committerAdy Abraham <adyabr@google.com>2021-08-30 20:54:17 +0000
commit71c8a95838a45fa12fa2aa519a0700186202a315 (patch)
tree469894be9c8a399bdc45a5495413bb5e3e4a900b
parentae01ea5aea14a038488bb76c4f0bbcb65d1d43ac (diff)
downloadnative-71c8a95838a45fa12fa2aa519a0700186202a315.tar.gz
SF: fix a bug with DISPLAY_EVENT_MODE_CHANGE
SF might dispatch a DISPLAY_EVENT_MODE_CHANGE event before changing the actual mode. This can happen when the mode change takes more than a single refresh and caused by incorrectly checking the previously reported event without checking for the current mode. Bug: 194515308 Bug: 193945763 Test: SF unit tests Change-Id: Icf44e0fb6aadb76e629cd408907389e2626d2047 Merged-In: Icf44e0fb6aadb76e629cd408907389e2626d2047
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index e0b364020b..64ad178b26 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -386,6 +386,13 @@ void Scheduler::dispatchCachedReportedMode() {
}
const auto modeId = *mFeatures.modeId;
+ // If the modeId is not the current mode, this means that a
+ // mode change is in progress. In that case we shouldn't dispatch an event
+ // as it will be dispatched when the current mode changes.
+ if (mRefreshRateConfigs.getCurrentRefreshRate().getModeId() != modeId) {
+ return;
+ }
+
const auto vsyncPeriod = mRefreshRateConfigs.getRefreshRateFromModeId(modeId).getVsyncPeriod();
// If there is no change from cached mode, there is no need to dispatch an event