Audio Sync not working on web exports

Godot Version

4.6.3.stable

Question

Hi all! How are you?

I’ ve made a little musical toy of an ancient Greek lyre with a minigame, a lyre hero of sorts if you will :sweat_smile:

On desktop and android the music sync is working fine, but on the web, the notes are off by 4 beats (there are 8 beats in a bar in this case).

The code is open in codeberg and the game can be played at itch, for those of you that have time and patience to give a deeper look. The music syncing logic is under the addons/orfeas addon, and its based on this youtube video. The class with the logic spawning the notes is note_lane_3d.gd.

I don’t know if this is a known issue, I made a rhythm game that worked fine in the web a while ago (I think it was Godot 4.3), so I’m a bit puzzled with this!

Thanks a lot for your time!

For those reaching this post in the future, the culprit was the AudioStreamPlayer.get_playback_position, that was lagging behind in web exports. I couldn’t figure out why, so what I did was create a simple Stopwatch and manually calculate the time elapsed since the stream started and make the calculations based on that. It works way better, still some lag in web mobile devices because of shaders loading and such, but now it’s playable.