Sounds play twice on iOS

I am using the latest versions of OpenFL (8.9.5), Lime (7.6.3) and HaxeFlixel (4.6.3).

On iOS I noticed that sound effects play twice, with a fraction of second between them. This happens on both simulator and device. Strangely, when playing music, I can sometimes hear the first beat of the song playing twice, but after that it seems to play normally.

Any idea of what could be causing this? Thanks.

There’s a memory improvement for Howler.js in the dev version of Lime here:

…but I don’t think that would effect a double-playing of sounds

Oh on iOS, hmm. Is this a regression? When did this start occurring?

Sorry, I’m not sure what you mean by regression. It was working before with OpenFL 8.4.1, Lime 7.0.0 and HaxeFlixel 4.5.1. Haxe was also upgraded from 3.x to 4.

Also, what’s strange is that the problem doesn’t seem very consistent. Some sounds seem to play twice only sometimes, while with others I can’t really tell if it’s playing twice or not. I have another, simpler app that doesn’t seem to have the issue.

I checked if it could be due to a difference in audio format, but all of the files are ogg, 44100Hz, 32-bit.

Can you attach one of the buggy sound files?
Also can you show code example, how you play them?

Sure. This sound always plays double, I tested in both wav and ogg:

land.wav
land.ogg

I play it by simply calling FlxG.sound.play("assets/sounds/land.ogg") or FlxG.sound.play("assets/sounds/land.wav"). I did a simple test within the game to just play the sound when I tap, so I’m sure I wasn’t playing it twice in different parts of code.

I just wanted to add that I tried a basic project that just plays the sound, and also tried with the dev version of lime, and the problem persists.

Maybe you should try playing sounds thru OpenFL (not thru HaxeFlixel) to see if it’s the problem of the framework.
If not, try testing with older versions of OpenFL (<= 8.9.1).

I can reproduce the issue. On Android (may be other platforms).
If I preload sound with Starling AssetManager, when fps is lower than maximum, sound can be played twice. Works fine if sound is preloaded with OpenFL Assets class.
HTML5, Android, Chrome.
OpenFL 8.9.5, Lime 7.6.3

I have made some more tests, and can confirm that it does not seem related to flixel, since I played the sound by calling openfl.utils.Assets.getSound("assets/sounds/land.ogg").play();

Also, the problem does not occur with lime 7.0.0 and openfl 8.4.1, but it does occur with lime 7.1.0 and openfl 8.5.0.

The problem has not happened to me on Android, that I have noticed.