-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Calling play() on AudioStreamPlayer2D causes crash without error log when World2D is shared with SubViewport and scene is reloaded. #89212
Comments
There's been a huge rework by @KoBeWi in current dev builds (4.3) where all AudioStreamPlayers share the same underlying code, which was previously not the case. As a result, there's a possibility the bug may have been accidentally addressed. Could you try to reproduce this issue in the latest dev build? |
Still crashes on master:
|
Having this issue as well in my project running on Godot 4.2.0, which was narrowed down to my minimap system (which uses a sub-viewport) after some analysis. As my UI is a separate scene from the main game scene, I attempted a workaround of only creating the sub viewport when the level is entered and freeing it when the level is exited, but even though the previous sub-viewports should be removed from the game and unable to cause any errors, I still experienced crashes. Hopefully this information helps. |
Updated Viewport destructor to remove itself from World2D, to avoid World2D keeping invalid pointers. Fixes godotengine#89212
If anyone else encounters this issue, i think i've found a crude workaround that works |
That is the first thing I did when I found the bug. It does not work (even I initially thought it did!). After sometime the bug materialized again. The only thing that I found it works was the patch that has not been approved yet: I had to compile the engine by myself and apply the patch (3 lines of code which makes complete sense). |
Strange, after doing the change in my project it stopped happening, and i even released the game (to a limited audience) and have yet to hear of any crashes Guess i just got lucky 😅 |
In my case it was not being caused by a reload but by a simple removal of the SubViewport using It's very easy to reproduce, but after I started removing the world_2d from the SubViewport before calling I imagine #91123 would also fix it as it removes the SubViewport from World2D in the same way as set_world_2d: Line 1191 in 705b7a0
|
I'm looking for a workaround for this. I don't want to develop my game on a custom build or wait for 4.4. I tried the suggestion of using I tried replacing it with If anyone has a suggestion for another way to get around this, please reply. Thanks! |
This will probably be in 4.3.1, so no need to wait for 4.4 |
@DinoMC I vaguely remember that after finding this thread while having a similar problem, the exact suggestions from this thread weren't working for me either. But this code worked fine on both 4.2 and on 4.3 right now:
I don't remember why exactly (probably should've added comments :D), but I think the problem was that |
@mynameiswhm In my case the _ready() func is working great, I'm actually using the following version : It's the _exit_tree() func that crash instantly, as soon as |
Tested versions
v4.2.1.stable.official [b09f793]
System information
Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+)
Issue description
Hello,
I've been experiencing an issue where Godot crashes when play() is called if a SubViewport's World2D is set to the scene root's World2D, after the scene is reloaded.
More specifically, the crash doesn't happen consistently, but rather sometimes it crashes instantly, and other times it crashes after a few reloads.
Some things I've observed:
Steps to reproduce
Minimal reproduction project (MRP)
Audio2DViewport Crash.zip
The text was updated successfully, but these errors were encountered: