[GH-ISSUE #7266] FPS stays capped at the refresh rate after alt-tabbing and clicking another app (VSync off, unlimited frame rate) #3192

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

Originally created by @jaszkus on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7266

Originally assigned to: @jaszkus on GitHub.

🤖 Opened by jaszkus's AI agent, not by jaszkus himself.

What happens

With VSync off and the frame rate set to unlimited, the game comes back capped at the monitor's refresh rate after a particular way of switching away and back:

  1. Press Alt+Tab, then click on any other app (so that app takes the click and focus), then switch back to Horizon → the FPS counter (F3) sits at the refresh rate and stays there.
  2. Press Alt+Tab and switch straight back without clicking anything in another app → unlimited, as configured.

The setting itself does not change: the Cap/V-Sync options still read as before, and F3 reports the capped number. It looks like the loop stays in "wait for the next event" mode instead of going back to drawing flat out.

Expected

Returning focus leaves the frame rate exactly as configured (unlimited here), whichever way the window lost focus.

Where it probably lives

Not confirmed, just the places that decide the pace:

  • crates/horizon-client/src/game.rs::idle — after asking for a redraw, frame_drawn picks ControlFlow::Poll or ControlFlow::WaitUntil(now + 16 ms); a frame that never reaches the swap chain leaves the loop waiting, and the comment there says the next frame "sets the pace back to polling".
  • WindowEvent::Focused in game.rs — sets self.focused and releases the pointer, and does not touch the pace.
  • crates/horizon-client-render/src/compositor.rs::set_vsync and frame_gen.rs (vsync = config.present_mode == Fifo) — the present mode as the surface sees it.
  • crates/horizon-client/src/game.rs::render — an Ok(false) from the surface (occluded, lost, timed out) is a frame that did not draw.

A click in another app and a plain Alt+Tab probably differ in whether Windows marks the window occluded, which would explain the split.

More to confirm

  • GPU, driver and Windows build (this was Windows 11 with an Intel GPU).
  • Whether it happens in a world only, or also on the title screen.
  • Single player (server thread) and multiplayer alike?
  • Whether changing the Cap/V-Sync option and back clears it without restarting.

Environment

  • Windows 11, release launcher build; FPS read from the game's own F3 counter.
Originally created by @jaszkus on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7266 Originally assigned to: @jaszkus on GitHub. > 🤖 Opened by jaszkus's AI agent, not by jaszkus himself. ## What happens With VSync off and the frame rate set to unlimited, the game comes back capped at the monitor's refresh rate after a particular way of switching away and back: 1. Press **Alt+Tab**, then **click on any other app** (so that app takes the click and focus), then switch back to Horizon → the FPS counter (F3) sits at the refresh rate and stays there. 2. Press **Alt+Tab** and switch straight back without clicking anything in another app → unlimited, as configured. The setting itself does not change: the Cap/V-Sync options still read as before, and `F3` reports the capped number. It looks like the loop stays in "wait for the next event" mode instead of going back to drawing flat out. ## Expected Returning focus leaves the frame rate exactly as configured (unlimited here), whichever way the window lost focus. ## Where it probably lives Not confirmed, just the places that decide the pace: - `crates/horizon-client/src/game.rs::idle` — after asking for a redraw, `frame_drawn` picks `ControlFlow::Poll` or `ControlFlow::WaitUntil(now + 16 ms)`; a frame that never reaches the swap chain leaves the loop waiting, and the comment there says the next frame "sets the pace back to polling". - `WindowEvent::Focused` in `game.rs` — sets `self.focused` and releases the pointer, and does not touch the pace. - `crates/horizon-client-render/src/compositor.rs::set_vsync` and `frame_gen.rs` (`vsync = config.present_mode == Fifo`) — the present mode as the surface sees it. - `crates/horizon-client/src/game.rs::render` — an `Ok(false)` from the surface (occluded, lost, timed out) is a frame that did not draw. A click in another app and a plain Alt+Tab probably differ in whether Windows marks the window occluded, which would explain the split. ## More to confirm - GPU, driver and Windows build (this was Windows 11 with an Intel GPU). - Whether it happens in a world only, or also on the title screen. - Single player (server thread) and multiplayer alike? - Whether changing the Cap/V-Sync option and back clears it without restarting. ## Environment - Windows 11, release launcher build; FPS read from the game's own F3 counter.
Author
Owner

@jaszkus commented on GitHub (Nov 2, 2026):

/claim

<!-- gh-comment-id:6578931090 --> @jaszkus commented on GitHub (Nov 2, 2026): /claim
Author
Owner

@jaszkus commented on GitHub (Nov 2, 2026):

🤖 Agent (jaszkus): more data from the same machine — sometimes a plain Alt+Tab is enough, with no click in another app. It does not happen on every switch, but when it does the cap stays until the option is changed or the game is restarted.

That weakens the "occluded" theory: occlusion is not required, so a focus flag or the loop's pace after a focus change is the likelier place.

Two codes paths to tell apart, and the number that decides between them:

  • crates/horizon-client/src/game/options.rs — Game::framerate_limit builds vanilla's FrameContext with focused: self.focused, and limit_frame sleeps/spins to that limit. If focused stays false (or the AFK branch stays on), vanilla's own rule applies: 30 FPS for AFK, 10 for minimized — not the refresh rate.
  • crates/horizon-client-render/src/compositor.rs (set_vsync) and gfx/frame_gen.rs (vsync = present_mode == Fifo), plus game.rs::idle (ControlFlow::Poll vs WaitUntil(16 ms)): these produce exactly the monitor's refresh rate, or about 60, rather than 30/10.

So: what does F3 report when it is stuck, and what is the monitor (Hz)? If it is exactly the refresh rate, it is the present mode/loop pace; if it is 30, it is the AFK limit on a stale focused.

<!-- gh-comment-id:6579036769 --> @jaszkus commented on GitHub (Nov 2, 2026): 🤖 Agent (jaszkus): more data from the same machine — **sometimes a plain Alt+Tab is enough**, with no click in another app. It does not happen on every switch, but when it does the cap stays until the option is changed or the game is restarted. That weakens the "occluded" theory: occlusion is not required, so a focus flag or the loop's pace after a focus change is the likelier place. Two codes paths to tell apart, and the number that decides between them: - `crates/horizon-client/src/game/options.rs` — `Game::framerate_limit` builds vanilla's `FrameContext` with `focused: self.focused`, and `limit_frame` sleeps/spins to that limit. If `focused` stays `false` (or the AFK branch stays on), vanilla's own rule applies: 30 FPS for AFK, 10 for minimized — **not** the refresh rate. - `crates/horizon-client-render/src/compositor.rs` (`set_vsync`) and `gfx/frame_gen.rs` (`vsync = present_mode == Fifo`), plus `game.rs::idle` (`ControlFlow::Poll` vs `WaitUntil(16 ms)`): these produce exactly the monitor's refresh rate, or about 60, rather than 30/10. So: what does F3 report when it is stuck, and what is the monitor (Hz)? If it is exactly the refresh rate, it is the present mode/loop pace; if it is 30, it is the AFK limit on a stale `focused`.
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#3192
No description provided.