diff options
| author | 2022-04-22 14:31:18 -0700 | |
|---|---|---|
| committer | 2022-04-22 14:35:38 -0700 | |
| commit | 3ac2e435a6691c09fe777a10a3316e85cdbcc2c3 (patch) | |
| tree | 66a883e71a002d8fb45a0179a5a43deb55179eea | |
| parent | b88d3d4718e462731280b677f5bf19933106efc2 (diff) | |
Add check for empty vsync data in Choreographer.
Currently there is a codepath in native DisplayEventDispatcher
introduced by aosp fc690e2a2d1d3cf08d71a02c4ecd14665c0f2039.
It accounts for vsync timeout. Here in java choreographer, we don't want
to divide by zero for logging messages so a check is added. There are no
real logic changes.
Test: atest ChoreographerTest
Bug: 229685140
Change-Id: I80f24abb89b9d961b017aca93340b1b02af6f66c
| -rw-r--r-- | core/java/android/view/Choreographer.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java index 60593ca46bcb..77591a7efb5e 100644 --- a/core/java/android/view/Choreographer.java +++ b/core/java/android/view/Choreographer.java @@ -765,18 +765,24 @@ public final class Choreographer { startNanos = System.nanoTime(); final long jitterNanos = startNanos - frameTimeNanos; if (jitterNanos >= frameIntervalNanos) { - final long skippedFrames = jitterNanos / frameIntervalNanos; - if (skippedFrames >= SKIPPED_FRAME_WARNING_LIMIT) { - Log.i(TAG, "Skipped " + skippedFrames + " frames! " - + "The application may be doing too much work on its main thread."); - } final long lastFrameOffset = jitterNanos % frameIntervalNanos; - if (DEBUG_JANK) { - Log.d(TAG, "Missed vsync by " + (jitterNanos * 0.000001f) + " ms " - + "which is more than the frame interval of " - + (frameIntervalNanos * 0.000001f) + " ms! " - + "Skipping " + skippedFrames + " frames and setting frame " - + "time to " + (lastFrameOffset * 0.000001f) + " ms in the past."); + if (frameIntervalNanos == 0) { + Log.i(TAG, "Vsync data empty due to timeout"); + } else { + final long skippedFrames = jitterNanos / frameIntervalNanos; + if (skippedFrames >= SKIPPED_FRAME_WARNING_LIMIT) { + Log.i(TAG, "Skipped " + skippedFrames + " frames! " + + "The application may be doing too much work on its main " + + "thread."); + } + if (DEBUG_JANK) { + Log.d(TAG, "Missed vsync by " + (jitterNanos * 0.000001f) + " ms " + + "which is more than the frame interval of " + + (frameIntervalNanos * 0.000001f) + " ms! " + + "Skipping " + skippedFrames + " frames and setting frame " + + "time to " + (lastFrameOffset * 0.000001f) + + " ms in the past."); + } } frameTimeNanos = startNanos - lastFrameOffset; DisplayEventReceiver.VsyncEventData latestVsyncEventData = |