-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Very noticeable stutter / lag when adding children to scene tree. #75369
Comments
@caliber06 Please upload a minimal reproduction project to make this easier to troubleshoot. Can you reproduce this when doing the same operation in 3.5.2? |
What is the child? Is it a scene that has not been displayed on screen before this moment? (shader compilation) Is it the same exact object being re-instanced on all of those spikes? Does the object have any scripts attached? Does the lag occur if you unattach and reattach the object from the scene tree? You should test on the same and subsequent frames. Use call_deferred for the latter.
So it is not occuring when the object is instanced with
What is stuttering? Is it just the blue ticks on the chart? These are insignificant, all about 1/60th of a second. Or does the whole engine seize? Does the mouse cursor move during the lag? |
the objects are being instanced and added at the same time. the packedscene that is being instanced has a script attached, which is a child class of a parent. I have tested instancing the object in _ready() and instancing it later on, same issue. The large AND small spikes on the graph are when adding children. The entire game freezes when adding objects to the scene tree like this. I won't be able to add a minimum-reproduction project until tomorrow. |
Does the instanced object have a shader material on it? Does placing a permanent instance of the object in the scene fix the problem when the new ones are instantiated? |
I notices the same problem also. Godot 3.5.2(in GDScript and C#) is more stable and faster on adding and queuefree() the children nodes. I just tested by adding 1000-2000 AnimatedSprite2D with one animation to test it. Nothing fancy. |
If you can compile from source or use a precompiled debug build, try using a C++ profiler on a debug build to see what's taking the most time. Edit: Please also test #75627 🙂 |
I should learn all this checkout , patch, branch etc2 from github first. |
Godot version
4.0
System information
Windows 10, Forward+, i5-10400
Issue description
adding children to the scene tree results in a noticeable stutter in increase in frametime.

(all those spikes are when adding children)
Steps to reproduce
just add a child of a loaded instance using add_child()
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: