It only happens in actual WebGL content, never in the editor. Furthermore, there is nothing that hints on it being consistently reproducible.
In our last project (multiplayer) the only thing I could think of is a moment where an object (triggering a 3d sfx) has been placed outside of float range. Its a (very) long shot - but one nonetheless.
EDIT: I might be able to give this another shot in our next project later today…
I am having this error in firefox unity 2019.4f when trying to use a keydown to set a javascript variable value to -30 but it does not fail on -10? I am not working with any sound files.
I found similar bug with AudioSource.Pause() in Unity 2019.4.37f (WebGL).
If I call Play() or UnPause() after Pause(), then the game crashes with error:
Uncaught TypeError: Failed to execute ‘start’ on ‘AudioBufferSourceNode’: The provided double value is non-finite.
Thank you so much! I was having the same problem but different scenario. I’m switching audio clips to a single audiosource, and adding audiosource.time = 0 just before playing the new audioclip, solved the issue in WebGL.
Update:
Setting time to zero didn’t work. I found out the cause, and this has to be an Unity bug… I think.
When you build webgl, either in development build or not, (it is easier in development build), go to Build\webgl-output.framework.js.gz, decompress it and modify build.framework.js.
Add the following line (see comment). Save the Js, and compress it again. I don’t know what does startOffset do but, at least, it plays audios just fine.
This bug has been haunting my product since the summer. Currently on 2021.3.9, but switching to 2021.3.15 didn’t eliminate it. Any chance of a fix from Unity soon? Messing with timings and audio source management can fix some cases, but it always seems to pop up somewhere else.
A little late to the game but I had the same problem. After initiating an audiosource and started .Play(). After the parent of the audiosource is destroyed and then a new instance of ausiosource is instantiated I get glitchy sound and some times one or more audiosources fail with this error and don’t play.
I implemented OnDestroy(){} on the parent object of the audiosource and made sure to calle audioSource.Stop(); when destroying the parent. Then the new audiosources spun up after works fine.
if(isNaN(startTime)){startTime = 0;}
if(isNaN(startOffset)){startOffset = 0;}
Note: you need to do for the unity version you are working on.
Hope it helped.
@akig2016 You are a true hero. Thank you! Your input has saved me from a weeks worth of torment. Your solution resolved this issue for me in 2021.3.5f1