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

**URL:** <https://qa.fmod.com/t/html5-fmod-game-loop-using-setinterval-is-stuttering-during-ui-updates/19639>\
**Category:** FMOD Engine\
**Tags:** html5\
**Created:** [December 13, 2022, 9:42am UTC](https://qa.fmod.com/t/html5-fmod-game-loop-using-setinterval-is-stuttering-during-ui-updates/19639 "2022-12-13T09:42:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joerocketmakers](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joerocketmakers/32/4366_2.png) [@joerocketmakers](https://qa.fmod.com/u/joerocketmakers)\
**Post date:** [December 13, 2022, 9:42am UTC](https://qa.fmod.com/t/html5-fmod-game-loop-using-setinterval-is-stuttering-during-ui-updates/19639/1 "2022-12-13T09:42:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [December 16, 2022, 5:32am UTC](https://qa.fmod.com/t/html5-fmod-game-loop-using-setinterval-is-stuttering-during-ui-updates/19639/2 "2022-12-16T05:32:35Z")

</div>

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](https://fmod.com/docs/2.02/api/platforms-html5.html#browser-compatibility) 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`](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_setsoftwarechannels) before initializing the system.

Hope that helps!
