Sound delayed on cutscenes #1964
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#1964
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Longshot version
nightly 649
Channel
Nightly
What kind of problem
Sound
What happened
The sound on cutscenes, like the opening of a new game or the intro with link riding the horse, have the sound delayed.
Where in the game
game opening and intro
How often
Every time
Graphics card and driver version
rtx 3080, 621.24
CPU, RAM and operating system
ryzen 7 9800x3d, 32gb ram ddr5, windows 11
Changes from the defaults
No response
longshot_log.txt
a
Screenshots or video
No response
Before you send it
Possibly related, for context:
Claimed by d4nkn3ss (an AI agent, Claude Code, on an RTX 3080, Windows 11).
Likely cause, from the code (not measured yet): Windows' sound goes out through waveOut in 10 ms blocks, up to 10 of them queued (
NBLOCKSinhost/nn_audio.c). The mixer is paced by the wall clock, not by the device. After a stall (loading at the start, just before the opening movie), it catches up by mixing the missed frames at once. That fills the queue, and with the device and the mixer at the same rate from then on, it stays full. Everything heard is then about 100 ms behind what the game drew, plus waveOut's own latency, for the rest of the run. The movie player keeps its pictures in step with the game's sound clock, so in the cutscenes the sound comes late.Next: measure the queue's depth in the game (the opening movie, and later in play), then keep it short with a game-free test.
prior work: none found (waveOut, NBLOCKS, "audio latency", "sound delayed", "lip sync", WASAPI).
I measured it on an RTX 3080 (Windows 11 26300, main @
1dbf9150), from the start to the title with the opening movies. I'm dropping my claim: a shorter queue doesn't help enough to be worth its risk. Details:On main: a probe line in
output_frame(not committed) showed 8 of the 10 waveOut blocks queued from the first second on, at the title and through every opening movie. So everything Longshot plays is heard about 80 ms after the game mixed it, plus whatever Windows' audio engine adds after waveOut. The cause is as I described above: the mixer runs on the clock and fills the ring while the device starts. The output check's fixture reproduces it: 8 blocks queued after a device that starts 80 ms late.A cap on the queue: I tried dropping frames past N queued blocks instead of past the ring's 10, with a switch for N:
waveOut on this PC takes blocks from the queue in batches of about 40-50 ms, so under 60 ms the sound breaks up. 60 ms saves 20 ms against main's 80, and a slower output (Bluetooth, USB) would need more. That's too little against the risk of crackle, so I'm not opening a pull request for it.
What would actually lower it: output through WASAPI (SDL3's audio, which the Linux build already uses under its waveOut stand-in in
host/posix/win32_posix.c) instead of waveOut, with a short device buffer. That's a bigger change, and maintainers should decide on it.For the reporter, @swordman: is the sound late everywhere, or only in the cutscenes and movies? And is your output a Bluetooth headset or speaker? Those add 100-200 ms of their own, often more than all of the above. A wired output, or a Bluetooth device's low-latency mode, would show which it is.
Posted by an AI agent (Claude Code) for d4nkn3ss. Claim dropped; the measurement branch stays local.
I was only able to notice the audio being delayed on cutscenes. i'm playing with a bluetooth headset, but no game ever had this delayed sound.
Just tried out with a wired headset, while the sound is less delayed, it is still delayed. @d4nkn3ss
Thanks, @swordman. That rules out Bluetooth: what's left is the ~80 ms Longshot's waveOut output keeps queued, plus what Windows' audio engine adds after it.
Two more things would help narrow it:
Posted by an AI agent (Claude Code) for d4nkn3ss. Not claimed.
I was only able to notice it on cutscenes and opening movies, not gameplay. How late? bluettoth at leas one second, maybe 2 @d4nkn3ss
I noticed that the triforce port doesn't have the issue
Thanks, @swordman. That fits what I measured above: the delay is in Longshot's own sound output on Windows (the waveOut queue, about 80 ms ahead of the device from the start, plus what Windows adds), not in the game or your headset. Another port with its own audio output wouldn't have it.
So the fix is the output change described above (WASAPI through SDL3, with a short device buffer), which is the maintainers' call. Nothing more is needed from you for now. If you can still say whether gameplay sounds (sword, footsteps) feel late too, or only cutscenes, that would confirm it.
Posted by an AI agent (Claude Code) for d4nkn3ss. Not claimed.
I was able to check again with bluetooth devices and the delay wasn't as bad. I think the real issue is that both the opening and the title screen play at 240 fps when capped at 60 fps @d4nkn3ss
Ok, I limited my fps with nvidia app to 60 and the opening cutscenes didn't have a single bit of delay on its sounds. Issue here is that the game 60 fps limit doesn't work with the title screen and opening movie, so it desyncs the sound
Thanks, @swordman: that's a good lead, and it points at something deliberate. Since #73, Longshot runs at 240 fps while a movie plays, even at the default 60 cap, so the movie's pictures aren't skipped. The log line
vi: a movie is playing: the frame rate goes to 240 for it (HOS_MOVIE_PACE=0 leaves it)marks it. Your log shows the opening at a steady 240.Claimed again by d4nkn3ss (an AI agent, Claude Code, on an RTX 3080, Windows 11), for this lead: I'll measure how late the opening's sound is against its picture, with and without that 240 fps movie pacing.
Prior work: none found (
HOS_MOVIE_PACE, "movie pacing", "fps cap title", "opening movie fps";git log --grep movie).@swordman, your lead was right. On an RTX 3080 here, at the default cap, the opening plays at about 220 fps (the movie pacing), and the movie's picture runs ahead of its sound: 0.2 s after 6 seconds, 0.7-0.9 s by the end of the opening. The sound itself keeps time. With the movie pacing off (60 fps), picture and sound agree within 10 ms. That's why capping at 60 in the NVIDIA app fixed it for you.
The cause: at 240 fps the game asks for the next picture by its own count, and that count runs fast. Longshot already dropped pictures that fell behind the sound, but it handed out early ones.
#2264 holds back a picture that's ahead of the movie's clock and shows the last one again until it's due. With it, the picture stays within 20 ms of its clock through the opening and the title, and the sound lines up within 10 ms. It's open for review; once it's in a nightly, a check on your PC would settle it. Until then, capping at 60 in the NVIDIA app, as you found, works around it.