The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on t

Unity 2021.2.12f.
Basically I have 0 sounds on auto start. I only register callbacks on pointer enter / click with sounds.
Yet, none of my sounds get to work, except those that get loaded in next scene.
Obivously, in editor everything is perfect.

In build console I see about 20 those warnings, nothing red.

1 Like

I’m experiencing the same issue on Unity 2022.1.18f1

This is normal. Because of some limitations of WebGL, you can’t have audio auto start. You need the user to click something on the site so the audio context can initialize. The best thing is to have a loading screen with a “click to continue” button.

That’s not a WebGL limitation but a browser one.
The problem with WebGL is that you get that even if you are not playing sounds on Start and I thinks that’s a Unity issues that I hope they will fix.

It’s only a warning so it shouldn’t affect your application.

1 Like

doesn’t work, I’ve tried. I made a page with a button that when clicked adds an iframe to my game’s index.html(so the game only starts loading after you click the button) and the issue is still there.

Actually like that you won’t solve the problem!
Now it’s the iframe that fires the Warning. I think that as soon as you click on the iframe the warning stops appearing.

To do as suggested I would place all the unity instancing in the button click callback.
I try with an example (using jQuery):

$(document).ready(function(){   
    $("#loadButton").click(function() {
        var script = document.createElement("script");
        script.src = loaderUrl;
        script.onload = () => {
            createUnityInstance(canvas, config, (progress) => {
                progressBarFull.style.width = 100 * progress + "%";
            }).then((unityInstance) => {
                gameInstance = unityInstance;
            }).catch((message) => {
                alert(message);
            });
        };
        document.body.appendChild(script);
    });
});

Fixed the issue by reloading all assets(just reloading unity wont fix it, probably something to do with the cache of the files? idk)

Why doesn’t Unity handle this?
The dev console will spam this warning until you click the content so can’t Unity prevent it for us, even if is just a warning?

2 Likes