perf(compositor): draw a new frame when it arrives (#1707)

A new game frame waited for the next screen tick before the compositor
drew it: 1.9-3.5 ms on average at 144 Hz, measured with the pacing
counters. With frames going straight back to the game (no compositor
limit), the compositor now draws as soon as the clients' requests are
handled, at most once per refresh, and presentation times stay on the
tick.

gamescope delivers about one frame per refresh, so the tick leaves a
frame younger than one refresh for the next arrival to draw, unless the
tick itself changed the window, effects or headset pose; a frame no
other frame follows is drawn at the tick after. Once a held frame is
still waiting at the next tick (a client paced by frame callbacks), the
tick draws every frame for a second before holding one again. The
queued draw checks again that drawing on arrival is still on.

Paced output (glasses), streaming and frame generation keep drawing on
the tick. The hidden pref renderOnCommit (default on) turns it off. The
pacing log line counts the scenes drawn on arrival. On the device new
frames wait 0.12 ms instead of ~2 ms.
This commit is contained in:
The412Banner authored and GitHub committed 2026-10-28 09:21:07 +00:00
1 parent 8c4f97a170
commit 8549ac9ce8
6 files changed
+283 -7

No files matched your search

@@ -603,6 +603,7 @@ object SessionPrefs {
fun mangoapp(context: Context): Boolean = prefs(context).getBoolean("mangoapp", true)
fun vsyncThread(context: Context): Boolean = prefs(context).getBoolean("vsyncThread", true)
fun renderOnCommit(context: Context): Boolean = prefs(context).getBoolean("renderOnCommit", true)
fun setMangoapp(context: Context, on: Boolean) { prefs(context).edit().putBoolean("mangoapp", on).apply() }
fun zinkLazy(context: Context): Boolean = prefs(context).getBoolean("zinkLazy", true)
@@ -53,6 +53,7 @@ object CompositorHost {
fpsLimit: Int,
): Boolean {
ownVsyncThread = SessionPrefs.vsyncThread(context)
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
pace(refreshHz, fpsLimit)
if (!SessionState.running) WaylandCompositor.nativeSetOutputSize(outputWidth, outputHeight)
if (started) {
@@ -284,6 +284,8 @@ public final class WaylandCompositor {
public static native void nativeSetFpsLimit(int fps);
public static native void nativeSetRenderOnCommit(boolean on);
public static native void nativeSetGpuTurbo(boolean on);
public static native int nativeRaisePriority(int tid, int nice);