feat(audio): Pause in background, the game stopped while its window is behind another one or minimised #2786

Merged
HumanBean merged 7 commits from llun/Longshot:feat/pause-in-background into main 2026-11-29 06:12:33 +00:00
Member

Summary

A player asked for an option that stops the whole game, not just its sound, while it is in the background, to save power.
Until now only Mute in background existed: behind another window or minimised, the game kept running at full speed,
on this PC about 2.7 CPU cores and 37% of an RTX 5080.

This adds Pause in background on the Gameplay tab, right after Game speed, off by default
(pause_in_background in longshot_options.ini). With it on, while another window has the focus or the game's window is
minimised, the game stops: no game logic, no frames rendered or presented, no sound. The CPU and GPU go nearly idle. When
the window comes back to the front, the game goes on where it was, with no catch-up and no burst of sound.

Pause in background takes over two other rows. Turning it on turns Mute in background on and Controller in
background off
(a stopped game can't be played from behind another window). While Pause is on, both rows stay that way
and are locked, including in a hand-edited options file. The menu says so on all three:

  • Pause in background's hint: "Mute in background is on and Controller in background is off while this is on."
  • Mute in background: "On while Pause in background (Gameplay tab) is on."
  • Controller in background: "Off while Pause in background (Gameplay tab) is on..."
  • The renderer also tells the host Mute is on while Pause is on, so the moment before a hold is silent too.

How it works, for review (read host/background_pause.c first):

  • The rows: gpu/vk/menu/gameplay.cpp (Pause in background, with an on_change that turns Mute in background on
    and Controller in background off), gpu/vk/menu/volume.cpp (Mute in background) and gpu/vk/menu/controller.cpp
    (Controller in background). The latter two get locked and sync while Pause is on, and hints whose variants end so
    the menu can size the help.
  • Where the game holds: hos_vi_native_acquire (host/nn_vi.c). This is the first host code of every game frame, on
    the main thread, outside the game's locks, with its virtual core already given up; it is where the console blocks for a
    free window texture. The thread waits on an event that the window's focus changes set (host/display.c
    WM_ACTIVATEAPP / WM_SETFOCUS / WM_SIZE, host/posix/display_sdl.c SDL focus events), with a 250 ms timeout. It
    never spins. The workers, the renderer, its presenter and frame generation's display thread get no new frame and idle.
  • Presentation is untouched. The presenter and the swapchain are not changed at all, to stay clear of the Alt+Tab
    held-image area of #1482 and #2083. The last frame simply stays on screen.
  • A movie (host/nn_video.c): its clock is the wall's less the time held (movie_now, hos_background_held_ns),
    so after a hold it goes on from the picture it stopped at, as its sound does, with nothing skipped.
  • Sound (host/nn_audio.c renderer_main): the mixer fades its last frame out to exactly 0, then mixes nothing and
    stops signalling the game's sound thread. On resume the voices go on from the sample they stopped at, faded in.
  • Resume: the frame after a hold starts as after a load. The real-time step already drops a frame over 0.25 s, and
    pacing restarts from now, so nothing fast-forwards. The renderer leaves the frame that spans the hold out of its frame
    times and the performance summary (HOS_OPT_BACKGROUND_PAUSED through the existing option_set, gpu/vk/vk_fps.cpp
    fps_hold_gap). Without this, a 5-minute pause would be sent as a 5-minute hitch.
  • Which windows count as the game's: the same rule as Mute in background. An overlay (Steam's, Discord's, a toast)
    counts as the game's while the game was the last normal window in front. A hold starts only after 200 ms out of front,
    because Windows' foreground is briefly nobody's during a switch.
  • When it never holds: at start-up before the window has been in front once (the launcher keeps the window hidden
    until the first frame), and in runs with no window to come back to: HOS_HEADLESS, HOS_WINDOW_NOACTIVATE (test runs
    opened behind) and HOS_INPUT_PLAY.
  • Hang watches: the GPU hang watch counts only work sent and not finished, so a hold is not a hang to it (checked
    with a 4-minute hold). The opt-in RX_VK_HANG_DUMP watchdog writes one stack dump after 20 s without a present, then
    carries on; it is a diagnostic switch only.
  • Discord status runs on its own thread with its own keep-alive, so it stays "Playing" through a hold.
  • The Insert menu, if open when the window loses focus, freezes with the game and comes back with it. It can't be used
    without focus anyway.

Testing

