[PR #6779] [MERGED] Wait instead of polling when a frame does not reach the screen #7089

Closed
opened 2026-11-03 06:33:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6779
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/no-frame-no-spin


📝 Commits (1)

  • d89499c Wait instead of polling when a frame does not reach the screen

📊 Changes

1 file changed (+18 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+18 -1)

📄 Description

Game::idle (winit's about_to_wait) ends every pass with w.request_redraw() and
ControlFlow::Poll, so each pass asks for another one immediately. While the compositor answers
with RedrawRequested that is correct, because the renderer paces the frame itself. A hidden
Wayland window gets no RedrawRequested at all, so the loop kept going through about_to_wait
with nothing to draw: one core pinned, and the window never repainted - the two symptoms in the
report.

The renderer already reports the case: Gfx::render returns Ok(false) when the surface refuses
the frame (CurrentSurfaceTexture::Occluded, lost or timed out). That answer is now kept on the
game as frame_drawn, and idle polls only while the last frame reached the swap chain; otherwise
it waits up to 16 ms for an event, which is a resize or occlusion change that wakes the loop and
lets the next frame set the pace back to polling.

Proven: cargo check -q -p horizon-client --lib clean and cargo clippy -q -p horizon-client --lib clean on the build VM; rustfmt --edition 2024 --check clean.

Not proven: the CPU saving itself - this box is headless X, not Wayland, so I could not hide a
window and watch the core. The check is the report's own: on Wayland, hide or iconify the window
with the game in a world and watch the process drop to idle instead of pinning a core, then bring it
back and confirm it resumes drawing immediately.

Limits: the pacing is a wait rather than a stop, so a hidden window still wakes 60 times a second -
enough to stop the spin, not to reach zero. A frame that fails for a reason other than occlusion
(a lost surface) also drops the loop to 60 Hz until the next successful frame, which the device
recovery path already handles.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6779 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/no-frame-no-spin` --- ### 📝 Commits (1) - [`d89499c`](https://github.com/horizon-rust/horizon/commit/d89499c0aedde2cbb309dfe7ff92225d79c4ba24) Wait instead of polling when a frame does not reach the screen ### 📊 Changes **1 file changed** (+18 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+18 -1) </details> ### 📄 Description `Game::idle` (winit's `about_to_wait`) ends every pass with `w.request_redraw()` and `ControlFlow::Poll`, so each pass asks for another one immediately. While the compositor answers with `RedrawRequested` that is correct, because the renderer paces the frame itself. A hidden Wayland window gets no `RedrawRequested` at all, so the loop kept going through `about_to_wait` with nothing to draw: one core pinned, and the window never repainted - the two symptoms in the report. The renderer already reports the case: `Gfx::render` returns `Ok(false)` when the surface refuses the frame (`CurrentSurfaceTexture::Occluded`, lost or timed out). That answer is now kept on the game as `frame_drawn`, and `idle` polls only while the last frame reached the swap chain; otherwise it waits up to 16 ms for an event, which is a resize or occlusion change that wakes the loop and lets the next frame set the pace back to polling. **Proven:** `cargo check -q -p horizon-client --lib` clean and `cargo clippy -q -p horizon-client --lib` clean on the build VM; `rustfmt --edition 2024 --check` clean. **Not proven:** the CPU saving itself - this box is headless X, not Wayland, so I could not hide a window and watch the core. The check is the report's own: on Wayland, hide or iconify the window with the game in a world and watch the process drop to idle instead of pinning a core, then bring it back and confirm it resumes drawing immediately. Limits: the pacing is a wait rather than a stop, so a hidden window still wakes 60 times a second - enough to stop the spin, not to reach zero. A frame that fails for a reason other than occlusion (a lost surface) also drops the loop to 60 Hz until the next successful frame, which the device recovery path already handles. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:33:35 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7089
No description provided.