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.
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.
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.)
Here are the WebGL-specific settings for my last project: