Unity WebGL minimization causes sound to disappear

I am currently encountering a similar issue as in this post,
but my platform is Unity WebGL.
https://qa.fmod.com/t/fmod-unity-ios-no-sound-after-app-resume-or-ad-even-after-upgrading-to-2-02-28/22836
My WebGL is embedded in an iOS app.
The problem is that after minimizing the app window and returning,
the sound disappears. However, there are two situations where the sound recovers:

  1. I trigger the iOS side to play an ad via JSLib, and the sound recovers after returning.

  2. Repeatedly minimizing and returning has a low probability of recovering the sound effects.

I trigger the focus using a JSLib web method,
because Unity’s OnApplicationFocus often doesn’t work.
I have configured the buffer size with System::setDSPBufferSize(1024, 4),
and also tried 4096, but it still doesn’t solve this problem.
Is there any progress on this issue? Thank you :slight_smile:

unity C#

public void OnFocusGained()
{
     Debug.Log("Focus Gained");
     FMODUnity.RuntimeManager.CoreSystem.mixerResume();
     FMODUnity.RuntimeManager.CoreSystem.update();
}

public void OnFocusLost()
{
     Debug.Log("Focus Lost");
     FMODUnity.RuntimeManager.CoreSystem.mixerSuspend();
     FMODUnity.RuntimeManager.CoreSystem.update();
}

Focus.jslib

mergeInto(LibraryManager.library, {
    InitFocusListener_j: function() {
        try {
            document.addEventListener('visibilitychange', function() {
                if (!document.hidden) {
                    SendMessage('unitygameobject', 'OnFocusGained');
                } else {
                    SendMessage('unitygameobject', 'OnFocusLost');
                }
            });
            console.log("Visibility listener initialized");
        } catch (error) {
            console.error("Failed to initialize visibility listener: " + error);
        }
    }
});

The method to trigger ads is that I use JSLib to call the iOS native side.
The iOS side then calls the ad through the AdMob plugin,
which overlays a window on top of my WebGL.
The overlay window closes only after the ad ends.

Unity2021.3.8f1
Fmod 2.03.09
Iphone SE2
IOS 26
WebKit
OpenGL ES 3.0(WebGL 2.0)

Hi,

Thank you for sharing the detailed information and repro steps.

We are still investigating this issue and unfortunately don’t have significant progress to report yet. From our side we have mainly observed that the behavior seems to differ between browsers and WebView implementations, which makes it less consistent on iOS compared to other platforms.

In the meantime, could you please share how you configure and manage AVAudioSession on the iOS side? Also, if you haven’t already, please review Handling Interruptions in our docs.

Those details might help us determine whether session category or lifecycle is contributing to audio loss on resume.

Thanks again for your patience while we continue looking into this.