iOS audio context suspended on visibility change

Hi

Here is an example that demonstrates the issue.

https://playcanv.as/p/OerFeKXH/
https://playcanvas.com/editor/scene/1168873

  1. load this PC app in iOS Safari. Tap button few times to hear button clicks.
  2. switch to a new tab eg google
  3. switch back to PC app.
  4. Tap button again. Now there is no sound.

Mac chrome, Mac Safari, and Android Chrome, do not have this problem

It seems that the audio context is suspended when it should be active.

The following does seem to work around the issue.

    this.app.systems.sound.manager.on('resume', function() {
        if (this.app.systems.sound.manager.context.state !== "running") {
            this.app.systems.sound.manager.context.resume();
        }        
    }, this);

created an engine issue https://github.com/playcanvas/engine/issues/3212

1 Like