Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 139146a3 authored by Melody Hsu's avatar Melody Hsu
Browse files

Fix divide by 0 for calculating vsyncs in buffer stuffing recovery

Arithmetic error when calculating number of vsyncs that have occurred
since last callback. Default number of vsyncs passed should be 0
whenever mLastFrameIntervalNanos is an invalid divisor.

Change-Id: I2e357b1cad9cd98c6bd7143100a7892c64a0bcbe
Fixes: 378981155
Test: presubmit
Flag: EXEMPT bug fix
parent b574b17b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -930,8 +930,8 @@ public final class Choreographer {
            // of the next vsync event.
            int totalFrameDelays = mBufferStuffingData.numberFrameDelays
                    + mBufferStuffingData.numberWaitsForNextVsync + 1;
            long vsyncsSinceLastCallback =
                    (frameTimeNanos - mLastNoOffsetFrameTimeNanos) / mLastFrameIntervalNanos;
            long vsyncsSinceLastCallback = mLastFrameIntervalNanos > 0
                    ? (frameTimeNanos - mLastNoOffsetFrameTimeNanos) / mLastFrameIntervalNanos : 0;

            // Detected idle state due to a longer inactive period since the last vsync callback
            // than the total expected number of vsync frame delays. End buffer stuffing recovery.