feat(audio): Pause in background, the game stopped while its window is behind another one or minimised #2786
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2786
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:feat/pause-in-background"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_backgroundinlongshot_options.ini). With it on, while another window has the focus or the game's window isminimised, 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:
How it works, for review (read
host/background_pause.cfirst):gpu/vk/menu/gameplay.cpp(Pause in background, with anon_changethat turns Mute in background onand Controller in background off),
gpu/vk/menu/volume.cpp(Mute in background) andgpu/vk/menu/controller.cpp(Controller in background). The latter two get
lockedandsyncwhile Pause is on, and hints whose variants end sothe menu can size the help.
hos_vi_native_acquire(host/nn_vi.c). This is the first host code of every game frame, onthe 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.cWM_ACTIVATEAPP/WM_SETFOCUS/WM_SIZE,host/posix/display_sdl.cSDL focus events), with a 250 ms timeout. Itnever spins. The workers, the renderer, its presenter and frame generation's display thread get no new frame and idle.
held-image area of #1482 and #2083. The last frame simply stays on screen.
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.
host/nn_audio.crenderer_main): the mixer fades its last frame out to exactly 0, then mixes nothing andstops signalling the game's sound thread. On resume the voices go on from the sample they stopped at, faded in.
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_PAUSEDthrough the existingoption_set,gpu/vk/vk_fps.cppfps_hold_gap). Without this, a 5-minute pause would be sent as a 5-minute hitch.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.
until the first frame), and in runs with no window to come back to:
HOS_HEADLESS,HOS_WINDOW_NOACTIVATE(test runsopened behind) and
HOS_INPUT_PLAY.with a 4-minute hold). The opt-in
RX_VK_HANG_DUMPwatchdog writes one stack dump after 20 s without a present, thencarries on; it is a diagnostic switch only.
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 ownfolder was compared with
diff -rqafterwards: unchanged.(
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 to284 s.
its window is minimised); restored, it went on (after 46.2 s held).not given backor held-image line, no devicelost. Straight back to 60 fps.
The largest jump between neighbouring samples in the whole dump (1925 of 32767) is in normal play, not at a resume.
frame interpolation: 582 frames shown on time, 0 late.pause:line. It runs behind another window and minimised exactly as before (numbersbelow).
locked it again.
settings.inihadpause_in_background=1andcontroller_in_background=0.99c58061c): the row sits after Game speed. Started with Pause off, Mute off and Controlleron, then turned Pause on in the menu:
refused.
after 10.7 s held).settings.inisavedpause_in_background=1,mute_in_background=1,controller_in_background=0.black window at start with Pause on. Fixed, and the test now walks that hint the way the menu does.
tests/test_pause_background.py(new);test_pacing_policy,screensaver_test.c(stand-ins for the newcalls) 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) compilewith gcc against the POSIX stand-ins, with the same warnings as main.
Still to test:
pictures skipped to catch upline underHOS_VIDEO_LOG=1. The fix (d6a19a6eb) is covered by the game-free check only.pause: the game is heldandgoes onlines, and the game going on where it was. On Linux a minimised window is seenthrough the loss of keyboard focus only.
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.
nvidia-smipower.draw, the whole card. Another session's game ran beside some samples, so only thosewithout it are shown.
783b77401.9fe89dd39and99c58061cchange only the menu rows, the Controller and Mute rules, and its both-on run heldthe same way (CPU 1.4% of one core, its GPU 0%, board power 51.7 W).
3ab4db6e9(measured as this PR with the row off)783b77401, row onCPU package power wasn't measured. There is no meter on this PC, but the process's CPU time falls about 99%.
Risks
old behaviour.
focus needs it off. While it is on, Controller in background is unavailable and Mute in background is forced on, as
asked.
GetForegroundWindow, as Mute in backgroundand the input already do).
hid: the game read no controller for N sreports the hold's length. It is a log line only.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). The checks that read the changed filespass. These fail on
maintoo, 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).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.compile with gcc against the POSIX stand-ins.
Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
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.
Possibly related, for context:
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.@review
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.
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.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.
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.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.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)
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.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.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.@fixcan 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:
99c58061c8against3ab4db6e91: 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:
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.
@ -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;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;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);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.
@ -254,1 +255,4 @@(longshot) Pause in background holds the game here first, for the same reasons, before the frame's phase and itspacing (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();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.
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;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.
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.
7963e7db(Pause in background)Thanks, BeanBot. Answers by item; the fixes are in
7963e7dbfandf008a02e3.L1 (movie clock). Fixed in
7963e7dbf. A movie's clock indec_acquire(clock_ns,out_nsand the catch-up, hold and log reads) isnow
movie_now(): the wall clock less the time the game has been held (hos_background_held_ns, kept under a lock inhost/background_pause.cfrom a hold's start to its end). After a hold the movie goes on from the picture it stoppedat, as its sound does, with nothing skipped.
tests/test_pause_background.pycovers it:movie_nowand the held-time clock and runs a movie across two holds (10 s and 4 s). The movie's clockstands during each hold, then runs with the wall again.
dec_acquiremust read no wall clock for the movie; only its 100 ms output wait is left onhos_now_ns().With the old wall clock the compiled check fails (
movie_now() - clock_ns == 2 * s), and with any one read left on thewall clock the source check fails.
L2 (option reads). Done in
7963e7dbf, as far as this PR's own reads and writes go:HOS_OPT_PAUSE_BACKGROUNDandHOS_OPT_MUTE_BACKGROUND, including the new override, with__atomic_load_n(relaxed).on_changesets Mute in background and Controller in background with__atomic_store_n.The menu model's own store of a row's value (
menu_model.cppchange:*s.value = next) is still a plain alignedintstore. That is the same for every one of the menu's options that the host reads through this callback, Mute inbackground on
mainincluded. Making the model's stores atomic is a change to every row, so it's left out of this PR.tests/test_pause_background.pychecks the atomic reads, andtest_audio_volume.pyaccepts the atomic form for Mute inbackground.
L3 (Linux focus flag). Done in
7963e7dbf.hos_posix_window[0](the focus) is now:__atomic_store_n(release) at the window's start and on SDL's focus gained and lost(
host/posix/display_sdl.c);__atomic_load_n(acquire) by theGetForegroundWindowstand-in (host/posix/win32_posix.c), which iswhat 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 eitherCreateEventAfails:pause: its events could not be made (error N): Pause in background does nothing in this 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.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.pyfrom main3ab4db6eand from7963e7db(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.
f008a02e3records that review (revision and hashes) indocs/user/images/guide/manifest.jsonand keeps the PNG;check_guide_screenshots.py --review-sourcespasses.f008a02e3c7014d0ae94Rebased onto main
9ce616330(7014d0ae9); the guide manifest's review now namesd6a19a6eb, 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.@review
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.
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.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)
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.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.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.@fixcan 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)
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:
7014d0ae94against9ce6163304: 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:
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.
@fix
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
@fixchangedI changed this pull request: the new head is
2c7d870eed.Changed
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)
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.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.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)
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:
2c7d870eedagainst9ce6163304: 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:
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.
@ -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);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.
@fix
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
@fixchangedI changed this pull request: the new head is
6432c05327.Changed
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)
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.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.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)
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:
6432c05327against9ce6163304: 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:
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.