Update lastExpectedPresentTime when cadence changes
When cadence changes, updating the
lastExpectedPresentTime prevents from
having an expected present time from a different cadence.
From getDeviceCompositionChanges we only store
the future expectedPresentTime.
getDeviceCompositionChanges follows after
onVsyncGenerated and stores the
expectedPresentTime otherwise from the past when rate changes.
This causes the next onVsyncGenerated to think
that the rate has changed, while it stayed the
same, and SF is flushing rest of the buffers
at the previous rate.
BUG: 296636253
BUG: 296635769
Test: manual
Change-Id: Ifb45d875e381a737b5e944d2e6cb080c5eb81196
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 4d6c349..8be3a38 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -540,8 +540,9 @@
displayData.validateWasSkipped = false;
{
std::scoped_lock lock{displayData.expectedPresentLock};
- displayData.lastExpectedPresentTimestamp = TimePoint::fromNs(expectedPresentTime);
- // TODO(b/296636176) Update displayData.lastFrameInterval for present display commands
+ if (expectedPresentTime > displayData.lastExpectedPresentTimestamp.ns()) {
+ displayData.lastExpectedPresentTimestamp = TimePoint::fromNs(expectedPresentTime);
+ }
}
if (canSkipValidate) {
@@ -965,6 +966,11 @@
isExpectedPresentWithinTimeout(expectedPresentTime, lastExpectedPresentTimestamp,
timeoutOpt, threshold);
+ using fps_approx_ops::operator!=;
+ if (frameIntervalIsOnCadence && frameInterval != lastFrameInterval) {
+ displayData.lastExpectedPresentTimestamp = expectedPresentTime;
+ }
+
if (expectedPresentWithinTimeout && frameIntervalIsOnCadence) {
return NO_ERROR;
}