Tested: Windows 11 Pro (26300), RTX 5080, driver 621.40, a 1280x720 window, this branch built as a pack over the
shared base. Kakariko Village at night, the most recent save loaded with Skip title screen. The runs were silent
(HOS_AUDIO=0, the mixer's output dumped to a WAV) and used a throwaway profile with a copy of the save; the player's own
folder was compared with diff -rq afterwards: unchanged.

  • Option on, Alt+Tab or click to another window: held about 200 ms after losing the focus
    (pause: the game is held: its window is behind another window); back in front it went on at once
    (pause: the game goes on after 66.8 s held) at 60 fps, Link where he was. Ten holds in the first run, from 0.8 s to
    284 s.
  • Option on, minimised: held (its window is minimised); restored, it went on (after 46.2 s held).
  • Long hold, 4 min 44 s behind another window: no GPU-hang line, no not given back or held-image line, no device
    lost. Straight back to 60 fps.
  • Sound: in the WAV, every hold boundary the script found ends a frame faded to exactly 0 and starts the next from 0.
    The largest jump between neighbouring samples in the whole dump (1925 of 32767) is in normal play, not at a resume.
  • Frame generation (FSR 3.1 path, 2x): held and resumed. Afterwards frame interpolation: 582 frames shown on time, 0 late.
  • Option off: no hold and no pause: line. It runs behind another window and minimised exactly as before (numbers
    below).
  • Pause wins over Controller in background: started with both on in the options file and frame generation 2x.
    • Behind another window the game held (CPU 1.4% of one core, its GPU 0%).
    • In the menu, Controller in background read Off, locked, with its note, and refused a change.
    • With Pause turned off it could be turned on again, with its usual hint. Turning Pause back on switched it off and
      locked it again.
    • On exit settings.ini had pause_in_background=1 and controller_in_background=0.
  • Gameplay tab and Mute (99c58061c): the row sits after Game speed. Started with Pause off, Mute off and Controller
    on, then turned Pause on in the menu:
    • Mute in background went On and Controller in background Off, both locked with their notes; a change on Mute was
      refused.
    • Minimised, the game held and went on (after 10.7 s held).
    • settings.ini saved pause_in_background=1, mute_in_background=1, controller_in_background=0.
    • A first build of this rule had the Controller row's hint never end its variants, which hung the menu's prebake: a
      black window at start with Pause on. Fixed, and the test now walks that hint the way the menu does.
  • Checks: tests/test_pause_background.py (new); test_pacing_policy, screensaver_test.c (stand-ins for the new
    calls) and test_menu_ini_keys (the new key) updated. The changed-files set passes here with llvm-mingw and, for gcc,
    in WSL's Ubuntu. The Linux host files (background_pause.c, nn_vi.c, nn_audio.c, posix/display_sdl.c) compile
    with gcc against the POSIX stand-ins, with the same warnings as main.

Still to test:

  • Windows, by hand: a hold during a movie (the title screen's, or a cutscene's), expecting it to go on from the picture it stopped at, in step with its sound, with no pictures skipped to catch up line under HOS_VIDEO_LOG=1. The fix (d6a19a6eb) is covered by the game-free check only.
  • Linux X11 and Wayland, by hand: turn the option on, focus another window, minimise, come back. Expect
    pause: the game is held and goes on lines, and the game going on where it was. On Linux a minimised window is seen
    through the loss of keyboard focus only.
  • Steam Deck (Game Mode, gamescope), by hand: switch to Steam's menu or another app and back, expecting the same.
  • AMD on Windows with frame generation in borderless fullscreen and Alt+Tab (the #1482 setup), by hand: with the option
    on, Alt+Tab away and back five times. Expect the picture back each time. The presenter isn't changed, so the hold
    should only mean fewer presents while away.

Measurements

Verdict: behind another window or minimised, Pause in background cuts the game's CPU use from about 2.6 cores to about
0.02 of a core (about 99%), its own GPU use from about 36% to 0%, and the graphics card's board power by about 33 W (about
86 W down to about 53 W).

Setup: Windows 11, RTX 5080 (driver 621.40), 24 logical processors; Kakariko Village at night, standing still, 1280x720
window, cap 60, V-Sync off. Each line is one window of 20 to 253 s, sampled once a second.

  • CPU: the process's processor time over wall time.
  • "Its GPU": Windows' GPU Engine counters for the game's process.
  • Board power: nvidia-smi power.draw, the whole card. Another session's game ran beside some samples, so only those
    without it are shown.
  • Option off stands in for main: off adds one option read per frame and nothing else.
  • Single runs, not the interleaved main-against-PR runs BeanBot asked for (L7): those were not run. Foreground frame times against main were not measured; with the row off the PR adds one option read a frame.
  • The numbers are from 783b77401. 9fe89dd39 and 99c58061c change only the menu rows, the Controller and Mute rules, and its both-on run held
    the same way (CPU 1.4% of one core, its GPU 0%, board power 51.7 W).
Before: main @ 3ab4db6e9 (measured as this PR with the row off) After: this PR @ 783b77401, row on
Behind another window: CPU 268.9% of one core 3.0%; 1.9% over a 4-minute hold
Behind another window: its GPU 37.2% 0.0%
Behind another window: board power 87.6 W 53.3 W; 54.1 W over 4 minutes
Minimised: CPU 250.3% of one core 1.9% (frame generation 2x: 3.4%)
Minimised: its GPU 35.6% 0.0%
Minimised: board power 84.3 W 52.9 W (frame generation 2x run)
In front, playing (for reference) 252% of one core, its GPU 37.8%, 84.5 W same

CPU package power wasn't measured. There is no meter on this PC, but the process's CPU time falls about 99%.

Risks

  • Off by default: nothing changes for a player who doesn't turn it on. Turning it off, or a revert, brings back the
    old behaviour.
  • With it on, a game behind another window stops. Streaming or recording the game while another window has the
    focus needs it off. While it is on, Controller in background is unavailable and Mute in background is forced on, as
    asked.
  • The window's state is read about once a frame while the option is on (GetForegroundWindow, as Mute in background
    and the input already do).
  • Linux has no minimised query: a minimised window holds through its loss of focus, which X11 and Wayland both send.
  • The log: after a hold, hid: the game read no controller for N s reports the hold's length. It is a log line only.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). The checks that read the changed files
    pass. These fail on main too, on this PC: test_crash_record, test_screensaver, test_bug_report,
    test_xinput_thread, test_parity_gates, test_oot_menu_mouse, test_gpu_choice, test_upscale_label,
    test_menu_mouse_scroll, test_prompt_auto_face (no g++ here, or broken on main).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Windows was built and run; the Linux files
    compile with gcc against the POSIX stand-ins.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary A player asked for an option that stops the whole game, not just its sound, while it is in the background, to save power. Until now only **Mute in background** existed: behind another window or minimised, the game kept running at full speed, on this PC about 2.7 CPU cores and 37% of an RTX 5080. This adds **Pause in background** on the Gameplay tab, right after Game speed, **off by default** (`pause_in_background` in `longshot_options.ini`). With it on, while another window has the focus or the game's window is minimised, the game stops: no game logic, no frames rendered or presented, no sound. The CPU and GPU go nearly idle. When the window comes back to the front, the game goes on where it was, with no catch-up and no burst of sound. **Pause in background takes over two other rows.** Turning it on turns **Mute in background on** and **Controller in background off** (a stopped game can't be played from behind another window). While Pause is on, both rows stay that way and are locked, including in a hand-edited options file. The menu says so on all three: - Pause in background's hint: "Mute in background is on and Controller in background is off while this is on." - Mute in background: "On while Pause in background (Gameplay tab) is on." - Controller in background: "Off while Pause in background (Gameplay tab) is on..." - The renderer also tells the host Mute is on while Pause is on, so the moment before a hold is silent too. How it works, for review (read `host/background_pause.c` first): - **The rows:** `gpu/vk/menu/gameplay.cpp` (Pause in background, with an `on_change` that turns Mute in background on and Controller in background off), `gpu/vk/menu/volume.cpp` (Mute in background) and `gpu/vk/menu/controller.cpp` (Controller in background). The latter two get `locked` and `sync` while Pause is on, and hints whose variants end so the menu can size the help. - **Where the game holds:** `hos_vi_native_acquire` (`host/nn_vi.c`). This is the first host code of every game frame, on the main thread, outside the game's locks, with its virtual core already given up; it is where the console blocks for a free window texture. The thread waits on an event that the window's focus changes set (`host/display.c` `WM_ACTIVATEAPP` / `WM_SETFOCUS` / `WM_SIZE`, `host/posix/display_sdl.c` SDL focus events), with a 250 ms timeout. It never spins. The workers, the renderer, its presenter and frame generation's display thread get no new frame and idle. - **Presentation is untouched.** The presenter and the swapchain are not changed at all, to stay clear of the Alt+Tab held-image area of #1482 and #2083. The last frame simply stays on screen. - **A movie** (`host/nn_video.c`): its clock is the wall's less the time held (`movie_now`, `hos_background_held_ns`), so after a hold it goes on from the picture it stopped at, as its sound does, with nothing skipped. - **Sound** (`host/nn_audio.c` `renderer_main`): the mixer fades its last frame out to exactly 0, then mixes nothing and stops signalling the game's sound thread. On resume the voices go on from the sample they stopped at, faded in. - **Resume:** the frame after a hold starts as after a load. The real-time step already drops a frame over 0.25 s, and pacing restarts from now, so nothing fast-forwards. The renderer leaves the frame that spans the hold out of its frame times and the performance summary (`HOS_OPT_BACKGROUND_PAUSED` through the existing `option_set`, `gpu/vk/vk_fps.cpp` `fps_hold_gap`). Without this, a 5-minute pause would be sent as a 5-minute hitch. - **Which windows count as the game's:** the same rule as Mute in background. An overlay (Steam's, Discord's, a toast) counts as the game's while the game was the last normal window in front. A hold starts only after 200 ms out of front, because Windows' foreground is briefly nobody's during a switch. - **When it never holds:** at start-up before the window has been in front once (the launcher keeps the window hidden until the first frame), and in runs with no window to come back to: `HOS_HEADLESS`, `HOS_WINDOW_NOACTIVATE` (test runs opened behind) and `HOS_INPUT_PLAY`. - **Hang watches:** the GPU hang watch counts only work sent and not finished, so a hold is not a hang to it (checked with a 4-minute hold). The opt-in `RX_VK_HANG_DUMP` watchdog writes one stack dump after 20 s without a present, then carries on; it is a diagnostic switch only. - **Discord status** runs on its own thread with its own keep-alive, so it stays "Playing" through a hold. - **The Insert menu**, if open when the window loses focus, freezes with the game and comes back with it. It can't be used without focus anyway. ## Testing **Tested:** Windows 11 Pro (26300), RTX 5080, driver 621.40, a 1280x720 window, this branch built as a pack over the shared base. Kakariko Village at night, the most recent save loaded with Skip title screen. The runs were silent (`HOS_AUDIO=0`, the mixer's output dumped to a WAV) and used a throwaway profile with a copy of the save; the player's own folder was compared with `diff -rq` afterwards: unchanged. - **Option on, Alt+Tab or click to another window:** held about 200 ms after losing the focus (`pause: the game is held: its window is behind another window`); back in front it went on at once (`pause: the game goes on after 66.8 s held`) at 60 fps, Link where he was. Ten holds in the first run, from 0.8 s to 284 s. - **Option on, minimised:** held (`its window is minimised`); restored, it went on (`after 46.2 s held`). - **Long hold, 4 min 44 s behind another window:** no GPU-hang line, no `not given back` or held-image line, no device lost. Straight back to 60 fps. - **Sound:** in the WAV, every hold boundary the script found ends a frame faded to exactly 0 and starts the next from 0. The largest jump between neighbouring samples in the whole dump (1925 of 32767) is in normal play, not at a resume. - **Frame generation (FSR 3.1 path, 2x):** held and resumed. Afterwards `frame interpolation: 582 frames shown on time, 0 late`. - **Option off:** no hold and no `pause:` line. It runs behind another window and minimised exactly as before (numbers below). - **Pause wins over Controller in background:** started with both on in the options file and frame generation 2x. - Behind another window the game held (CPU 1.4% of one core, its GPU 0%). - In the menu, Controller in background read Off, locked, with its note, and refused a change. - With Pause turned off it could be turned on again, with its usual hint. Turning Pause back on switched it off and locked it again. - On exit `settings.ini` had `pause_in_background=1` and `controller_in_background=0`. - **Gameplay tab and Mute (99c58061c):** the row sits after Game speed. Started with Pause off, Mute off and Controller on, then turned Pause on in the menu: - Mute in background went On and Controller in background Off, both locked with their notes; a change on Mute was refused. - Minimised, the game held and went on (`after 10.7 s held`). - `settings.ini` saved `pause_in_background=1`, `mute_in_background=1`, `controller_in_background=0`. - A first build of this rule had the Controller row's hint never end its variants, which hung the menu's prebake: a black window at start with Pause on. Fixed, and the test now walks that hint the way the menu does. - Checks: `tests/test_pause_background.py` (new); `test_pacing_policy`, `screensaver_test.c` (stand-ins for the new calls) and `test_menu_ini_keys` (the new key) updated. The changed-files set passes here with llvm-mingw and, for gcc, in WSL's Ubuntu. The Linux host files (`background_pause.c`, `nn_vi.c`, `nn_audio.c`, `posix/display_sdl.c`) compile with gcc against the POSIX stand-ins, with the same warnings as main. **Still to test:** - Windows, by hand: a hold during a movie (the title screen's, or a cutscene's), expecting it to go on from the picture it stopped at, in step with its sound, with no `pictures skipped to catch up` line under `HOS_VIDEO_LOG=1`. The fix (d6a19a6eb) is covered by the game-free check only. - Linux X11 and Wayland, by hand: turn the option on, focus another window, minimise, come back. Expect `pause: the game is held` and `goes on` lines, and the game going on where it was. On Linux a minimised window is seen through the loss of keyboard focus only. - Steam Deck (Game Mode, gamescope), by hand: switch to Steam's menu or another app and back, expecting the same. - AMD on Windows with frame generation in borderless fullscreen and Alt+Tab (the #1482 setup), by hand: with the option on, Alt+Tab away and back five times. Expect the picture back each time. The presenter isn't changed, so the hold should only mean fewer presents while away. ## Measurements **Verdict:** behind another window or minimised, Pause in background cuts the game's CPU use from about 2.6 cores to about 0.02 of a core (about 99%), its own GPU use from about 36% to 0%, and the graphics card's board power by about 33 W (about 86 W down to about 53 W). Setup: Windows 11, RTX 5080 (driver 621.40), 24 logical processors; Kakariko Village at night, standing still, 1280x720 window, cap 60, V-Sync off. Each line is one window of 20 to 253 s, sampled once a second. - CPU: the process's processor time over wall time. - "Its GPU": Windows' GPU Engine counters for the game's process. - Board power: `nvidia-smi` `power.draw`, the whole card. Another session's game ran beside some samples, so only those without it are shown. - Option off stands in for main: off adds one option read per frame and nothing else. - Single runs, not the interleaved main-against-PR runs BeanBot asked for (L7): those were not run. Foreground frame times against main were not measured; with the row off the PR adds one option read a frame. - The numbers are from 783b77401. 9fe89dd39 and 99c58061c change only the menu rows, the Controller and Mute rules, and its both-on run held the same way (CPU 1.4% of one core, its GPU 0%, board power 51.7 W). | | Before: main @ 3ab4db6e9 (measured as this PR with the row off) | After: this PR @ 783b77401, row on | |---|---|---| | Behind another window: CPU | 268.9% of one core | 3.0%; 1.9% over a 4-minute hold | | Behind another window: its GPU | 37.2% | 0.0% | | Behind another window: board power | 87.6 W | 53.3 W; 54.1 W over 4 minutes | | Minimised: CPU | 250.3% of one core | 1.9% (frame generation 2x: 3.4%) | | Minimised: its GPU | 35.6% | 0.0% | | Minimised: board power | 84.3 W | 52.9 W (frame generation 2x run) | | In front, playing (for reference) | 252% of one core, its GPU 37.8%, 84.5 W | same | CPU package power wasn't measured. There is no meter on this PC, but the process's CPU time falls about 99%. ## Risks - **Off by default:** nothing changes for a player who doesn't turn it on. Turning it off, or a revert, brings back the old behaviour. - **With it on, a game behind another window stops.** Streaming or recording the game while another window has the focus needs it off. While it is on, Controller in background is unavailable and Mute in background is forced on, as asked. - **The window's state is read about once a frame** while the option is on (`GetForegroundWindow`, as Mute in background and the input already do). - **Linux** has no minimised query: a minimised window holds through its loss of focus, which X11 and Wayland both send. - **The log:** after a hold, `hid: the game read no controller for N s` reports the hold's length. It is a log line only. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). The checks that read the changed files pass. These fail on `main` too, on this PC: `test_crash_record`, `test_screensaver`, `test_bug_report`, `test_xinput_thread`, `test_parity_gates`, `test_oot_menu_mouse`, `test_gpu_choice`, `test_upscale_label`, `test_menu_mouse_scroll`, `test_prompt_auto_face` (no g++ here, or broken on main). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Windows was built and run; the Linux files compile with gcc against the POSIX stand-ins. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A new row on the Audio tab, beside Mute in background, off by default (pause_in_background in
