I’m using the XR Tools staging mechanism to switch from my main menu to a second scene and then back to the main menu. This works fine so far.
However, when I programmatically load a 3D model and later delete it using node.queue_free(), the application crashes when switching back to the main menu.
I first noticed this problem after updating to Godot 4.6, although I’m not sure whether it’s actually related to the engine.
Things I have already tried:
Remote debugging is not very helpful because I end up stepping through _process() functions.
Using print statements doesn’t help much either. The issue seems to have a timing component, so sometimes the messages appear and sometimes they don’t.
I captured a crash report using adb. It shows the memory violation but doesn’t indicate where it occurs.
Make sure that when you manually queue free a node, you also remove it from the scene tree.
When the scene is unloaded, the nodes in the scene are freed as well. It sounds like this crash may be caused by double freeing that same node.
which seemed to work well. And there is no problem loading several models after each other (no memory leak, as far as i can see it), only when switching the scene.
The model itself is created reading a GLB from a ZIP file:
var modelData = zipReader.read_file(modelFile)
var result = gltfDocument.append_from_buffer(modelData, "", gltfState, 64)
...
mediaModelNode = gltfDocument.generate_scene(gltfState)
Is there anything else i have to do to remove a node from the scene tree?
I noticed that the 3D model is not causing the problem. The error occurs even if i don’t load the model. So i guess i’m not properly cleaning up something else in the scene tree.