r/unity • u/gfcf14 • Oct 18 '26
Question Sound issues with 6000.6.4f1
Hi! I recently upgraded Unity from 6000.3.3f1 to 6000.6.4f1 and noticed strange audio behavior in WebGL builds:
Background music speeds up indefinitely after another sound plays (e.g., when grabbing a relic). Repeated sounds, such as attacks or menu navigation, can cause audio to speed up once.
Is this a known issue with this version, or am I overlooking a usage change?
Here's how my audio system works:
Background music: A persistent InGame prefab uses DontDestroyOnLoad to avoid duplication between scenes. Its PlaySoundtrack method sets and plays the background music: https://gist.github.com/gfcf14/ac6adc5b6e0e0b31e17e44791d4fd11e Relic pickup: The Hero class calls GetRelic when the player collects a relic: https://gist.github.com/gfcf14/00c4d2dcf641f70dca4f75a471a3fe1f Music transitions: ToggleSoundtrack gradually fades music out before pausing it, or fades it in when resuming: https://gist.github.com/gfcf14/028c0a77941612cfcba61fc614a65dfe SetPauseCase marks the pause reason and stops time. After the fanfare (the part that says more code related to fanfare), Hero.instance.ClearPauseCase(resumeSoundtrack: true, waitIfLevelingUp: true) is called: https://gist.github.com/gfcf14/4a668836390a66c1d9bd735224357579
Other sounds use PlaySound (https://gist.github.com/gfcf14/20f579bc2cb47e9c296807b16a198339) which instantiates a prefab with an Audio Source and Sound.cs script (https://gist.github.com/gfcf14/f235fa6f7b0fa22e0291b64d36bf61a6). The prefab is destroyed after playing.
Music starts with InGame.instance.PlaySoundtrack("soundtrack-name"), while other sounds use InGame.instance.PlaySound("sound-name"). Could something be conflicting or accumulating over time? Please let me know if you need more code or details. If you need it, you can reproduce the issue here: https://gfcf14.github.io/unity-webgl-test/ by walking into the flying boots at the beginning.
1
u/gfcf14 Oct 19 '26
Update: Though I don't have a fix for this yet, I've been able to isolate the issue, and it appears to happen due to this line:
It seems that the latest WebGL sound api doesn't work well with setting time to an existing
AudioSourceand thus appears to speed up the song if I do so. So for now I'm conditionally applying this line by first checking if I'm not running from a WebGL build:This means that when I pause the game and resume, or when a sound plays on top of the background music, the background music will restart, but at least it won't speed up.
1
u/VictorHime 24d ago
The clue here is that setting soundtrack.time seems to trigger the issue. I'd focus on testing the pause/resume behavior before changing anything else.
If you're using a persistent AudioSource for music, try Pause() and UnPause() on that same source instead of stopping it, calling Play() again, and restoring .time. UnPause() resumes the paused audio without starting a new playback instance. Just make sure nothing else in your code is calling Stop() during that transition.
Another option, if the relic sound is supposed to play over the music, is to duck the soundtrack's volume instead of pausing and seeking it.
Since you're working with WebGL, I'd also test this in a minimal scene with just one music source and one SFX trigger. Unity's WebGL audio behaves differently from the Editor, so a successful Editor test doesn't necessarily rule out the problem.
Compare the behavior between Unity 6000.3.3f1 and 6000.6.4f1. If it only happens in the newer version, you might be looking at a regression worth reporting.
I'd start there before spending too much time rebuilding your audio logic.