Always call start() on audio stream before mixing #46202
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #28110
This is the AudioStreamPlayer counterpart of #46151. This bug seems to only crop up when people pause in a scene's
_ready()
or immediately after playing an AudioStreamPlayer.The problematic codepath seems to be:
play()
being called and setting active = true (can be done in script or through autoplay+entering the tree)set_stream_paused(true)
to be called_mix_audio()
being called which triggers the fadeout code, leading to amix()
call on anAudioStreamPlaybackResampled
(like for an ogg or mp3), which doesn't have a check thatstart()
has first been called.This triggers unintialized memory being copied into the audio buffer. If any of the values in that block of memory are NaN, they get propagated through into whatever audio effect chain the project has. At least for a reverb effect, that NaNs out the entire audio stream coming out of that bus.
This PR also adds a false-initialization to use_fadeout since before it would just be uninitialized garbage.
HUGE thank you to @jjmontesl for the help testing this one, and on your insights in the comments on the bug!
Testing can be done with this project which is specifically configured to repro the bug.
mix_before_start.zip
As always with these audio bugs, please watch your volume while reproducing the bug, especially if you wear headphones or have good speakers.