phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.02k stars 7.09k forks source link

HTML-AUDIO iOS sound delayed #5556

Closed jamessimo closed 7 months ago

jamessimo commented 3 years ago

Version

Description

When using any sounds in HTML5 audio there are a few hundred milliseconds delay. Saw on the phaser discourse that one person said they mitigated this using .m4a files with the same bit rate. This didn’t work for me however I did have some sounds I was unable to make m4a.

Example Test Code

var config = {
  ...
    audio: {
        disableWebAudio: true
    }

    this.load.audio('sfx', [
        'assets/audio/SoundEffects/magical_horror_audiosprite.ogg',
        'assets/audio/SoundEffects/magical_horror_audiosprite.mp3'
    ]);

     fx = this.sound.add('sfx');

...

How to reproduce

Please see the example at https://phaser.io/examples/v3/view/audio/html5-audio/markers-pause-resume#

On your PC you can click any of the play sound buttons as fast as you can and you will always hear something

on iOS there is a few hundred-millisecond delay, if you tap fast on the buttons you will not hear the sound as the delay keeps getting restarted.

This issue happens regardless if you use a sound marker or not.

Tested using .m4a and .a3c both have the same issue.

samme commented 3 years ago

I think HTML5 audio is high-latency by nature, especially on iOS.

photonstorm commented 7 months ago

We've taken the decision to recode the Phaser Audio system from scratch and replace the existing one. This will remove the division between Web Audio and HTML Audio (you'll be able to have both together), along with lots of other required features and API updates. Development work will start in Q2 2024. As a result, we are going to mothball all audio-related issues rather than try to monkey-patch solutions in.