Sounds crash my web game on mobile browser (Godot 4.5 dev5 HTML export on itch)

Godot Version

4.5 dev5

Question

A game I’m working on kept crashing when I tested it on mobile browser (itch.io embed). The game would run fine for a minute or so, then would crash/reload. I tried things like using preload() instead of load(), and also tried using both .WAV and .OGG audio file formats. The audio files are all sized just around 10kb-250kb each even in .WAV format. The game runs fine if I disable audio. I haven’t been able to get it to work with audio. I’m using “Compatibility” mode in Godot.

To test the issue, I created a super simple demo with buttons that play sounds. (I used the same audio files that I’m using in my game.) The buttons get pressed automatically in order to keep playing sound while the game is running.

Play demo here: https://mellowminx.itch.io/audio-test-godot-4-5-dev-5-audio-test

Demo password: godot

Project files: GitHub - mellowminx/godot-4-5-dev-5-audio-test

Game crashes/reloads after 1-3 mins. Tested on iOS Chrome and Safari.

I also replicated this same demo game in Godot 3.5.3, which I’ve used before to publish a few small web games on itch.io, and they work fine on mobile browser with audio. I always use “OpenGL ES 2.0” in Godot 3.5.3. This demo web game embedded on itch.io seems to run fine with no issues:

Play demo here: GitHub - mellowminx/godot-3-5-3-audio-test

Demo password: godot

Project files: GitHub - mellowminx/godot-3-5-3-audio-test

Ran fine for 30+ mins. Tested on iOS Chrome.

Note: I’ve also tried exporting with Godot 4.4.1 and it seems to have the same issue with the web game’s audio on mobile browser.


For those of you who export HTML games using Godot 4+ to embed on itch.io and run on mobile browser, how are you making your audio work? Which version of Godot 4 are you using? Would love to know what else I can try to troubleshoot this issue! Or if it’s really a bug, where should I report it and what info should I include. Thank you.


EDIT: I’ve reported the bug by opening an issue in the Godot github: Godot 4.5 dev5 HTML export web game crashes/reloads in iOS Chrome and Safari after a few minutes if audio is used #107390

Have you tried mp3s?

I haven’t tried .MP3 file format. Is that recommended for web exports?

I believe I read somewhere that it was, especially for mobile. Unfortunately I can’t remember where or I’d pull up a reference, but I think it was somewhere in the official documentation.

I think it’s because the problem with WAV files is they’re too big to send over the internet and cause lag issues, and phones are not good at decompressing Ogg files. But I could be making that up.

It’s worth a try, thanks!

(Just a note for extra info on this thread-- I used WAV files for my previous web games exported from Godot 3.5.3 and they were fine on mobile browser)

There’s no reason to use anything other than MP3 for mobile and web now that licensiong fees for the mp3 patents (which expired) are not needed anymore. .ogg is another format to use which is equally as good as mp3.

WAV is a no no for mobile and web as it is an uncompresssed audio format which will cause you problems if you’re not streaming the data.

I see thanks! The uploaded demo and project files linked use OGG format but I’ll also try MP3.

Hey y’all! I just discovered the same issue when I loaded up my game in a phone browser for the first time since adding audio. The problem seems to only exist on iPhones (worked perfectly fine on Android with Chrome and Firefox), but it’s true on iOS Safari and Firefox. Thank you for the note on the MP3 files, I replaced the WAVs in my game with them; however, the problem still exists in the same places it did before.

2 Likes

Thanks for sharing that you experienced the same issue! I shared your comment on the Godot github issue I opened for this.

1 Like