godotengine / godotengine/godot
AudioStreamPlayer clip falsely loops after animation end in web export
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in 4.3.stable, 4.3.dev7
### System information
Godot v4.4.dev7 - macOS Sequoia (15.1.1) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Apple M1 Pro - Apple M1 Pro (8 threads)
### Issue description
**Expected behavior (as in desktop exports):**
When triggering a looping audio clip to play through an AnimationPlayer, the clip always ends when either the clip ends after a trim in the animation timeline or when the animation finishes playing, regardless of the `loop` import property.
**Actual behavior:**
In web builds (with sample playback), when no "end" of the clip is reached (i.e. the end of the clip is after the animation end) the clip will keep looping indefinitely - the end of the animation does not end the clip (and its "end" outside of the animation doesn't either, even when the clip is trimmed). A particularly annoying edge-case occurs when the clip isn't trimmed and thus is allowed to keep looping until the animation stops - in web builds the clip will keep looping forever as no "playback end" is ever encountered. Once the animation has ended, playing the animation again will start a fresh instance of the clip, layering them on top.
### Steps to reproduce
1. Create a new AudioStreamPlayer
2. Import an audio file and set its `loop` import property to true
3. Create an AnimationPlayer, create an autoplaying animation, add an Audio Playback Track with the looping audio.
4. Make sure that the animation end is before the end of the audio clip.
5. Run the web export - the audio will keep looping.
Alternatively (with MRP):
1. Open the minimal reproduction project
2. Run the web export
3. Press the "Trigger animation" button to start playback
4. Note how in the editor the audio will stop after the animation end but the web version keeps playing (even though the clip is additionally trimmed)
### Minimal reproduction project (MRP)
[web-animation-audio-loop-bug.zip](https://github.com/user-attachments/files/18446101/web-animation-audio-loop-bug.zip)
Contributor guide
Research direction
Start by reproducing the issue with the minimal reproduction project, comparing the editor and web export while triggering the AnimationPlayer audio playback track. Trace how the web export handles a looping AudioStreamPlayer when the animation ends before the clip, and verify that playback stops at the animation end without layering on subsequent plays.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- audio-video-rtc, game-dev, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100