diff options
| author | 2020-11-10 20:16:03 -0800 | |
|---|---|---|
| committer | 2020-11-23 19:11:28 +0000 | |
| commit | 6de88c4747d86983d52fc10edf05561bfa0e741c (patch) | |
| tree | 2354483e9e40d182e03d23e342f4c139a909c58c | |
| parent | c12fbffe466aaf4f30edf8b2bb987d3b7a754374 (diff) | |
SurfaceFlinger: expectedVsyncTimestamp can be 0
Scheduler::isVsyncValid can be called with expectedVsyncTimestamp as 0
if it is called from Layer::latchAndReleaseBuffer. If we send the vsync
timestamp as 0 to VSyncTracker, it may change the phase for the current
divider which will cause jank.
Test: run bouncyball and observe systraces
Change-Id: Ic0b0ea895497891a22badc9c67cea5c23698fc2c
| -rw-r--r-- | services/surfaceflinger/Scheduler/VSyncPredictor.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp index a28ed929de..a6f9372a5c 100644 --- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp +++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp @@ -222,10 +222,10 @@ nsecs_t VSyncPredictor::nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const { /* * Returns whether a given vsync timestamp is in phase with a vsync divider. - * For example, if the vsync timestamps are (0,16,32,48): - * isVSyncInPhase(0, 2) = true - * isVSyncInPhase(16, 2) = false - * isVSyncInPhase(32, 2) = true + * For example, if the vsync timestamps are (16,32,48,64): + * isVSyncInPhase(16, 2) = true + * isVSyncInPhase(32, 2) = false + * isVSyncInPhase(48, 2) = true */ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { struct VsyncError { @@ -235,11 +235,11 @@ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { bool operator<(const VsyncError& other) const { return error < other.error; } }; - std::lock_guard lock(mMutex); - if (divider <= 1) { + if (divider <= 1 || timePoint == 0) { return true; } + std::lock_guard lock(mMutex); const nsecs_t period = mRateMap[mIdealPeriod].slope; const nsecs_t justBeforeTimePoint = timePoint - period / 2; const nsecs_t dividedPeriod = mIdealPeriod / divider; |