Unity FMOD in WebGL, when losing focus, the sound becomes very strange

Unity FMOD in WebGL, when losing focus, the sound becomes very strange, But using Unity AudioSource does not have this issue.

I know that I can call FMODUnity.RuntimeManager.CoreSystem.mixerSuspend() in the OnApplicationFocus method of MonoBehaviour to stop these strange sounds. However, in some embedded WebGL environments within apps, it does not always work. For example, in TikTok. Sometimes, after switching back to the app from the background, the sound becomes weird again. The issue is that this problem does not occur with Unity’s default AudioSource, so it seems not to be related to the hardware, WebGL, or the Unity engine. It’s more like an issue with how FMOD itself handles sounds in WebGL.

My FMod is 2.02.22, Unity version is 2022.3.21f1. Is there any solution?

The ‘strange sound’ when the app is in the background is caused by the StudioSystem::update() not being called enough, this is because when the app is in the background Unity limits the app to 1fps and this is what drives Monobehavior::update() which is used to call StudioSystem::update().

If the game is still running in the bacground and you call mixerSuspend(), the game can still make calls to FMOD but they will not be processed until mixerResume() is called, which will result in it processing all the queued commands at once which could also cause ‘strange sounds’.

1 Like