HTML5 - FMOD game loop using setInterval is stuttering during UI updates

Hi there,

I’m building a virtual mixing desk for the web browser using the FMOD HTML5 API, but I’m having some issues with audio stuttering.

It seems that calling gSystem.update() in a JS setInterval is causing thread queueing issues as the UI gets more complex. As I’m adding things like level meters, pan pots and faders, my setInterval is being queued behind UI updates, which is causing FMOD to stutter because it interrupts the game loop.

I’m aware that JS in the browser is single threaded, and there may be no answer to this other than “make the UI simpler”, but I wanted to double check that there wasn’t a way to run the FMOD game loop on a different thread from the UI. Will FMOD run in a web worker? Is there something I can do around audio worklets? I only need to target the latest browsers so compatibility isn’t an issue.

Thanks in advance for any advice.

Hi,

FMOD on HTML5 has the FMOD_OUTPUTTYPE_AUDIOWORKLET output mode that offloads FMOD’s processes to an AudioWorkletNode - FMOD will default to this if your browser supports the functionality. We recommend using this output mode alongside setting a fast code path using SharedArrayBuffer for best performance. Please see our Core API HTML5 docs for more info.

If you’re still running into issues even after ensuring that you’re doing both of these things, there’s a couple things you can do on FMOD’s side of things, such as reducing the amount of simultaneously playing streams, increasing the buffer size, reducing the number of playing instances, and driving the virtual voice system harder by capping the maximum amount of software channels with System::setSoftwareChannels before initializing the system.

Hope that helps!