WIP: fix(sound): above 60 fps the sound effects no longer go silent after a minute or two #3308

Draft
llun wants to merge 3 commits from llun/Longshot:fix/sound-engine-60hz-high-fps into main
Member

DO NOT MERGE. This is up so the player who reported the bug can build it with the Longshot Launcher and test it at a 240 cap. It stays work in progress until their run and the Lens of Truth check below are done.

Summary

Above a Game frame rate cap of 60, the sound effects and voices go silent a minute or two after loading a save. The music keeps playing, then it can stop too (the Forest Temple). A player at a 240 cap (about 200 to 220 fps, RTX 5090) hit it on Nightly 1179 and Nightly 1217. At a cap of 60 it never happened, with or without their one sound mod.

What their log showed (HOS_AUDIO_STATS=1, HOS_FPS_LOG=1):

  • The 60 Hz sound gate counted right the whole time ("sound job ran 195 of the last 600 frames (step 0.360, held to 60 Hz)").
  • It was not a slow pile-up. Within about two seconds, six finished voices (no wave buffers left, everything played) stayed started for good. The game was still running and still changed those voices' pitch every second.
  • From then on, every once-a-second line read "17 voices started (11 with buffers)": no new sound started, and no finished one was retired.

Why. Since #2983 (the Lens of Truth's on and off sounds above 60 fps), phase 0 of the sound job (f_80435300) runs on every frame. On a frame the 60 Hz gate holds, it gets a step of 0, but every module and the sound system's update (f_8012f9c0) still run. That update counts its own calls and hands work to the audio thread. At 220 fps it ran about 220 times a second against the renderer's 200 audio frames a second, and the voices stopped being retired.

What this changes. On a frame the gate holds, phase 0 now:

  • calls only the one-frame cues' module (EVENT_CUE_VTABLE; its vt+0x30, f_80ac6780, starts the Lens's on and off cues), so the Lens fix stays;
  • skips every other module, as before;
  • skips the sound system's update and the rest of f_80435860 through a new jump site, sound.systemUpdate.

Everything else runs once a whole 60 fps step, as at a cap of 60. A cap of 60 is unchanged: no frame is held there.

How to see it on main: set the Game frame rate cap to 240 on a PC that reaches 200 fps or more, load a save and play for a few minutes (the Forest Temple, the Temple of Time and the Market all showed it). The sound effects stop. With HOS_AUDIO_STATS=1 the "voices started" line freezes.

Read first:

  • the sound paragraph at the top of game/crates/game-core/src/fixes/high_fps.rs;
  • sound_module_held_rule and sound_system_held_rule;
  • sound.systemUpdate in game/sites/sites.toml.

