Looped audio in webview - keeps playing after restart

I am trying to fix a bug in an old project.

A game written in Phaser 3.24.1 that is played in a webview from a mobile app (you play the game inside Viber’s in-app browser).

The unexpected behavior is:

  1. Player opens the game for the first time
  2. The menu has no sound by design
  3. Player starts a game and the code starts the theme with this.sound.add("theme", { loop: true }).setVolume(this.defaultMusicVolume)
  4. If the player decides to close the webview, while the music is playing, the next time a webview is opened, EVEN IF IT IS NOT THE GAME BUT A RANDOM WEBSITE, the music turns back on and loops forever with no obvious way to stop it.

What I have tried:

  1. If I use the sound manager to stop all sounds - it does not help. This “old” tune from the last playable instance is not in the context of the newly played game
  2. If I set loop: false and manually run the music with the “complete” event listener, than the music will eventually stop. But as it’s a game theme of over 1 minute length, that’s not a desired solution.

A wild guess at what should I do:
I believe the looped music becomes an orphan. The game instance that created it, is no longer accessible as it is from a tab that was closed. So I am looking for a way to tell the webview browser “stop all looping sounds please”.

Any hints are more than welcome. This one is killing me :slight_smile:

Seems like a browser bug. You could try destroying the game in