WebGL AudioContext warning with only FMOD Studio Listener in the scene

Hi,

I would like to report an issue that I am experiencing with FMOD.

I am using Unity 2020.3.24.

STR:

  • Create an empty Unity project
  • Go to Edit/ProjectSettings/Audio and disable set ‘Disable Unity Audio’ to true
  • Create a WebGL build
  • Once the build is done and your browser load the application on a web page, open the Console
  • You will see that there is no “The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.” warning
  • Go back to Unity and add an FMOD Studio Listener to your scene
  • Save the scene
  • Create another WebGL build
  • Once the build is done and your browser load the application on a web page, open the Console
  • You will see that “The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.” warning shows up!

I would like to know why having an FMOD Studio Listener in a scene causes this issue and if you have any suggestions to address this.

The solution that I have for this right now, is to add the FMOD Studio Listener to my scene, only after “user gesture on the page”. But this feels wrong.

Thanks in advance!

This is expected behaviour. Adding a listener counts to the browser as it trying to play audio so it will throw this error when the Unity scene loads up and tries to add a listener to the system. You can read more about user gestures in our documentation:

https://fmod.com/resources/documentation-api?version=2.02&page=platforms-html5.html#user-interaction-requirement

Okay, that is clear.

This issue also occurs when you try to load banks before a user gesture, right?

What is the most optimal wait to load banks and wait for them?

Also, there is a WaitForAllSampleLoading method in the RuntimeManager. How exactly can I know when it has finished waiting? My expectation from a method that starts with “Wait” is that it would return WaitUntil or would allow passing a callback.

Thanks :pray:

There is no callback for WaitForAllSampleLoading but it will stop all FMOD calls until it has finished loading since it blocks the thread it’s on. Also, please note that WaitForAllSampleLoading does not work on HTML5 builds.