schedule vsync immediately when requested from the Looper thread

This patch allows Choreographer to schedule vsync immediately when it
is requested from the Looper thread. Previously this is not allowed
when vsync is already scheduled from a binder thread and hence there
is a delay up to 16ms (one vsync interval) in processing frame
callbacks.

Change-Id: Idd70f1a6c359e92ecebd778a104b71dfa6660c79
Signed-off-by: Dohyun Lee <dohyun.lee@lge.com>
Signed-off-by: mydongistiny <jaysonedson@gmail.com>
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2025-12-01 22:14:43 +07:00
parent 842dcf613f
commit 5b3c824b5d

View File

@@ -872,6 +872,19 @@ public final class Choreographer {
msg.setAsynchronous(true);
mHandler.sendMessageAtTime(msg, nextFrameTime);
}
} else {
if (USE_VSYNC) {
if (mHandler.hasMessages(MSG_DO_SCHEDULE_VSYNC)) {
// If running on the Looper thread, then schedule the vsync immediately.
if (isRunningOnLooperThreadLocked()) {
if (DEBUG_FRAMES) {
Log.d(TAG, "Scheduling next frame on vsync.");
}
scheduleVsyncLocked();
mHandler.removeMessages(MSG_DO_SCHEDULE_VSYNC);
}
}
}
}
}