Skip to content

gtk: present on demand (Repainter), not every tick - #94

Merged
tannevaled merged 1 commit into
mainfrom
feat/gtk-repainter
Aug 31, 2026
Merged

gtk: present on demand (Repainter), not every tick#94
tannevaled merged 1 commit into
mainfrom
feat/gtk-repainter

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The GTK backend blitted a full frame every vsync — layout + texture upload + recompose at 60 Hz even on an idle window. Implement window.Repainter (the policy the Cocoa backend already uses): Repaint() raises a flag (cheap, any goroutine, no GTK call off the main thread, no callback allocation), and the frame clock — one persistent main-thread pump — presents only when the flag is set. go-widgets/application's present loop calls Repaint gated by the handler's NeedsPresent, so a still window draws nothing.

Measured with the reader under Xvfb: idle presents fall from ~100% of ticks to ~7% (heartbeat + spinner cadence) — a ~15× cut in idle uploads — UI unchanged. Compile-time assertion pins the capability; TestRepaintGating pins the present-once-per-Repaint contract display-free.

The GTK back-end blitted a full frame every vsync — one layout + texture upload +
recompose at 60 Hz even on an idle, unchanged window. Implement window.Repainter
instead, the policy the Cocoa back-end already uses: Repaint() raises a flag (cheap,
callable from any goroutine, no GTK call off the main thread, no callback
allocation), and the frame clock — the one persistent main-thread pump — presents
only when the flag is set. go-widgets/application's present loop calls Repaint at up
to 60 Hz gated by the handler's NeedsPresent, so a still window draws nothing.

Measured with the reader under Xvfb: idle presents fall from ~100% of ticks to
~7% (heartbeat + spinner cadence) — a ~15× cut in idle uploads — with the UI
unchanged. A compile-time assertion pins the capability; TestRepaintGating pins the
present-once-per-Repaint contract without a display.
@tannevaled
tannevaled merged commit 93106b1 into main Aug 31, 2026
28 checks passed
@tannevaled
tannevaled deleted the feat/gtk-repainter branch August 31, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant