Skip to content

iOS audio locks when audio context is interrupted #5390

@SBCGames

Description

@SBCGames

Version

  • Phaser Version: tested on 3.50 - beta X and some of the previous versions
  • Operating system: iOS
  • Browser: Safari

Description

iOS often puts audio context state into state "interrupted". It can happen with incoming call and (at least on iPad / iOS 14) it also happens when app is minimized with home button. What also happens is, that audio, previously unlocked in the beginning of game, is locked again and needs to be unlocked. Otherwise game looses all sounds.

There is similar (maybe the same) issue (#5156) - at least looking at description. But as I am not sure, I started this new one.

In onFocus (https://github.com/photonstorm/phaser/blob/master/src/sound/webaudio/WebAudioSoundManager.js#L335) code is testing if audio was unlocked. When I changed it to this, I got rid of the problem:

    onFocus: function ()
    {
        /*
        if (!this.locked)
        {
            this.context.resume();
        }
        */
        
        this.locked = true;
        this.unlock();
    },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions