# WebGL bouncing ball Stutter

**URL:** <https://qa.fmod.com/t/webgl-bouncing-ball-stutter/22482>\
**Category:** Unity\
**Created:** [January 6, 2025, 6:04am UTC](https://qa.fmod.com/t/webgl-bouncing-ball-stutter/22482 "2025-01-06T06:04:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniellumertz](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@daniellumertz](https://qa.fmod.com/u/daniellumertz)\
**Post date:** [January 6, 2025, 6:04am UTC](https://qa.fmod.com/t/webgl-bouncing-ball-stutter/22482/1 "2025-01-06T06:04:43Z")

</div>

Hello everyone, in my game, I’m encountering an issue with Unity and FMOD in WebGL builds. The problem is similar to what occurs in the bouncing ball FMOD demo: [FMOD HTML5 Demo](https://fmod.com/assets/html5/js_unity/demo.html).

When I load the banks, start the scene, and then switch tabs, the game audio begins to stutter. I hypothesize this only happens to streamed audios, I wonder what is the common practice in these scenarios, if continue playing the music or pause/resume all events, also would appreciate any advice on which API functions to study for that matter.

Thank you in advance for any advice!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [January 8, 2025, 3:55am UTC](https://qa.fmod.com/t/webgl-bouncing-ball-stutter/22482/2 "2025-01-08T03:55:24Z")

</div>

Hi,

An option when the game enters the background is to suspend the mixer: [FMOD Engine | Core API Reference - System::mixerSuspend](https://fmod.com/docs/2.02/api/core-api-system.html#system_mixersuspend). This will maintain all internal states while reducing CPU usage to 0%. Mainly useful on mobile platforms. When the game resumes focus resume the mixer: [FMOD Engine | Core API Reference - System::mixerResume](https://fmod.com/docs/2.02/api/core-api-system.html#system_mixerresume).

However, we have to call JavaScript functions from Unity C# scripts:

1. First set up a Java Plugin: [Unit Docs | Set up your JavaScript plug-in](https://docs.unity3d.com/2022.3/Documentation/Manual/web-interacting-browser-js.html)
2. As we use the `MyGameInstance` object in the `.jslib` file we need to initialize it in our `index.html` file: [Unity Docs | Call JavaScript functions from Unity C# scripts - Call JavaScript functions from global scope](https://docs.unity3d.com/2022.3/Documentation/Manual/web-interacting-browser-js-to-unity.html#:~:text=Call%20JavaScript%20functions%20from%20global%20scope).

Here is how I am pausing/resuming the mixer in my script:

```auto
public class TriggerPause : MonoBehaviour
{
	[DllImport("__Internal")]
	private static extern void AddListener();

	private bool paused = false;
	void Start()
	{
		AddListener();
	}

	void suspend()
	{
		if (paused)
		{
			FMODUnity.RuntimeManager.CoreSystem.mixerResume();
			paused = false;
		}
		else
		{
			FMODUnity.RuntimeManager.CoreSystem.mixerSuspend();
			paused = true;
		}
	}
}

```

Hope this helps!
