Unfortunately having integrated FMOD into a WebGL project for the last few months, we’re facing the hard decision to shift back to unity built in audio.
The primary driver for this is stuttering audio experienced in WebGL browser. Similar to some other users we have issues with scene loading boundaries, as well as occasional “during play” stutters. The during play stutters due to dropped frames are difficult to eliminate (an example of this is a large addressable which gets downloaded in the background and loaded into memory, spending ~60ms on lower end devices).
Some techniques help (e.g. ducking audio between loading) with a small impact on user experience, but during play, even the odd stutter or two is enough to negatively impact the sense of interaction in a way that is less noticeable with a visual frame drop. And eliminating all the individual causes of stutters is not a guarantee as we are also constrained by some of unity’s systems.
Is there anything on the FMOD configuration level that I can leverage to try to compensate? I tried playing with DSP buffer size, but still experience stutter, am I right in thinking the max acceptable latency at 2048 is effectively 40ms of a blocked frame?
Unfortunately I feel like moving away from FMOD to built in is the most likely scenario for us right now I appreciate that FMOD is severely limited by browser capability.
There are a few things you could try, but at the end of the day WebGL is a single-threaded environment with no access to the GPU and, as you mentioned, varying performance between browsers. Some things to try:
Never have more than one streaming asset playing at a time.
Preload banks/events before gameplay, and unload anything you don’t need.
Where possible, reduce the Max Instances count and use a relevant Voice Stealing option to compensate for dropouts.
Avoid convolution reverb.
Increase the DSP Buffer Length in the FMOD Unity settings for WebGL
40ms is the default for most platforms, with a DSP Buffer Length of 512 and DSP Buffer Count of 4. A DSP Buffer Length of 2048 and DSP Buffer Count of 4 would give you a 170ms of latency. Whether or not that is an acceptable amount of latency for your case is something to be determined with user testing.
Hi, I would love to know how this worked out. We are debating using FMOD for a WebGL Unity project. Would love to talk to anyone at FMOD or author of this post for any insight. thank you Mike
Hey, we have been using FMOD with WebGL for almost a year now and we have been having a lot of problems with it, so I would really not recommend it.
Otherwise FMOD is amazing, but not for WebGL
As long as you are using Safari 15.2 or later all of the HTML5 optimizations should be available.
To use the SharedArrayBuffer optimization you will need to configure your server to use the “Cross-Origin-Opener-Policy: same-origin” and “Cross-Origin-Embedder-Policy: require-corp” policies, which should give you the best possible performance on HTML5.
General information about how to set these policies can be found here: Cross Origin Isolation
The specifics of how to set them will depend on how you are hosting your game.
Are you asynchronously loading your banks? It sounds like maybe you’re loading everything in all at once, right at the start, which could be a big bottleneck. (You mentioned you’re using asset bundles, which unfortunately I don’t have much experience with.)
One thing I found is that I had to manually override the WebGL output mode to Javascript web audio output; auto didn’t work the same way / resulted in stuttering.
Here are the WebGL-specific settings for my last project:
May i ask that how Fmod will know which platform i am in. Is it auto dected or not?
For example, if i add webgl, android and ios.
How does it ensure that WebGL is used when i am playing game on HTML5 platfrom?
THank you so much!
By the way, here.s another bug i faced:
[FMOD] AAudio_GetDriverInfoInternal : Could not get driver info for device with id: 1701669204.
It is happend when fmod initialized…