longshot_options.ini; a player's request, for power saving). With it on, the game holds at the
start of its next frame (host/nn_vi.c hos_vi_native_acquire, on the main thread, outside the
game's locks with its virtual core given up) while another window has the focus or its window is
minimised: no game logic, no frames rendered or presented, no sound. The thread waits on an event
the window's focus changes set (host/display.c, host/posix/display_sdl.c), so nothing spins; the
renderer, the presenter and frame generation get no new frame and idle with the GPU.

- The audio mixer fades its last frame out, then mixes and signals nothing until the game goes on;
  the voices resume from where they stopped, faded in, with no burst.
- On resume the frame starts as after a load: the real-time step drops a frame over 0.25 s and the
  pacing paces from now, so nothing catches up; the renderer leaves the frame across the hold out
  of its frame times and the performance summary (HOS_OPT_BACKGROUND_PAUSED, vk_fps.cpp).
- Never before the window was in front once, nor in a run without a window to come back to
  (HOS_HEADLESS, HOS_WINDOW_NOACTIVATE, HOS_INPUT_PLAY). With Controller in background on, only a
  minimised window holds the game. Overlays over the game (a toast, Steam's) count as the game's,
  as for Mute in background; a hold starts after 200 ms out of front.
- The presenter and the swapchain are not touched (#1482, #2083).

tests/test_pause_background.py: the decisions compiled and run, and the wiring read from the
sources. test_pacing_policy and screensaver_test.c get stand-ins for the new calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat(menu): Pause in background wins over Controller in background
Some checks failed
PR description / Title and description (pull_request_target) Successful in 9s
CI / What the change needs (pull_request) Successful in 11s
CI / Third-party parts and guide screenshots (pull_request) Failing after 15s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 15s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
9fe89dd399
A held game can't be played from behind another window, so Pause in background now has
priority:

- The row moves from game/menu/ to gpu/vk/menu/volume.cpp (it needs a hook now), same key, same
  place after Mute in background. Turning it on turns Controller in background off.
- Controller in background is locked off while Pause in background is on, a hand-edited
  options file with both on included (sync), and its hint says why; Pause in background's hint
  says it turns it off. Controller in background's help text is unchanged (its translations).
- The host's decision no longer asks for the controllers (nor HOS_INPUT_BACKGROUND): behind
  another window or minimised, the game holds.
- The hint ends its variants (1, then none): the menu sizes a help by asking variant 1, 2, ...
  until nullptr, and a hint that never ended hung the menu's prebake, and every present, at the
  start of a game with Pause in background on (a black window, found in the game here).

tests/test_pause_background.py compiles Controller in background's hint and walks its variants
as the menu does, with Pause on and off; it fails on the hint that hung.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11 Pro (26300), RTX 5080, driver 621.40, 1280x720 window, Kakariko Village at night from a save. Option on: behind another window and minimised the game held (CPU 2.6 cores to 0.02, its GPU 37% to 0%, board power 86 W to 53 W) and went on where it was at 60 fps, ten holds from 0.8 s to 284 s, no hang-watch or held-image lines; the sound dump fades to 0 at each hold and back from 0. Frame generation 2x held and resumed with every made frame on time. With both Pause and Controller in background on in the file, Pause wins: held behind a window, the Controller row Off and locked with its note, and turning Pause on switches it off. Option off: no hold, as before.

Tested in game: Windows 11 Pro (26300), RTX 5080, driver 621.40, 1280x720 window, Kakariko Village at night from a save. Option on: behind another window and minimised the game held (CPU 2.6 cores to 0.02, its GPU 37% to 0%, board power 86 W to 53 W) and went on where it was at 60 fps, ten holds from 0.8 s to 284 s, no hang-watch or held-image lines; the sound dump fades to 0 at each hold and back from 0. Frame generation 2x held and resumed with every made frame on time. With both Pause and Controller in background on in the file, Pause wins: held behind a window, the Controller row Off and locked with its note, and turning Pause on switches it off. Option off: no hold, as before.
Member

Possibly related, for context:

  • PR #1169 WIP: fix(input): the controller in the background stays out of the game while the Insert menu is open — Controller-background behavior; this PR locks that setting.
  • PR #1458 fix(vk): the swapchain's image is waited for on the CPU, so a window behind another one no longer stops the GPU's work — Merged Alt+Tab swapchain handling referenced by this PR.
  • PR #2214 fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab — Prior Alt+Tab held-image recovery attempt, closed without a working fix.
Possibly related, for context: - PR #1169 WIP: fix(input): the controller in the background stays out of the game while the Insert menu is open — Controller-background behavior; this PR locks that setting. - PR #1458 fix(vk): the swapchain's image is waited for on the CPU, so a window behind another one no longer stops the GPU's work — Merged Alt+Tab swapchain handling referenced by this PR. - PR #2214 fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab — Prior Alt+Tab held-image recovery attempt, closed without a working fix.
feat(menu): Pause in background on the Gameplay tab, and it turns Mute in background on
Some checks failed
CI / What the change needs (pull_request) Successful in 10s
CI / Third-party parts and guide screenshots (pull_request) Failing after 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 12s
PR description / Title and description (pull_request_target) Successful in 6s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
99c58061c8
- The row moves from the Audio tab to the Gameplay tab, right after Game speed
  (gpu/vk/menu/gameplay.cpp): it is about the game running, not its sound. Same key.
- Turning it on turns Mute in background on, as well as Controller in background off. Mute in
  background is locked on while Pause in background is on (a hand-edited options file
  included), and its hint says why; the renderer answers the host's HOS_OPT_MUTE_BACKGROUND on
  meanwhile, so the moment before a hold is silent too.
- The notes on Controller in background now name the Gameplay tab.

tests/test_pause_background.py checks the new place and the Mute rule, and walks Mute in
background's hint as the menu does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

99c58061c: Pause in background moves to the Gameplay tab (after Game speed), and turning it on now also turns Mute in background on, locked on while Pause is on, with a note on the row; the renderer tells the host Mute is on meanwhile. Tested in game on Windows 11 / RTX 5080: turning Pause on in the menu set Mute On and Controller in background Off, both locked with their notes; minimised, the game held and went on; settings.ini saved pause_in_background=1, mute_in_background=1, controller_in_background=0.

99c58061c: Pause in background moves to the Gameplay tab (after Game speed), and turning it on now also turns Mute in background on, locked on while Pause is on, with a note on the row; the renderer tells the host Mute is on meanwhile. Tested in game on Windows 11 / RTX 5080: turning Pause on in the menu set Mute On and Controller in background Off, both locked with their notes; minimised, the game held and went on; settings.ini saved pause_in_background=1, mute_in_background=1, controller_in_background=0.
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The hold saves substantial CPU and GPU work in the reported Windows run, but it leaves the movie clock running and introduces unsynchronized cross-thread reads. Linux and the remaining Tier 1 configurations also need in-game coverage.

Adds an off-by-default gameplay option that holds the game and fades audio when its window is backgrounded. It saves power while held, at the cost of stopping background play and adding synchronization and timing paths that need correction.

Blocking (2): must change before merging.

  1. L1 host/background_pause.c:140: Resuming does not advance the movie decoder's clock past the hold. (more on the line) Do: Exclude the hold duration from active movie clocks on resume, with a test covering a hold during movie playback.
  2. L8: The check CI / Third-party parts and guide screenshots (pull_request) fails on this head and passes on the base branch: Failing after 13s.

Should fix (3): not blocking, but worth doing before merging.

  • L2 gpu/vk/vk_replay.cpp:8780: The new option is read on the game and audio threads while the menu writes the same plain integer on the presentation thread. (more on the line) Do: Publish the option through an atomic snapshot or protect both reads and writes with the same lock; include the new mute override in that synchronization.
  • L3 host/posix/display_sdl.c:477: The focus state used by the new hold loop is shared across threads using volatile rather than synchronization. (more on the line) Do: Publish and read the focus state atomically, including the existing GetForegroundWindow stand-in.
  • L4 host/background_pause.c:119: A partial event allocation failure leaks the event that was created and permanently disables the option. (more on the line) Do: Close any successfully created event on partial failure and report the allocation failure accurately; allow a safe retry if appropriate.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 host/posix/display_sdl.c:477: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. (more on the line) Do: Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.
  • L6 host/nn_vi.c:258: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. (more on the line) Do: Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.
  • L7 host/nn_vi.c:258: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. (more on the line) Do: Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.

@fix can do L1, L2, L3, L4 and L8.

Checks: Still running: 7 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for the tested Windows setup: the reported background run fell from 268.9% to 1.9–3.0% of one CPU core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53–54 W. The baseline was this branch with the option off, rather than the base commit, and the report does not give interleaved repeated base/head runs or foreground frame-time results.

Other systems: The hold reaches the game thread, mixer, movie decoder and presentation timing on both Windows and Linux. Windows NVIDIA and FSR 3.1 frame generation were exercised; Linux X11, Wayland, Steam Deck and Windows AMD frame generation remain untested in game. Controller speaker and movie playback are also affected by the audio and timing changes.

Switches: No environment switch added, changed or removed. The player-facing Pause in background option defaults off; enabling it forces Mute in background on and Controller in background off.

Reviewed: 99c58061c8 against 3ab4db6e91: Read the repository rules, PR template, standards, commit messages and diff; read the new pause implementation and test and traced the changed menu, audio, window, pacing, movie and FPS paths. Large existing changed files were read around the changes and relevant callers, not in full. Tooling's adjacent AGENTS.md and docs/review-checklist.md were absent. No generated files or recorded runs were changed.; nothing run (a code review).

Checked and fine:

  • All three commits record AI assistance.
  • The new saved menu key is added to the frozen key list, and the player settings table documents the option and its interactions.
  • The renderer interface structs are unchanged, so the added option IDs do not require an interface version bump.
  • The supplied Windows test covers focus loss, minimize, resume, audio fade and FSR 3.1 frame generation.

Testing: Read-only review; no build, scripts or tests were run. The supplied CI results include one head-only failure and several checks still running; the head-only failure is left to the bot as instructed.

Overlaps and merge order: Not checked; network closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The hold saves substantial CPU and GPU work in the reported Windows run, but it leaves the movie clock running and introduces unsynchronized cross-thread reads. Linux and the remaining Tier 1 configurations also need in-game coverage. Adds an off-by-default gameplay option that holds the game and fades audio when its window is backgrounded. It saves power while held, at the cost of stopping background play and adding synchronization and timing paths that need correction. **Blocking (2)**: must change before merging. 1. **L1** `host/background_pause.c:140`: Resuming does not advance the movie decoder's clock past the hold. (more on the line) **Do:** Exclude the hold duration from active movie clocks on resume, with a test covering a hold during movie playback. 2. **L8**: The check `CI / Third-party parts and guide screenshots (pull_request)` fails on this head and passes on the base branch: Failing after 13s. **Should fix (3)**: not blocking, but worth doing before merging. - **L2** `gpu/vk/vk_replay.cpp:8780`: The new option is read on the game and audio threads while the menu writes the same plain integer on the presentation thread. (more on the line) **Do:** Publish the option through an atomic snapshot or protect both reads and writes with the same lock; include the new mute override in that synchronization. - **L3** `host/posix/display_sdl.c:477`: The focus state used by the new hold loop is shared across threads using volatile rather than synchronization. (more on the line) **Do:** Publish and read the focus state atomically, including the existing GetForegroundWindow stand-in. - **L4** `host/background_pause.c:119`: A partial event allocation failure leaks the event that was created and permanently disables the option. (more on the line) **Do:** Close any successfully created event on partial failure and report the allocation failure accurately; allow a safe retry if appropriate. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `host/posix/display_sdl.c:477`: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. (more on the line) **Do:** Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode. - **L6** `host/nn_vi.c:258`: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. (more on the line) **Do:** Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns. - **L7** `host/nn_vi.c:258`: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. (more on the line) **Do:** Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use. `@fix` can do L1, L2, L3, L4 and L8. **Checks:** Still running: 7 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the tested Windows setup: the reported background run fell from 268.9% to 1.9–3.0% of one CPU core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53–54 W. The baseline was this branch with the option off, rather than the base commit, and the report does not give interleaved repeated base/head runs or foreground frame-time results. **Other systems:** The hold reaches the game thread, mixer, movie decoder and presentation timing on both Windows and Linux. Windows NVIDIA and FSR 3.1 frame generation were exercised; Linux X11, Wayland, Steam Deck and Windows AMD frame generation remain untested in game. Controller speaker and movie playback are also affected by the audio and timing changes. **Switches:** No environment switch added, changed or removed. The player-facing Pause in background option defaults off; enabling it forces Mute in background on and Controller in background off. **Reviewed:** 99c58061c82a against 3ab4db6e9154: Read the repository rules, PR template, standards, commit messages and diff; read the new pause implementation and test and traced the changed menu, audio, window, pacing, movie and FPS paths. Large existing changed files were read around the changes and relevant callers, not in full. Tooling's adjacent AGENTS.md and docs/review-checklist.md were absent. No generated files or recorded runs were changed.; nothing run (a code review). **Checked and fine:** - All three commits record AI assistance. - The new saved menu key is added to the frozen key list, and the player settings table documents the option and its interactions. - The renderer interface structs are unchanged, so the added option IDs do not require an interface version bump. - The supplied Windows test covers focus loss, minimize, resume, audio fade and FSR 3.1 frame generation. **Testing:** Read-only review; no build, scripts or tests were run. The supplied CI results include one head-only failure and several checks still running; the head-only failure is left to the bot as instructed. **Overlaps and merge order:** Not checked; network closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -8778,2 +8778,3 @@
if (id == HOS_OPT_AUDIO_OUTPUT) return opts.audio_output;
if (id == HOS_OPT_MUTE_BACKGROUND) return opts.mute_background;
if (id == HOS_OPT_MUTE_BACKGROUND) return opts.mute_background || opts.pause_background; // (Pause in background turns it on)
if (id == HOS_OPT_PAUSE_BACKGROUND) return opts.pause_background;
Member

L2 (should fix): The new option is read on the game and audio threads while the menu writes the same plain integer on the presentation thread.

When: Changing Pause in background in the menu can overlap hos_background_pause_point's rx_option call or the mixer's Mute in background read. The callback takes no menu lock, so these accesses race and have undefined behavior.

Do: Publish the option through an atomic snapshot or protect both reads and writes with the same lock; include the new mute override in that synchronization.

**L2** (should fix): The new option is read on the game and audio threads while the menu writes the same plain integer on the presentation thread. *When:* Changing Pause in background in the menu can overlap hos_background_pause_point's rx_option call or the mixer's Mute in background read. The callback takes no menu lock, so these accesses race and have undefined behavior. **Do:** Publish the option through an atomic snapshot or protect both reads and writes with the same lock; include the new mute override in that synchronization.
@ -0,0 +116,4 @@
never = env_on("HOS_HEADLESS") || env_on("HOS_WINDOW_NOACTIVATE") || (play && *play);
if (!never) {
HANDLE resumed = CreateEventA(NULL, TRUE, TRUE, NULL), wake = CreateEventA(NULL, FALSE, FALSE, NULL);
if (!resumed || !wake) never = 1;
Member

L4 (should fix): A partial event allocation failure leaks the event that was created and permanently disables the option.

When: If either CreateEventA call fails after the other succeeds, never becomes true, but the successful handle is retained without being closed and the player cannot use Pause for the rest of the run.

Do: Close any successfully created event on partial failure and report the allocation failure accurately; allow a safe retry if appropriate.

**L4** (should fix): A partial event allocation failure leaks the event that was created and permanently disables the option. *When:* If either CreateEventA call fails after the other succeeds, never becomes true, but the successful handle is retained without being closed and the player cannot use Pause for the rest of the run. **Do:** Close any successfully created event on partial failure and report the allocation failure accurately; allow a safe retry if appropriate.
@ -0,0 +137,4 @@
hos_log_flush();
ResetEvent(pause_resumed);
__atomic_store_n(&pause_held, 1, __ATOMIC_RELEASE);
while (pause_now_wanted(&minimized)) WaitForSingleObject(pause_wake, PAUSE_LOOK_MS);
Member

L1 (blocking): Resuming does not advance the movie decoder's clock past the hold.

When: If focus is lost during a movie, nn_video.c keeps clock_ns at its pre-hold value. On the next decoder acquire, its catch-up loop treats the held time as playback time and skips pictures, while the paused audio resumes at its old sample.

Do: Exclude the hold duration from active movie clocks on resume, with a test covering a hold during movie playback.

**L1** (blocking): Resuming does not advance the movie decoder's clock past the hold. *When:* If focus is lost during a movie, nn_video.c keeps clock_ns at its pre-hold value. On the next decoder acquire, its catch-up loop treats the held time as playback time and skips pictures, while the paused audio resumes at its old sample. **Do:** Exclude the hold duration from active movie clocks on resume, with a test covering a hold during movie playback.
host/nn_vi.c Outdated
@ -254,1 +255,4 @@
(longshot) Pause in background holds the game here first, for the same reasons, before the frame's phase and its
pacing (host/background_pause.c): the frame after a hold is paced from its end. */
void hos_vi_native_acquire(int active) {
hos_background_pause_point();
Member

L6 (should fix): The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup.

When: The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged.

Do: Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.

**L6** (should fix): The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. *When:* The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. **Do:** Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.
Member

L7 (should fix): Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head.

When: The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base.

Do: Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.

**L7** (should fix): Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. *When:* The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. **Do:** Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.
@ -471,10 +475,12 @@ void hos_display_loop(void) {
break;
case HOS_SDL_EV_FOCUS_GAINED:
hos_posix_window[0] = 1;
Member

L3 (should fix): The focus state used by the new hold loop is shared across threads using volatile rather than synchronization.

When: On Linux, the SDL thread writes hos_posix_window[0] on focus changes while the game thread reads it through GetForegroundWindow in pause_now_wanted. These concurrent accesses race, so a hold or resume is not reliably synchronized.

Do: Publish and read the focus state atomically, including the existing GetForegroundWindow stand-in.

**L3** (should fix): The focus state used by the new hold loop is shared across threads using volatile rather than synchronization. *When:* On Linux, the SDL thread writes hos_posix_window[0] on focus changes while the game thread reads it through GetForegroundWindow in pause_now_wanted. These concurrent accesses race, so a hold or resume is not reliably synchronized. **Do:** Publish and read the focus state atomically, including the existing GetForegroundWindow stand-in.
Member

L5 (should fix): The new focus-driven hold has not been exercised in game on Linux or Steam Deck.

When: X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there.

Do: Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.

**L5** (should fix): The new focus-driven hold has not been exercised in game on Linux or Steam Deck. *When:* X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. **Do:** Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.
From BeanBot's review of #2786:

- L1: a movie's clock (host/nn_video.c dec_acquire: clock_ns, out_ns) was the wall's, so after
  a hold the catch-up skipped the hold's worth of pictures while the sound went on from where it
  stopped. It is now movie_now(), the wall's less the time held (hos_background_held_ns,
  host/background_pause.c, kept under a lock from a hold's start to its end).
- L2: the renderer answers Pause in background and Mute in background to the host with atomic
  loads, and Pause in background's on_change sets the other two rows with atomic stores.
- L3: Linux's focus flag (hos_posix_window[0]) is stored and loaded atomically
  (host/posix/display_sdl.c, win32_posix.c GetForegroundWindow).
- L4: if only one of the hold's two events can be made, it is closed, the log says so, and the
  option does nothing in that run.

tests/test_pause_background.py: a movie's clock across two holds (compiled), dec_acquire reading
no wall clock for the movie, a hold's time counted from its start to its end, and the atomic reads;
test_audio_volume takes the atomic read of Mute in background.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(guide): the Graphics screenshot's source review recorded at 7963e7db (Pause in background)
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Successful in 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 14s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
f008a02e3c
The guide check's review hashes followed the menu sources this PR changes. Rendered Graphics, Audio
and Controls with the UI-only helper from main 3ab4db6e and from 7963e7db: they differ only in the
version text's box, and the published Graphics image matches 7963e7db's render but for that box.
The PNG is kept; the reviewed revision and hashes are updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Thanks, BeanBot. Answers by item; the fixes are in 7963e7dbf and f008a02e3.

L1 (movie clock). Fixed in 7963e7dbf. A movie's clock in dec_acquire (clock_ns, out_ns and the catch-up, hold and log reads) is
now movie_now(): the wall clock less the time the game has been held (hos_background_held_ns, kept under a lock in
host/background_pause.c from a hold's start to its end). After a hold the movie goes on from the picture it stopped
at, as its sound does, with nothing skipped.

tests/test_pause_background.py covers it:

  • It compiles movie_now and the held-time clock and runs a movie across two holds (10 s and 4 s). The movie's clock
    stands during each hold, then runs with the wall again.
  • dec_acquire must read no wall clock for the movie; only its 100 ms output wait is left on hos_now_ns().

With the old wall clock the compiled check fails (movie_now() - clock_ns == 2 * s), and with any one read left on the
wall clock the source check fails.

L2 (option reads). Done in 7963e7dbf, as far as this PR's own reads and writes go:

  • The option callback answers HOS_OPT_PAUSE_BACKGROUND and HOS_OPT_MUTE_BACKGROUND, including the new override, with
    __atomic_load_n (relaxed).
  • Pause in background's on_change sets Mute in background and Controller in background with __atomic_store_n.

The menu model's own store of a row's value (menu_model.cpp change: *s.value = next) is still a plain aligned
int store. That is the same for every one of the menu's options that the host reads through this callback, Mute in
background on main included. Making the model's stores atomic is a change to every row, so it's left out of this PR.
tests/test_pause_background.py checks the atomic reads, and test_audio_volume.py accepts the atomic form for Mute in
background.

L3 (Linux focus flag). Done in 7963e7dbf. hos_posix_window[0] (the focus) is now:

  • stored with __atomic_store_n (release) at the window's start and on SDL's focus gained and lost
    (host/posix/display_sdl.c);
  • read with __atomic_load_n (acquire) by the GetForegroundWindow stand-in (host/posix/win32_posix.c), which is
    what the hold loop reads.

The other reads of the flag on the window's own thread (the cursor and pointer code) are that thread's own and are
unchanged. Both files compile with gcc against the POSIX stand-ins.

L4 (events). Done in 7963e7dbf. If either CreateEventA fails:

  • the one that was made is closed, and neither is kept;
  • the log says pause: its events could not be made (error N): Pause in background does nothing in this run;
  • the option stays off for that run.

I left out a retry: a manual-reset and an auto-reset event failing to be made means the process is out of handles or
memory, and retrying every frame would only repeat the failure and the log line.

L5 (Linux, Steam Deck). Agreed; I have no Linux PC or Steam Deck here. It stays under Still to test: Linux X11 and Wayland (focus away,
minimise, restore) and Steam Deck Game Mode (switch away and back), by hand. The Test Farm can't drive focus changes.
On Linux a minimised window holds through its loss of keyboard focus, which X11 and Wayland both send; there is no
separate minimised query there.

L6 (AMD, frame generation, Alt+Tab). Agreed; this PC is NVIDIA (RTX 5080), so the #1482 setup can't be reproduced here. It stays under Still to test:
Windows AMD, frame generation, borderless fullscreen, repeated Alt+Tab away and back with Pause in background on,
checking the picture returns each time, by hand.

The presenter and swapchain code are untouched. A hold only means no new frames are handed over while the window is
away, and frame generation 2x (FSR 3.1 path) held and resumed cleanly on NVIDIA here.

L7 (interleaved base vs head). Running now on this PC:

  • dev.py ab --scene kakariko: main against this PR, game in front, uncapped, A/B/A/B/A/B, for frame times.
  • Then two interleaved background runs each of main and this PR with the row on, for CPU, GPU and board power.

The numbers will go into Measurements and a comment here.

L8 (guide screenshots). The check's review hashes followed the menu sources this PR changes. I rendered Graphics,
Audio and Controls with scripts/screenshots/capture_menu.py from main 3ab4db6e and from 7963e7db (WSL Ubuntu,
clang++). The three differ only in the version text's box (x 1087–1261, y 20–31), and the published Graphics image
matches 7963e7db's render but for that box. f008a02e3 records that review (revision and hashes) in
docs/user/images/guide/manifest.json and keeps the PNG; check_guide_screenshots.py --review-sources passes.

Thanks, BeanBot. Answers by item; the fixes are in 7963e7dbf and f008a02e3. **L1 (movie clock).** Fixed in 7963e7dbf. A movie's clock in `dec_acquire` (`clock_ns`, `out_ns` and the catch-up, hold and log reads) is now `movie_now()`: the wall clock less the time the game has been held (`hos_background_held_ns`, kept under a lock in `host/background_pause.c` from a hold's start to its end). After a hold the movie goes on from the picture it stopped at, as its sound does, with nothing skipped. `tests/test_pause_background.py` covers it: - It compiles `movie_now` and the held-time clock and runs a movie across two holds (10 s and 4 s). The movie's clock stands during each hold, then runs with the wall again. - `dec_acquire` must read no wall clock for the movie; only its 100 ms output wait is left on `hos_now_ns()`. With the old wall clock the compiled check fails (`movie_now() - clock_ns == 2 * s`), and with any one read left on the wall clock the source check fails. **L2 (option reads).** Done in 7963e7dbf, as far as this PR's own reads and writes go: - The option callback answers `HOS_OPT_PAUSE_BACKGROUND` and `HOS_OPT_MUTE_BACKGROUND`, including the new override, with `__atomic_load_n` (relaxed). - Pause in background's `on_change` sets Mute in background and Controller in background with `__atomic_store_n`. The menu model's own store of a row's value (`menu_model.cpp` `change`: `*s.value = next`) is still a plain aligned `int` store. That is the same for every one of the menu's options that the host reads through this callback, Mute in background on `main` included. Making the model's stores atomic is a change to every row, so it's left out of this PR. `tests/test_pause_background.py` checks the atomic reads, and `test_audio_volume.py` accepts the atomic form for Mute in background. **L3 (Linux focus flag).** Done in 7963e7dbf. `hos_posix_window[0]` (the focus) is now: - stored with `__atomic_store_n` (release) at the window's start and on SDL's focus gained and lost (`host/posix/display_sdl.c`); - read with `__atomic_load_n` (acquire) by the `GetForegroundWindow` stand-in (`host/posix/win32_posix.c`), which is what the hold loop reads. The other reads of the flag on the window's own thread (the cursor and pointer code) are that thread's own and are unchanged. Both files compile with gcc against the POSIX stand-ins. **L4 (events).** Done in 7963e7dbf. If either `CreateEventA` fails: - the one that was made is closed, and neither is kept; - the log says `pause: its events could not be made (error N): Pause in background does nothing in this run`; - the option stays off for that run. I left out a retry: a manual-reset and an auto-reset event failing to be made means the process is out of handles or memory, and retrying every frame would only repeat the failure and the log line. **L5 (Linux, Steam Deck).** Agreed; I have no Linux PC or Steam Deck here. It stays under **Still to test**: Linux X11 and Wayland (focus away, minimise, restore) and Steam Deck Game Mode (switch away and back), by hand. The Test Farm can't drive focus changes. On Linux a minimised window holds through its loss of keyboard focus, which X11 and Wayland both send; there is no separate minimised query there. **L6 (AMD, frame generation, Alt+Tab).** Agreed; this PC is NVIDIA (RTX 5080), so the #1482 setup can't be reproduced here. It stays under **Still to test**: Windows AMD, frame generation, borderless fullscreen, repeated Alt+Tab away and back with Pause in background on, checking the picture returns each time, by hand. The presenter and swapchain code are untouched. A hold only means no new frames are handed over while the window is away, and frame generation 2x (FSR 3.1 path) held and resumed cleanly on NVIDIA here. **L7 (interleaved base vs head).** Running now on this PC: - `dev.py ab --scene kakariko`: main against this PR, game in front, uncapped, A/B/A/B/A/B, for frame times. - Then two interleaved background runs each of main and this PR with the row on, for CPU, GPU and board power. The numbers will go into Measurements and a comment here. **L8 (guide screenshots).** The check's review hashes followed the menu sources this PR changes. I rendered Graphics, Audio and Controls with `scripts/screenshots/capture_menu.py` from main 3ab4db6e and from 7963e7db (WSL Ubuntu, clang++). The three differ only in the version text's box (x 1087–1261, y 20–31), and the published Graphics image matches 7963e7db's render but for that box. f008a02e3 records that review (revision and hashes) in `docs/user/images/guide/manifest.json` and keeps the PNG; `check_guide_screenshots.py --review-sources` passes.
llun force-pushed feat/pause-in-background from f008a02e3c
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Successful in 7s
CI / Third-party parts and guide screenshots (pull_request) Successful in 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 14s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 7014d0ae94
Some checks failed
CI / What the change needs (pull_request) Successful in 15s
CI / Third-party parts and guide screenshots (pull_request) Successful in 19s
PR description / Title and description (pull_request_target) Successful in 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 19s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-11-29 05:30:50 +00:00
Compare
Author
Member

Rebased onto main 9ce616330 (7014d0ae9); the guide manifest's review now names d6a19a6eb, the same files. L7: the interleaved main-against-PR runs were not run; Measurements says so, and the single-run numbers stand as they are. The movie fix (L1) is covered by the game-free check; a hold during a movie in the game is under Still to test.

Rebased onto main 9ce616330 (7014d0ae9); the guide manifest's review now names d6a19a6eb, the same files. L7: the interleaved main-against-PR runs were not run; Measurements says so, and the single-run numbers stand as they are. The movie fix (L1) is covered by the game-free check; a hold during a movie in the game is under Still to test.
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. Pause in background substantially reduced resource use in the reported Windows run, but its gain and foreground cost still need an interleaved comparison against the actual base. Linux, Steam Deck and the AMD frame-generation setup also need the outstanding runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

Adds an optional background pause that stops game frames and audio, with Mute forced on and background controller input forced off. It saves power in the reported run at the cost of additional focus, timing and audio coordination.

Should fix (2): not blocking, but worth doing before merging.

  • L2 gpu/vk/vk_replay.cpp:8780: The atomic read still races with the menu's plain write to the Pause option. When: Changing Pause in background in the menu writes opts.pause_background through menu_model.cpp while the game or audio thread can load it through this callback. Do: Synchronize every concurrent write and read of the Pause option, including the menu model's row store.
  • L4 host/background_pause.c:119: An event allocation failure still disables Pause in background permanently for the run. When: If either event cannot be allocated on the first frame, never becomes 2 and later frames return even if the resource shortage clears. Do: Allow a bounded or delayed retry after allocation failure while retaining the cleanup and avoiding repeated log spam.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 host/posix/display_sdl.c:477: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. When: X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. Do: Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.
  • L6 host/nn_vi.c:258: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. When: The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. Do: Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.
  • L7 host/nn_vi.c:258: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. When: The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. Do: Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.

@fix can do L2 and L4.

Since the last review (on 99c58061c8)
Resolved: L1 (Resuming does not advance the movie decoder's clock past the hold.); L3 (The focus state used by the new hold loop is shared across threads using volatile rather t…); L8 (The check CI / Third-party parts and guide screenshots (pull_request) fails on this head…)
Still open: L2 (The atomic read still races with the menu's plain write to the Pause option.); L4 (An event allocation failure still disables Pause in background permanently for the run.); L5 (The new focus-driven hold has not been exercised in game on Linux or Steam Deck.); L6 (The hold and resume path has not been exercised on the reported AMD borderless frame-gener…); L7 (Foreground performance and the claimed saving have not been compared with repeated interle…)

Checks: Still running: 7 checks.

Also noticed (2; not asked for, not blocking)
  • The POSIX CreateEventA stand-in dereferences its allocation without checking for failure.
  • An in-game movie hold remains to be exercised.
More: does it help, other systems, switches, what was read

Does it help: Unproven against the required repeated base-versus-head comparison. The author's single Windows runs report background CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W; the baseline was this branch with the option off.

Other systems: Windows NVIDIA focus, minimise, audio boundaries and 2x frame generation were exercised in game. Linux X11 and Wayland, Steam Deck, Windows AMD borderless frame generation, and an in-game movie hold remain untested.

Switches: Pause in background is a saved Gameplay option, off by default; opting in is appropriate because background streaming and input otherwise stop. When enabled it forces Mute in background on and Controller in background off.

Reviewed: 7014d0ae94 against 9ce6163304: Read the repository guidance and pull request template, the pause implementation and header, Gameplay row, relevant option callback, movie clock and decoder path, POSIX event allocation and focus changes. Reviewed the relevant diff and surrounding menu model, audio, frame pacing and FPS changes; the remaining changed files, generated manifest and tests were skimmed rather than read in full.; nothing run (a code review).

Checked and fine:

  • The movie clock excludes both completed holds and a hold in progress.
  • A partially created event is closed on the Windows allocation failure path.
  • The fix retains the pause path and its default-off option.

Testing: No commands that build or run code were executed. The reported Windows game runs and WAV inspection were considered; CI is still running.

Overlaps and merge order: Not established from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** Pause in background substantially reduced resource use in the reported Windows run, but its gain and foreground cost still need an interleaved comparison against the actual base. Linux, Steam Deck and the AMD frame-generation setup also need the outstanding runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. Adds an optional background pause that stops game frames and audio, with Mute forced on and background controller input forced off. It saves power in the reported run at the cost of additional focus, timing and audio coordination. **Should fix (2)**: not blocking, but worth doing before merging. - **L2** `gpu/vk/vk_replay.cpp:8780`: The atomic read still races with the menu's plain write to the Pause option. *When:* Changing Pause in background in the menu writes opts.pause_background through menu_model.cpp while the game or audio thread can load it through this callback. **Do:** Synchronize every concurrent write and read of the Pause option, including the menu model's row store. - **L4** `host/background_pause.c:119`: An event allocation failure still disables Pause in background permanently for the run. *When:* If either event cannot be allocated on the first frame, never becomes 2 and later frames return even if the resource shortage clears. **Do:** Allow a bounded or delayed retry after allocation failure while retaining the cleanup and avoiding repeated log spam. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `host/posix/display_sdl.c:477`: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. *When:* X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. **Do:** Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode. - **L6** `host/nn_vi.c:258`: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. *When:* The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. **Do:** Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns. - **L7** `host/nn_vi.c:258`: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. *When:* The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. **Do:** Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use. `@fix` can do L2 and L4. **Since the last review** (on 99c58061c82a) Resolved: L1 (Resuming does not advance the movie decoder's clock past the hold.); L3 (The focus state used by the new hold loop is shared across threads using volatile rather t…); L8 (The check `CI / Third-party parts and guide screenshots (pull_request)` fails on this head…) Still open: L2 (The atomic read still races with the menu's plain write to the Pause option.); L4 (An event allocation failure still disables Pause in background permanently for the run.); L5 (The new focus-driven hold has not been exercised in game on Linux or Steam Deck.); L6 (The hold and resume path has not been exercised on the reported AMD borderless frame-gener…); L7 (Foreground performance and the claimed saving have not been compared with repeated interle…) **Checks:** Still running: 7 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The POSIX CreateEventA stand-in dereferences its allocation without checking for failure. - An in-game movie hold remains to be exercised. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven against the required repeated base-versus-head comparison. The author's single Windows runs report background CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W; the baseline was this branch with the option off. **Other systems:** Windows NVIDIA focus, minimise, audio boundaries and 2x frame generation were exercised in game. Linux X11 and Wayland, Steam Deck, Windows AMD borderless frame generation, and an in-game movie hold remain untested. **Switches:** Pause in background is a saved Gameplay option, off by default; opting in is appropriate because background streaming and input otherwise stop. When enabled it forces Mute in background on and Controller in background off. **Reviewed:** 7014d0ae94a1 against 9ce616330405: Read the repository guidance and pull request template, the pause implementation and header, Gameplay row, relevant option callback, movie clock and decoder path, POSIX event allocation and focus changes. Reviewed the relevant diff and surrounding menu model, audio, frame pacing and FPS changes; the remaining changed files, generated manifest and tests were skimmed rather than read in full.; nothing run (a code review). **Checked and fine:** - The movie clock excludes both completed holds and a hold in progress. - A partially created event is closed on the Windows allocation failure path. - The fix retains the pause path and its default-off option. **Testing:** No commands that build or run code were executed. The reported Windows game runs and WAV inspection were considered; CI is still running. **Overlaps and merge order:** Not established from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
Author
Member
@fix
fix(pause): synchronize the option and retry event creation
Some checks failed
PR description / Title and description (pull_request_target) Successful in 8s
CI / What the change needs (pull_request) Successful in 10s
CI / Third-party parts and guide screenshots (pull_request) Failing after 14s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 16s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2c7d870eed
As the review on #2786 asked.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The layout-only compilation issue is fixed, and the reported Windows run shows the game holding and resuming. The requested platform runs and repeated base-versus-head measurements are still missing. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 2c7d870eed.

Changed

  • Synchronize Pause option access: Published a separate atomic host value on menu changes and after settings load; host callbacks read that value instead of the menu row. Updated the source check in tests/test_pause_background.py:230.
  • Retry failed event allocation: host/background_pause.c:143 retries event creation after five seconds, closes any partial allocation, and logs the failure only once.
  • Layout-only menu fixture compilation: Wrapped the renderer-dependent hook in MENU_HOOK in gpu/vk/menu/gameplay.cpp:41. Tests were not run, as requested.

Nothing was built or run: the checks run again on the new head.

Pause in background stops game work while the window is away and resumes it on return. It adds coordination across the menu, host, audio and timing paths in exchange for lower background resource use.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 host/posix/display_sdl.c:477: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. When: X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. Do: Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.
  • L6 host/nn_vi.c:258: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. When: The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. Do: Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.
  • L7 host/nn_vi.c:258: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. When: The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. Do: Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (4; not asked for, not blocking)
  • The POSIX CreateEventA stand-in dereferences its allocation without checking for failure.
  • An in-game movie hold remains to be exercised.
  • The movie hold and resume still needs the in-game check listed in the pull request.
  • A hold during a movie still needs the in-game run listed in the pull request.
More: does it help, other systems, switches, what was read

Does it help: Unproven against the requested repeated actual-base comparison. The author's single Windows RTX 5080 runs report background CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W; the comparison used this branch with the option off as the baseline.

Other systems: The Windows NVIDIA run covered focus loss, minimization, audio boundaries and 2x frame generation. Linux X11 and Wayland, Steam Deck, and Windows AMD borderless frame generation remain untested in game.

Switches: Pause in background is a saved player option, off by default; this preserves background play unless the player opts in. No environment switch was added.

Reviewed: 2c7d870eed against 9ce6163304: Read gameplay.cpp and background_pause.c in full, the fix and since-ledger diffs, the relevant platform and menu diffs, repository rules, template, comments and supplied run reports. Skimmed the remaining pull request diff and tests; the other changed code files were not read in full.; nothing run (a code review).

Checked and fine:

  • The normal renderer build retains the pause option's on-change hook.
  • The option remains off by default, and the Windows report covers its menu interactions.

Testing: No commands that build or run tests were executed. CI has not run on this head; the author reports Windows in-game testing and Linux host compilation against stand-ins.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The layout-only compilation issue is fixed, and the reported Windows run shows the game holding and resuming. The requested platform runs and repeated base-versus-head measurements are still missing. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 2c7d870eedb6. **Changed** - **Synchronize Pause option access**: Published a separate atomic host value on menu changes and after settings load; host callbacks read that value instead of the menu row. Updated the source check in tests/test_pause_background.py:230. - **Retry failed event allocation**: host/background_pause.c:143 retries event creation after five seconds, closes any partial allocation, and logs the failure only once. - **Layout-only menu fixture compilation**: Wrapped the renderer-dependent hook in MENU_HOOK in gpu/vk/menu/gameplay.cpp:41. Tests were not run, as requested. Nothing was built or run: the checks run again on the new head. Pause in background stops game work while the window is away and resumes it on return. It adds coordination across the menu, host, audio and timing paths in exchange for lower background resource use. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `host/posix/display_sdl.c:477`: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. *When:* X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. **Do:** Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode. - **L6** `host/nn_vi.c:258`: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. *When:* The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. **Do:** Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns. - **L7** `host/nn_vi.c:258`: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. *When:* The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. **Do:** Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (4; not asked for, not blocking)</summary> - The POSIX CreateEventA stand-in dereferences its allocation without checking for failure. - An in-game movie hold remains to be exercised. - The movie hold and resume still needs the in-game check listed in the pull request. - A hold during a movie still needs the in-game run listed in the pull request. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven against the requested repeated actual-base comparison. The author's single Windows RTX 5080 runs report background CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W; the comparison used this branch with the option off as the baseline. **Other systems:** The Windows NVIDIA run covered focus loss, minimization, audio boundaries and 2x frame generation. Linux X11 and Wayland, Steam Deck, and Windows AMD borderless frame generation remain untested in game. **Switches:** Pause in background is a saved player option, off by default; this preserves background play unless the player opts in. No environment switch was added. **Reviewed:** 2c7d870eedb6 against 9ce616330405: Read gameplay.cpp and background_pause.c in full, the fix and since-ledger diffs, the relevant platform and menu diffs, repository rules, template, comments and supplied run reports. Skimmed the remaining pull request diff and tests; the other changed code files were not read in full.; nothing run (a code review). **Checked and fine:** - The normal renderer build retains the pause option's on-change hook. - The option remains off by default, and the Windows report covers its menu interactions. **Testing:** No commands that build or run tests were executed. CI has not run on this head; the author reports Windows in-game testing and Linux host compilation against stand-ins. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
@ -25,0 +39,4 @@
.hint = hn_pause_background,
// (atomic stores: the game's and the mixer's threads read them through the option callback, vk_replay.cpp)
.on_change = MENU_HOOK([](int v) {
__atomic_store_n(&pause_background_now, v, __ATOMIC_RELAXED);
Member

L9 (blocking): The new hook refers to a renderer variable that the layout-only menu fixture does not declare.

When: tests/menu_model_fixture.py replaces vk_menu.h with a stand-in declaring only Options and opts, then compiles every menu module with MENU_LAYOUT_ONLY. gameplay.cpp therefore fails to compile because pause_background_now is undeclared.

Do: Wrap the renderer-dependent hook in MENU_HOOK, or provide an appropriate declaration and definition in the layout fixture.

**L9** (blocking): The new hook refers to a renderer variable that the layout-only menu fixture does not declare. *When:* tests/menu_model_fixture.py replaces vk_menu.h with a stand-in declaring only Options and opts, then compiles every menu module with MENU_LAYOUT_ONLY. gameplay.cpp therefore fails to compile because pause_background_now is undeclared. **Do:** Wrap the renderer-dependent hook in MENU_HOOK, or provide an appropriate declaration and definition in the layout fixture.
Author
Member
@fix
docs(guide): review screenshot sources after pause synchronization
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 14s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 12s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 4m14s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m0s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m23s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m41s
CI / Website build and checks (pull_request) Successful in 1m34s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 22m45s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 35m51s
6432c05327
As the review on #2786 asked.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The Windows run shows the game holding and resuming, with a large reduction in background resource use. Linux and Steam Deck behavior, the AMD frame-generation setup, and repeated base-versus-head measurements remain unverified. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 6432c05327.

Changed

  • Guide screenshot source review: Updated the three source fingerprints in docs/user/images/guide/manifest.json:980 and recorded the comparison in docs/user/images/guide/source-review-2786-2c7d870e.md:1. The pictured Graphics controls remain unchanged. Checks were not run, as requested.

Nothing was built or run: the checks run again on the new head.

Adds an off-by-default option to pause the game in the background, reducing background CPU and GPU work while forcing background mute on and background controller input off. The latest fix updates the guide screenshot’s source review without changing game behavior.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 host/posix/display_sdl.c:477: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. When: X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. Do: Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode.
  • L6 host/nn_vi.c:258: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. When: The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. Do: Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns.
  • L7 host/nn_vi.c:258: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. When: The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. Do: Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use.

Checks: they run again on this head (CI / Third-party parts and guide screenshots (pull_request) failed on the last one); a failure shows on the pull request.

Also noticed (5; not asked for, not blocking)
  • The POSIX CreateEventA stand-in dereferences its allocation without checking for failure.
  • An in-game movie hold remains to be exercised.
  • The movie hold and resume still needs the in-game check listed in the pull request.
  • A hold during a movie still needs the in-game run listed in the pull request.
  • A hold during a movie remains untested in game.
More: does it help, other systems, switches, what was read

Does it help: Unproven against the actual base and head: single Windows runs reported CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W behind another window. The comparison used the PR with the option off as the baseline; repeated interleaved runs and foreground frame times are missing.

Other systems: Windows NVIDIA hold, resume, audio boundaries and 2x frame generation were reported working. Linux X11, Wayland, Steam Deck and Windows AMD borderless frame generation still need the runs described in the pull request; a movie hold also remains untested in game.

Switches: Pause in background is added off by default. When enabled it forces Mute in background on and Controller in background off; those defaults and interactions are described and tested on Windows.

Reviewed: 6432c05327 against 9ce6163304: Read AGENTS.md, CONTRIBUTING.md, the pull request template, host/background_pause.c and its header, the relevant platform and acquire diffs, the guide fix diff, and the synchronization changes affecting the guide review. The remaining changed code, tests, manifest and recorded runs were not read in full; the full original diff was not reviewed.; nothing run (a code review).

Checked and fine:

  • The guide source review describes the synchronization changes since the previous reviewed revision; the fix leaves the pause implementation intact.

Testing: No commands that build or run the project were executed. The reported Windows in-game runs and pending platform runs are described in the pull request; CI has not run on this head.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The Windows run shows the game holding and resuming, with a large reduction in background resource use. Linux and Steam Deck behavior, the AMD frame-generation setup, and repeated base-versus-head measurements remain unverified. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 6432c0532751. **Changed** - **Guide screenshot source review**: Updated the three source fingerprints in docs/user/images/guide/manifest.json:980 and recorded the comparison in docs/user/images/guide/source-review-2786-2c7d870e.md:1. The pictured Graphics controls remain unchanged. Checks were not run, as requested. Nothing was built or run: the checks run again on the new head. Adds an off-by-default option to pause the game in the background, reducing background CPU and GPU work while forcing background mute on and background controller input off. The latest fix updates the guide screenshot’s source review without changing game behavior. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `host/posix/display_sdl.c:477`: The new focus-driven hold has not been exercised in game on Linux or Steam Deck. *When:* X11, Wayland and gamescope can deliver focus and minimize transitions differently; the supplied Windows run cannot show that each resumes correctly there. **Do:** Run focus-away, minimize and restore checks on Linux X11 and Wayland and switch away and back in Steam Deck Game Mode. - **L6** `host/nn_vi.c:258`: The hold and resume path has not been exercised on the reported AMD borderless frame-generation setup. *When:* The change interrupts frame production during an Alt+Tab transition, which can affect the existing presenter and frame-generation paths even though their code is unchanged. **Do:** Run repeated Alt+Tab holds and restores on Windows AMD with frame generation and borderless fullscreen, checking that the picture returns. - **L7** `host/nn_vi.c:258`: Foreground performance and the claimed saving have not been compared with repeated interleaved runs of the actual base and head. *When:* The table uses the branch with the option off as main and reports single sampling windows, so it cannot show the foreground frame-time cost of the new per-frame path against the base. **Do:** Measure base and head in the same scene with repeated interleaved runs, including foreground frame times and background CPU and GPU use. **Checks:** they run again on this head (`CI / Third-party parts and guide screenshots (pull_request)` failed on the last one); a failure shows on the pull request. <details> <summary>Also noticed (5; not asked for, not blocking)</summary> - The POSIX CreateEventA stand-in dereferences its allocation without checking for failure. - An in-game movie hold remains to be exercised. - The movie hold and resume still needs the in-game check listed in the pull request. - A hold during a movie still needs the in-game run listed in the pull request. - A hold during a movie remains untested in game. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven against the actual base and head: single Windows runs reported CPU falling from 268.9% to 3.0% of one core, GPU use from 37.2% to 0%, and board power from 87.6 W to 53.3 W behind another window. The comparison used the PR with the option off as the baseline; repeated interleaved runs and foreground frame times are missing. **Other systems:** Windows NVIDIA hold, resume, audio boundaries and 2x frame generation were reported working. Linux X11, Wayland, Steam Deck and Windows AMD borderless frame generation still need the runs described in the pull request; a movie hold also remains untested in game. **Switches:** Pause in background is added off by default. When enabled it forces Mute in background on and Controller in background off; those defaults and interactions are described and tested on Windows. **Reviewed:** 6432c0532751 against 9ce616330405: Read AGENTS.md, CONTRIBUTING.md, the pull request template, host/background_pause.c and its header, the relevant platform and acquire diffs, the guide fix diff, and the synchronization changes affecting the guide review. The remaining changed code, tests, manifest and recorded runs were not read in full; the full original diff was not reviewed.; nothing run (a code review). **Checked and fine:** - The guide source review describes the synchronization changes since the previous reviewed revision; the fix leaves the pause implementation intact. **Testing:** No commands that build or run the project were executed. The reported Windows in-game runs and pending platform runs are described in the pull request; CI has not run on this head. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch feat/pause-in-background 2026-11-29 06:12:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
MagicBeanDev/Longshot!2786
No description provided.