SF: update VSP timebase on error condition
When an vsync timestamp is recorded that is anonmolous to the currently
recorded timestamp ringbuffer, update the timebase for synthetic
calculations.
Test: 2 new unit tests
Test: visual spot checking interactions on pixel4 device
Test: uibench a/b anti-regression
Test: dogfood with patch based one recent rvc build.
Fixes: 159882858
Change-Id: Ie201cd593a54586d9b1f488c6d2ca44178d75cf1
diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
index a3cb772..ab5773d 100644
--- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
+++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
@@ -77,7 +77,14 @@
std::lock_guard<std::mutex> lk(mMutex);
if (!validate(timestamp)) {
- ALOGV("timestamp was too far off the last known timestamp");
+ // VSR could elect to ignore the incongruent timestamp or resetModel(). If ts is ignored,
+ // don't insert this ts into mTimestamps ringbuffer.
+ if (!mTimestamps.empty()) {
+ mKnownTimestamp =
+ std::max(timestamp, *std::max_element(mTimestamps.begin(), mTimestamps.end()));
+ } else {
+ mKnownTimestamp = timestamp;
+ }
return false;
}
@@ -236,7 +243,13 @@
void VSyncPredictor::clearTimestamps() {
if (!mTimestamps.empty()) {
- mKnownTimestamp = *std::max_element(mTimestamps.begin(), mTimestamps.end());
+ auto const maxRb = *std::max_element(mTimestamps.begin(), mTimestamps.end());
+ if (mKnownTimestamp) {
+ mKnownTimestamp = std::max(*mKnownTimestamp, maxRb);
+ } else {
+ mKnownTimestamp = maxRb;
+ }
+
mTimestamps.clear();
mLastTimestampIndex = 0;
}