fix(sound): above 60 fps the Lens of Truth's on and off sounds are no longer lost #2983
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2983
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/lens-sfx-high-fps"
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
With the Frame rate cap above 60, the Lens of Truth's on and off sounds were often missing: at 144 fps, about half of 20 toggles had no sound. At a cap of 60 they always play.
How to see it on main:
On main, many on and off sounds are missing. With this PR, every one plays.
Why it happened: above 60 fps the gate in
hos_oot_sound_gatekeeps the sound manager's job (f_80435300) at 60 Hz, so on the frames it holds, the job returned at once. The Lens queues its sound as a one-frame xlink event on the game thread, and when the job skipped that frame, the event was gone before the job ran again.What this changes:
f_80435860),sound.moduleUpdateandsound.moduleUpdateLate, skip only the music manager's and the song playbacks' note module's calls on held frames. Their existing latches (the held music change flags, the song note cue) keep counting the job's real runs.Two other variants, both tested by ear at 144 fps:
f_8012f9c0) on held frames, with all the modules skipped, still lost about half the sounds (16 of 20 on, 10 of 20 off). The module that plays the event is in those loops, so skipping all of them is not enough.test_music_manager_flags,test_song_note_cue.py).Read first: the paragraph in
game/oot_high_fps.hand its four inline functions (oot_sound_held,oot_sound_phase_runs,oot_sound_job_step,oot_sound_module_held), thenhos_oot_sound_gateingame/oot_high_fps.c, thenhos_site_sound_moduleingame/oot_sites.c, thentests/test_sound_held_frames.py.The cause was found by cfw34683 (on the issue).
Fixes #2721
Testing
Tested: Windows 10, RTX 4090, the user's own save with the Lens of Truth, in Zora's Domain, frame rate cap above 60 (about 144 fps), keyboard and controller. 20 Lens toggles in each run, counted by ear:
468bb8d2e268319f29On
268319f29the music sounded normal, and an ocarina song played correctly. The head,b49a6f952, differs from it only in two places, both from review.hos_oot_sound_gatenow works out its return value while it holdssound_lock; the value is the same. The new test now takes its clang from$CLANG. So I did not repeat the by-ear count onb49a6f952. The head did run in the game for the audio-on measurement below, with the held-frame path active.The checks:
tests/test_sound_held_frames.py, fails on the test commit, as on main. For example:FAIL: 144 fps: 1681 of 2880 one-frame sound events lost (the gate held the job on 1681 of 2880 frames; phase 0 reached the sound system on 0 of them). It passes on the head,b49a6f952, with 89 checks at 120, 144, 165 and 240 fps, uncapped, and capped at 60. Undoing the module skip or the step of 0 makes it fail again.tests/test_high_fps_fixes.pyandtests/test_song_note_cue.pypass on the head.cargo test -p sitespasses on the head (53 tests), including the check that the outcome lines match the site table.--strict: the host code builds with no new warnings, andtests/run_all.pygives 828 passed and 89 failed on the head,b49a6f952, against 827 passed and 89 failed on main468bb8d2e. The failing files are the same on both, and the one extra pass is the new test.tests/test_oot_cloth.pyis among the failures on main too.Still to test:
Measurements
Verdict: no measurable cost, with the audio on or off. With the audio on, this PR and main differ by +2.2 fps (+1.4%) and -0.05 ms median frame time. That is inside both sides' own spread across their three runs: 156.8 to 162.0 fps for main, 157.5 to 163.9 fps for this PR. The pairs differ by -0.1, +3.0 and +1.9 fps. GPU time is the same.
Setup:
audio: output on the default device (4 devices), stereo.RX_VK_FRAME_TRACEper-frame data over 40 s, after an 18 s settle. The table gives the median of each side's three runs.oot: sound job ran 224 of the last 600 frames (step 0.382, held to 60 Hz).468bb8d2eb49a6f952The first measurement used the headless test profile, which sets
HOS_AUDIO=0. It was the same setup otherwise, with this PR at268319f29. It also showed no cost:HOS_AUDIO=0)468bb8d2e268319f29Risks
longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (The strict suite on Linux: the failures are the same as main's, andtest_oot_cloth.pyis named.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZm4vGmQAmJWyCvQFuA
Tested in game: Windows 10, RTX 4090 (NVIDIA 617.42), adult Zora's Domain on the user's own save, Frame rate cap above 60 (~144 fps): 20 Lens of Truth toggles each, counted by ear. main
468bb8d2emissed 7 on / 13 off; this head268319f29missed 0 / 0. Music normal and an ocarina song played correctly on this head.@Beanstalk On Steam Deck and on Linux with the Frame rate cap above 60: turn the Lens of Truth on and off about 20 times; expecting every on and off sound to play, the music unchanged and an ocarina song played correctly.
@cuecuemoar only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for268319f, and the PR has changed since (b49a6f9), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.@review
Recommendation: Request changes. The Lens sounds played in the reported Windows run, but the new gate return reads shared state outside its lock. The cost with audio enabled and the Linux and Steam Deck behavior also remain unmeasured.
Phase 0 now runs on held frames to capture one-frame sound events, while music and note modules remain gated. This fixes the reported Lens sound loss in the tested scene, at the cost of extra module work and hook calls above 60 fps.
Blocking (1): must change before merging.
game/oot_high_fps.c:66: The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock. (more on the line) Do: Compute the phase's return value from the local run while holding the lock, and return that saved value.Should fix (1): not blocking, but worth doing before merging.
tests/test_sound_held_frames.py:277: The new test defaults to clang without honoring CC. (more on the line) Do: Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
game/oot_sites.c:272: The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates. (more on the line) Do: Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results. (@fixdoes its part first: Reduce or avoid the additional held-frame module work if it can be narrowed to the event-processing path.)game/oot_high_fps.h:195: The changed sound path has not yet been exercised on Linux or Steam Deck. (more on the line) Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.@fixcan do L1, L2 and L4.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported case: at approximately 144 fps on Windows, main missed 7 of 20 on sounds and 13 of 20 off sounds; this head missed none. The reported performance comparison used HOS_AUDIO=0, so it does not establish the cost with normal audio output.
Other systems: The phase-0 change affects other sound modules and worker-thread timing above 60 fps on both Windows and Linux. Music and one ocarina song sounded right in the Windows run; Linux and Steam Deck runs are pending. GPU-specific rendering is not changed.
Switches: None added, changed or removed.
Reviewed:
268319f292against468bb8d2ee: Read the repository rules and PR template, commit messages, diff, changed sound logic and new test, and the relevant hook and test infrastructure. Skimmed the large site tables and existing test files; no generated files or translations changed. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no tests or project code were run. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -62,3 +64,3 @@hos_log("oot: sound job ran %lld of the last 600 frames (step %.3f%s)", ran, step,oot_sound_partial(step, t) ? ", held to 60 Hz" : "");return run;return oot_sound_phase_runs(&sound_gate, phase);L1 (blocking): The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock.
When: If a phase-1 or phase-2 callback is returning as a phase-0 callback changes the gate, the unlocked read races with that write and can return the other frame's decision; this is also a C data race.
Do: Compute the phase's return value from the local run while holding the lock, and return that saved value.
@ -183,0 +192,4 @@static inline int oot_sound_held(const OotSoundGate *g) {return !g->run;}L3 (should fix): The changed sound path has not yet been exercised on Linux or Steam Deck.
When: At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct.
Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.
@ -264,2 +269,4 @@}/* sound.moduleUpdate and sound.moduleUpdateLate (jump, before phase 0's call of a module, x0 the module): non-zero skips thecall of the music manager or the song playbacks' note module on a frame the gate held */L2 (should fix): The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates.
When: Above 60 fps, phase 0 and its module hooks run on held frames while a normal player also has audio output active; the reported headless runs do not measure that combination.
Do: Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results.
@ -0,0 +274,4 @@def main():parser = argparse.ArgumentParser(description=__doc__)parser.add_argument("--cc", default="clang")L4 (should fix): The new test defaults to clang without honoring CC.
When: A developer invoking the test with CC set to an available compiler still invokes clang; if clang is not on PATH the test fails before checking the fix.
Do: Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint.
268319f292b49a6f9525Pushed
b49a6f952. It replaces268319f29and is still on main468bb8d2e. Main has moved one commit since, and that commit does not touch these files. The review's changes are folded into the PR's two commits: test7416c9b07, fixb49a6f952.L1 (blocking),
game/oot_high_fps.c: fixed.hos_oot_sound_gatenow works out its answer,oot_sound_phase_runs, while it holdssound_lock, and returns that saved value. The answer is the same as before. The only difference is that it can no longer read a gate another phase is changing.L4, the test's compiler: changed, but not to
CC. The fixture has to be compiled with clang. It links the hooks' object, which uses native TLS, and mingw's gcc can't link that (tests/sitehooks.py, its docstring). WithCC=gcc, honoringCCwould break the test instead of fixing it. So--ccnow defaults to$CLANG, the same variabletests/run_all.pyuses for{clang}. Without it, the test uses the checkout's owntools/llvmclang, then the clang on PATH. If there is none, it fails with a message saying so. The test's docstring now explains why. On Linux the test passed both with no--ccandCLANGunset, and with--ccgiven.L2, cost with the audio on: measured. I repeated the interleaved A/B with the audio on. I used the default profile, because the test profile sets
HOS_AUDIO=0, and every run's log hasaudio: output on the default device. Main468bb8d2egave 157.6 fps and this PR'sb49a6f952gave 159.8 fps (medians of 3). That is inside each side's own spread (156.8 to 162.0 against 157.5 to 163.9). Median frame time was 6.250 against 6.200 ms, and p99 was 7.850 ms on both. The held-frame path was active in every run. The table is under Measurements. It is the same scene as before: adult Zora's Domain, Uncapped. I did not measure a heavier scene. The added work is a fixed set of sound-module calls on held frames, so it doesn't grow with the scene's load.As for narrowing the work first: the "all modules skipped" variant in Testing is that narrowing, taken all the way to the sound system's update alone. By ear it still lost about half the sounds (16 of 20 on, 10 of 20 off), so the module that plays the event runs in those loops. Narrowing further, down to that one module, would mean first finding which of phase 0's modules handles xlink events. Given no measurable cost, I left that alone.
L3, Steam Deck and Linux: still open. The Test Farm request is posted above. It needs a BigBean's approval, and it stays under Still to test.
Checks on
b49a6f952, Linux (WSL),--strict:game/oot_high_fps.c).tests/test_sound_held_frames.pyfails on the test commit7416c9b07withFAIL: 144 fps: 1681 of 2880 one-frame sound events lost ..., and passes on the head with 89 checks.tests/test_high_fps_fixes.pyandtests/test_song_note_cue.pypass.cargo test -p sitespasses (53 tests).tests/run_all.pygives 828 passed and 89 failed on the head, against 827 and 89 on main. The failing files are the same, and the one extra pass is the new test.268319f29. The head differs from it only in the locked read above, so I did not repeat the count. The head did run in the game for the audio-on measurement.@review
Recommendation: Approve. The code is ready: only testing is left. The reported Lens sound loss is fixed in the Windows test, with no measurable cost in the reported audio-on comparison. Linux and Steam Deck gameplay results are still needed. Recommend approval; not approved on the forge.
Phase 0 now processes one-frame sound events on held frames while keeping music and note modules at 60 Hz. This fixes the reported lost sounds at the cost of extra sound-module work on held frames.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/oot_high_fps.h:195: The changed sound path has not yet been exercised on Linux or Steam Deck. When: At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct. Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.Since the last review (on
268319f292)Resolved: L1 (The return reads sound_gate.run after releasing sound_lock, while another phase can write…); L2 (The performance comparison disables audio output, so it does not measure the full player w…)
Withdrawn (it was wrong): L4 (The new test defaults to clang without honoring CC.)
Still open: L3 (The changed sound path has not yet been exercised on Linux or Steam Deck.)
Checks: Still running: 10 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes. At about 144 fps, the Windows test missed 7 on and 13 off sounds in 20 toggles on main, versus 0 of each on the tested PR build. Three audio-on performance runs per side showed overlapping spreads: median average fps was 157.6 on main and 159.8 on the PR, with p99 frame time 7.850 ms on both.
Other systems: The sound path runs on Windows and Linux, including Steam Deck, independently of GPU vendor. Windows gameplay covered the Lens, music and an ocarina song; Linux and Steam Deck gameplay remain untested. Other phase 0 modules now run on held frames and could behave differently if they count calls.
Switches: None added, changed or removed.
Reviewed:
b49a6f9525against468bb8d2ee: Read the repository rules, PR template, standards, full diff, commits, sound gate and helpers, new test and sitehooks helper. Skimmed the changed site tables and existing test changes. The full changed code files and all surrounding callers were not read in full; Tooling's adjacent AGENTS.md was unavailable.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during this review. The author reports Windows gameplay, Linux host checks and an audio-on comparison; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.