Missing nodes when parenting a scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By InterDan

Hi!

So, I have this project that tries to emulate those old videogames that used videos inside an interface (e.g. Los Justicieros). As such, every scene switch is happening inside the panel that holds the “scenes” inside the interface, erasing the previous node and instancing the new. I used this article from the documentation as the base of my code, however, something weird is happening. Sometimes, seemingly at random, when the scene is switched, some nodes of the scene are missing.

enter image description here

I tried to instance the scene, duplicate it, add one of the instances to the scene tree root and the other to the scene container and, by using the remote scene view, I could check that when something is missing in the scene, it isn’t missing in the duplicate node, so the problem must be occuring when adding the child to the scene container.

I’m really not sure if this is a problem with the engine or I made a mistake with my code, and I couldn’t replicate the bug on an empty project, so I don’t know if I should report it.

I uploaded a sample of the project here. I only included a scene with the shop because is where this happens the most, but I observed this happening on other scenes as well.

The photo icon at the bottom right reloads the scene. By clicking repeatedly you can observe the issue. This happens either on Godot 3.1.1 and Godot 3.2.alpha

To wrap up, I guess what I’m asking is: Am I doing something wrong? Should I report this even though I can’t replicate it? Is it possible that the project is corrupted somehow?

Some observations:

It seems that this happens even without the interface frame setup, using the get_tree().change_scene(path) method.
Deleting some nodes in the scene solves the issue. Maybe there’s a limit of nodes you can parent at once?

InterDan | 2019-10-15 14:46

:bust_in_silhouette: Reply From: InterDan

I think I figured out the problem. I was freeing a node that was part of the scene at the same time I was freeing the scene itself. However, I’m still unable to reproduce this in other project, so that might not be the actual problem/solution?

Anyway, if anything was learned, always remove the node from the parent before you free it.