Game crashes when unloading scene

Godot Version

Godot 4.4.1

Question

Hi!
I’ve been having this issue where my game crashes upon unloading a specific pretty large scene. This would be fine, but I can’t get any error message to pop up in editor or through the console when opening the game with --verbose.

Through testing, this seems to be happening when the scene gets unloaded.

Running the following code on that scene consistently gets the game to crash without an error message.

SceneTree tree = GetTree();
tree.UnloadCurrentScene();

The code above works on every other scene with no issue.

The only idea I have would be related to object pooling, as the scene makes heavy use of it. However, this shouldn’t impact the unloading process since all those nodes would end up getting deleted alongside their parent node.

Does anyone know what I could do to fix or at least get an error message to show up somehow?

Edit:
This is what shows up when running it through console.

================================================================
CrashHandlerException: Program crashed with signal 11
Engine version: Godot Engine v4.4.1.stable.mono.official (49a5bc7b616bd04689a2c89e89bda41f50241464)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] error(-1): no debug info in PE/COFF executable
[2] error(-1): no debug info in PE/COFF executable
[3] error(-1): no debug info in PE/COFF executable
[4] error(-1): no debug info in PE/COFF executable
[5] error(-1): no debug info in PE/COFF executable
[6] error(-1): no debug info in PE/COFF executable
[7] error(-1): no debug info in PE/COFF executable
[8] error(-1): no debug info in PE/COFF executable
[9] error(-1): no debug info in PE/COFF executable
[10] error(-1): no debug info in PE/COFF executable
[11] error(-1): no debug info in PE/COFF executable
[12] error(-1): no debug info in PE/COFF executable
[13] error(-1): no debug info in PE/COFF executable
[14] error(-1): no debug info in PE/COFF executable
[15] error(-1): no debug info in PE/COFF executable
[16] error(-1): no debug info in PE/COFF executable
[17] error(-1): no debug info in PE/COFF executable
[18] error(-1): no debug info in PE/COFF executable
[19] error(-1): no debug info in PE/COFF executable
-- END OF BACKTRACE --
================================================================

Hi,

Never had such an issue, but that seems related: get_tree().unload_current_scene() sometimes causes a silent crash, with no errors or logs · Issue #85692 · godotengine/godot · GitHub

Would that suggestion from the issue help?

My “silent crash” bugs were fixed by removing all ViewportTextures from the scene tree before unloading the scene. I tried to create a minimal reproduction project but was unable to reproduce the bug in a simpler project.
I’m leaving this information here in case someone else has problems with their Godot game suddenly exiting on a scene change – try unassigning any ViewportTexture properties from the scene tree before unloading the scene.


If that does not help, one thing I would probably try is deleting stuff from the scene step by step, to see if at some point, the crash does not happen, which would allow you to know what node is causing the crash (if that’s related to a specific node, but I suppose it is based on the fact that one specific scene is having the problem).
Finding the problem source is not an actual fix ofc, but that’s 50% of the bug fixing process :sweat_smile:

I do have a pretty large viewport texture being rendered, so that could be it?
I’ll give it a shot, might work.
Thanks!

Well, that would be the first thing to try out then!
Let us know if that’s related to that viewport.