-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
instances leaked at exit with AudioStreamPlayer #76745
Comments
Related to #34495 |
I had a look into this issue and it looks like it is also caused by #51296. I noticed that when calling Interestingly, godot/scene/audio/audio_stream_player.cpp Lines 71 to 75 in c12d635
This is basically the same godot/scene/audio/audio_stream_player.cpp Lines 164 to 168 in c12d635
So why does it not work as expected? The issue is that #51296 has introduce a Line 255 in c12d635
Internally godot/servers/audio_server.cpp Lines 1169 to 1186 in c12d635
This means that the audio server holds on to these references for "a bit longer" to possibly do a fade out, and only free them later. During a process shutdown this doesn't make sense, and these references from the audio server are then reported as leaks. So it should be possible to fix this issue by adding some corresponding shutdown cleanup logic on the audio server side. However the more I understand the code, the more I feel that #51296 has made things in the audio server more complicated than necessary. |
I can confirm this is still present on 4.2.2 on a windows build game. A quick fix for this is to stop all audiostreams and await 0.1s before exiting. func _notification(what):
if what == NOTIFICATION_WM_CLOSE_REQUEST:
get_tree().set_auto_accept_quit(false) # or change project settings config
print("Exiting")
%LevelAudio.stop()
await get_tree().create_timer(0.1).timeout
get_tree().quit() # default behavior |
Godot version
Godot_v4.0.2-stable_linux.x86_64
System information
Ubuntu 21.10
Issue description
At exit, if a sound is still playing errors are displayed about leaked resources.
It doesn't always happen, it's maybe around 50% of the time.
It happens only when launched outside of the editor using command line.
Steps to reproduce
Minimal reproduction project
leaking_resources.zip
The text was updated successfully, but these errors were encountered: