fix(fps): the sound clock keeps its remainder around 60 fps, and cap 60 runs every phase #2552
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2552
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/high-fps-sound-remainder"
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?
#2470's sound gate has two flaws. Around 60 fps with a cap above 60, the sound runs slower than real time. At a cap of 60, a sound job phase can be skipped once.
What changed
The remainder is kept across whole steps. Before, a step of 1 or more ran the sound job and threw away the partial steps added up before it. With a cap above 60 and the game near 60 fps (or VRR, or frame-time jitter), the step hovers around 1, and the frames under 1 were simply lost. In a simulation, the sound engine's clock against real time was:
A step of 1 or more now runs with the game's own step and keeps the remainder, which comes back later as one more whole step. The remainder is cleared only at a cap of 60 and for a step of 0 or less (or NaN).
A cap of 60 runs every phase. The gate started with "do not run", and it answered phases 1 and 2 from phase 0's last choice before looking at the cap. So at a cap of 60, a phase 1 or 2 before the first phase 0, or right after the cap changed, was skipped once. A cap of 60 now runs every phase whatever came before, and the gate starts with "run". At a cap of 60 the sound job is now exactly the game's own again.
Also:
HOS_FPS_LOG's sound counters are kept under the gate's lock, and its switch is read atomically.The original sound fix is a port of zortos293/Lichii PR #1289 by auz466.
Tests
tests/test_high_fps_fixes.pyadds checks that:The same checks run against #2470's gate fail 9 cases, including the first three clock cases. The new test passes.
Not tested
tests/run_all.pywas not run; onlytests/test_high_fps_fixes.py.github-sync referenced this pull request2026-11-12 06:22:54 +00:00