utopia-rise / fmod-gdextension

FMOD Studio GDExtension bindings for the Godot game engine
MIT License
435 stars 49 forks source link

FmodListener3D.queue_free() does break 3D audio #252

Open Cyberrebell opened 1 day ago

Cyberrebell commented 1 day ago

If I delete an old FmodListener3D using .queue_free() instead of .free() and create a new one before the old one is actually freed in background it breaks 3D sound or the new one just doesn't work.

Here is a minimal reproduction project (fmod addon needs to be added manually as it exceeds github file upload limitations): fmod-queue_free-test.zip

By switching from queue_free() to free() in camera_3d.gd it works. So there is a workaround but the reason for it may be very hard to find in a complex project.

CedNaru commented 1 day ago

It's probably because Listeners only know about their own index. So when you create a new one, when the old one is still queued for deletion. The new one takes over the old one's index, but the old will still unregister this index when leaving the sceneTree. I should probably add some "ownership" to Listener so only one can control a given index at a time.