Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit aeaadb8

Browse files
committed
Ensure that frameTimeNanos passed to VsyncWaiterAndroid is not greater than System.nanoTime
1 parent 14d170d commit aeaadb8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shell/platform/android/io/flutter/view/VsyncWaiter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public void asyncWaitForVsync(long cookie) {
3131
new Choreographer.FrameCallback() {
3232
@Override
3333
public void doFrame(long frameTimeNanos) {
34+
// Some device is calling doFrame with a timestamp that is greater than
35+
// System.nanoTime. We should ensure that frameTimeNanos passed to
36+
// VsyncWaiterAndroid is not greater than System.nanoTime.
37+
long now = System.nanoTime();
38+
if (frameTimeNanos > now) {
39+
frameTimeNanos = now;
40+
}
3441
long refreshPeriodNanos = (long) (1000000000.0 / fps);
3542
FlutterJNI.nativeOnVsync(
3643
frameTimeNanos, frameTimeNanos + refreshPeriodNanos, cookie);

0 commit comments

Comments
 (0)