The cause was narrowed with two agents arguing opposite fixes. Delta time, as the cloth fix (#3242) does, was ruled out: it would still update the sound engine at the frame rate.

Testing

Tested: Windows 11, RTX 5080, NVIDIA 621.47, headless runs through the job queue.

  • The new check, a_held_frame_leaves_the_sound_engine_and_its_modules_to_the_next_run in high_fps.rs, fails on the test commit as on main: "120 fps: the sound system updated 1200 times for 600 whole steps". It passes with the fix at 120, 144, 165, 200, 240, 360 and 480 fps and at a cap of 60.
  • The other checks: all 22 high-fps tests in game-core pass. cargo test -p sites passes, including the site owners.
  • The game: the lift places sound.systemUpdate in f_80435860 beside the two module sites (the work folder's gen/edits.txt). dev.py smoke passes (kokiri-start, in play, menu opened). A 4-minute run uncapped in Handheld, Link walking, rolling and swinging between the Market and Hyrule Field (about 77 fps there; the gate held about 1 frame in 5, so the skip ran): sounds kept starting (a voice started in 182 of 225 seconds of HOS_AUDIO_STATS), and no finished voice stayed started for more than a second, as at a cap of 60.
  • What this PC can't show: it reaches about 130 to 165 fps, not the 200+ where the freeze shows. Three runs of main here (144 to 165 fps cap, Market and Hyrule Field, 4 to 5 minutes each) did not freeze, so this PC cannot show the fix working.

Still to test:

  • The reporter's PC, Windows, RTX 5090, 240 cap: play 10 minutes from a save, the Forest Temple included, with HOS_AUDIO_STATS=1 and HOS_FPS_LOG=1 in longshot_env.txt. Expect sound effects and voices to keep playing and the "voices started" counts to keep changing. (by hand, the reporter)
  • Any PC, 144 and 240 cap: turn the Lens of Truth on and off about 20 times (Debug tools > Inventory gives it and the Magic Meter). Expect every on and off sound, as #2983 made it. (by hand)
  • Any PC, above 60: listen to the area music, the battle music ending after a fight, and an ocarina song. Expect them as at 60 fps, with the same pitch and tempo. (by hand)
  • @Beanstalk on a PC that reaches 200 fps or more at a 240 cap: 10 minutes in a game area with HOS_AUDIO_STATS=1. Expect the "voices started" line to keep changing.

Measurements

Nothing measured. This only removes calls on frames the gate holds, and it makes no performance claim.

Risks

  • A one-frame cue another module takes on a held frame would be lost above 60 fps. That is the Lens bug #2983 fixed, for a cue this PR doesn't know about. Only f_80ac6780 has the Lens's cue names. A revert brings back #2983's behaviour, and the freeze with it.
  • The Lens's cue now waits for the next 60 Hz run before the sound system's update takes it: up to about 16 ms later than #2983, the same as at a cap of 60.
  • A cap of 60 is unchanged. Nothing changes in saves, settings or caches.

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. (It ran in the game here, but this PC can't reach the frame rate the bug needs: the reporter's run is pending.)
  • mise run test passes (any failure that also fails on main is named). 887 passed, 14 failed, 55 skipped (Windows, 12 at once). None of the 14 reads a file this PR changes: test_lifter stops at a clippy type_complexity error in game/crates/api/src/settings/service.rs and the ffi-gen check, both from main; test_device_lost_exit, test_fps_stats, test_lost_wait_said, test_present_acquire_ahead, test_present_device_loss, test_present_thread, test_present_probe_retirement, test_present_probe, test_queue_priority, test_recorder_parts, test_submit_oom, test_sync_watch_event and test_stack_commit check the renderer and the host's memory, which this PR leaves alone. cargo clippy -p game-core -p sites --all-targets -- -D warnings and cargo fmt --check are clean on the changed crates (the third commit is rustfmt's wrap of one assert in the test).
  • 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 fix: a game-free test that fails on main and passes here.
  • 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

> **DO NOT MERGE.** This is up so the player who reported the bug can build it with the Longshot Launcher and test it at a 240 cap. It stays work in progress until their run and the Lens of Truth check below are done. ## Summary Above a **Game frame rate cap** of 60, the sound effects and voices go silent a minute or two after loading a save. The music keeps playing, then it can stop too (the Forest Temple). A player at a 240 cap (about 200 to 220 fps, RTX 5090) hit it on Nightly 1179 and Nightly 1217. At a cap of 60 it never happened, with or without their one sound mod. **What their log showed** (`HOS_AUDIO_STATS=1`, `HOS_FPS_LOG=1`): - The 60 Hz sound gate counted right the whole time ("sound job ran 195 of the last 600 frames (step 0.360, held to 60 Hz)"). - It was not a slow pile-up. Within about two seconds, six finished voices (no wave buffers left, everything played) stayed started for good. The game was still running and still changed those voices' pitch every second. - From then on, every once-a-second line read "17 voices started (11 with buffers)": no new sound started, and no finished one was retired. **Why.** Since #2983 (the Lens of Truth's on and off sounds above 60 fps), phase 0 of the sound job (`f_80435300`) runs on every frame. On a frame the 60 Hz gate holds, it gets a step of 0, but every module and the sound system's update (`f_8012f9c0`) still run. That update counts its own calls and hands work to the audio thread. At 220 fps it ran about 220 times a second against the renderer's 200 audio frames a second, and the voices stopped being retired. **What this changes.** On a frame the gate holds, phase 0 now: - calls only the one-frame cues' module (`EVENT_CUE_VTABLE`; its `vt+0x30`, `f_80ac6780`, starts the Lens's on and off cues), so the Lens fix stays; - skips every other module, as before; - skips the sound system's update and the rest of `f_80435860` through a new jump site, `sound.systemUpdate`. Everything else runs once a whole 60 fps step, as at a cap of 60. A cap of 60 is unchanged: no frame is held there. **How to see it on main:** set the Game frame rate cap to 240 on a PC that reaches 200 fps or more, load a save and play for a few minutes (the Forest Temple, the Temple of Time and the Market all showed it). The sound effects stop. With `HOS_AUDIO_STATS=1` the "voices started" line freezes. **Read first:** - the sound paragraph at the top of `game/crates/game-core/src/fixes/high_fps.rs`; - `sound_module_held_rule` and `sound_system_held_rule`; - `sound.systemUpdate` in `game/sites/sites.toml`. The cause was narrowed with two agents arguing opposite fixes. Delta time, as the cloth fix (#3242) does, was ruled out: it would still update the sound engine at the frame rate. ## Testing **Tested:** Windows 11, RTX 5080, NVIDIA 621.47, headless runs through the job queue. - **The new check**, `a_held_frame_leaves_the_sound_engine_and_its_modules_to_the_next_run` in `high_fps.rs`, fails on the test commit as on main: "120 fps: the sound system updated 1200 times for 600 whole steps". It passes with the fix at 120, 144, 165, 200, 240, 360 and 480 fps and at a cap of 60. - **The other checks:** all 22 high-fps tests in `game-core` pass. `cargo test -p sites` passes, including the site owners. - **The game:** the lift places `sound.systemUpdate` in `f_80435860` beside the two module sites (the work folder's `gen/edits.txt`). `dev.py smoke` passes (kokiri-start, in play, menu opened). A 4-minute run uncapped in Handheld, Link walking, rolling and swinging between the Market and Hyrule Field (about 77 fps there; the gate held about 1 frame in 5, so the skip ran): sounds kept starting (a voice started in 182 of 225 seconds of `HOS_AUDIO_STATS`), and no finished voice stayed started for more than a second, as at a cap of 60. - **What this PC can't show:** it reaches about 130 to 165 fps, not the 200+ where the freeze shows. Three runs of main here (144 to 165 fps cap, Market and Hyrule Field, 4 to 5 minutes each) did not freeze, so this PC cannot show the fix working. **Still to test:** - The reporter's PC, Windows, RTX 5090, 240 cap: play 10 minutes from a save, the Forest Temple included, with `HOS_AUDIO_STATS=1` and `HOS_FPS_LOG=1` in `longshot_env.txt`. Expect sound effects and voices to keep playing and the "voices started" counts to keep changing. (by hand, the reporter) - Any PC, 144 and 240 cap: turn the Lens of Truth on and off about 20 times (Debug tools > Inventory gives it and the Magic Meter). Expect every on and off sound, as #2983 made it. (by hand) - Any PC, above 60: listen to the area music, the battle music ending after a fight, and an ocarina song. Expect them as at 60 fps, with the same pitch and tempo. (by hand) - @Beanstalk on a PC that reaches 200 fps or more at a 240 cap: 10 minutes in a game area with `HOS_AUDIO_STATS=1`. Expect the "voices started" line to keep changing. ## Measurements Nothing measured. This only removes calls on frames the gate holds, and it makes no performance claim. ## Risks - **A one-frame cue another module takes on a held frame would be lost above 60 fps.** That is the Lens bug #2983 fixed, for a cue this PR doesn't know about. Only `f_80ac6780` has the Lens's cue names. A revert brings back #2983's behaviour, and the freeze with it. - **The Lens's cue now waits for the next 60 Hz run** before the sound system's update takes it: up to about 16 ms later than #2983, the same as at a cap of 60. - A cap of 60 is unchanged. Nothing changes in saves, settings or caches. ## Checklist ### Ready for review - [x] 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. (It ran in the game here, but this PC can't reach the frame rate the bug needs: the reporter's run is pending.) - [x] `mise run test` passes (any failure that also fails on `main` is named). 887 passed, 14 failed, 55 skipped (Windows, 12 at once). None of the 14 reads a file this PR changes: `test_lifter` stops at a clippy `type_complexity` error in `game/crates/api/src/settings/service.rs` and the `ffi-gen` check, both from main; `test_device_lost_exit`, `test_fps_stats`, `test_lost_wait_said`, `test_present_acquire_ahead`, `test_present_device_loss`, `test_present_thread`, `test_present_probe_retirement`, `test_present_probe`, `test_queue_priority`, `test_recorder_parts`, `test_submit_oom`, `test_sync_watch_event` and `test_stack_commit` check the renderer and the host's memory, which this PR leaves alone. `cargo clippy -p game-core -p sites --all-targets -- -D warnings` and `cargo fmt --check` are clean on the changed crates (the third commit is rustfmt's wrap of one assert in the test). - [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 fix: a game-free test that fails on `main` and passes here. - [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 game-free check of the high-fps sound rules from 120 to 480 fps: the sound system's update (f_8012f9c0) and every
module but the one-frame cues' runs once a whole 60 fps step, the cues' module on every frame, and everything on every
frame at a cap of 60. It fails on main: "120 fps: the sound system updated 1200 times for 600 whole steps".

The module rule now takes the module's vtable and the sound system's rule is added, both as main has them (no change in
what runs); the next commit changes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(sound): above 60 fps the sound effects no longer go silent after a minute or two
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
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
947ce36a77
Above a Frame rate cap of 60 (a player at 240, about 200-220 fps), the sound effects and voices went silent within a
minute or two of loading a save, then the music too. Their HOS_AUDIO_STATS log showed six finished voices staying
started for good and no new sound starting, while the 60 Hz sound gate counted right.

Since PR 2983 (the Lens of Truth's cues), phase 0 of the sound job ran on every frame: every module and the sound
system's update (f_8012f9c0), which counts its own calls and hands work to the audio thread, ran at the frame rate.
Now, on a frame the gate holds, phase 0 calls only the one-frame cues' module (EVENT_CUE_VTABLE, its vt+0x30
f_80ac6780 starts the Lens's on and off cues), and a new jump site, sound.systemUpdate, skips the sound system's update
and the rest of f_80435860. Everything else runs once a whole 60 fps step, as at a cap of 60.

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

Tested in game: DO NOT MERGE: up for the reporter's test at a 240 cap. Windows 11, RTX 5080, NVIDIA 621.47, headless through the job queue, the two commits before their rebase onto be4942212 (same diff). dev.py smoke PASS (kokiri-start, in play, menu opened). About 4 minutes uncapped in Handheld between the Market and Hyrule Field (~77 fps, the gate holding ~1 frame in 5): sounds kept starting and no finished voice stayed started over a second. This PC can't reach the 200+ fps the freeze needs, so the fix itself is not yet shown working: that is the reporter's run in Still to test.

Tested in game: DO NOT MERGE: up for the reporter's test at a 240 cap. Windows 11, RTX 5080, NVIDIA 621.47, headless through the job queue, the two commits before their rebase onto be4942212 (same diff). dev.py smoke PASS (kokiri-start, in play, menu opened). About 4 minutes uncapped in Handheld between the Market and Hyrule Field (~77 fps, the gate holding ~1 frame in 5): sounds kept starting and no finished voice stayed started over a second. This PC can't reach the 200+ fps the freeze needs, so the fix itself is not yet shown working: that is the reporter's run in Still to test.
test(sound): the held-frame check's long assert as rustfmt has it
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Waiting to run
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
6a098b9d05
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Waiting to run
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/sound-engine-60hz-high-fps:llun-fix/sound-engine-60hz-high-fps'
git switch 'llun-fix/sound-engine-60hz-high-fps'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3308
No description provided.