-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Mainloop is being created and initialized after main scene and singletons #71695
Comments
Same behavior in Godot 3.5.1 stable. But GameLoop._init isn't flaky and always called after first scene ready. |
From documentation https://docs.godotengine.org/en/latest/classes/class_node.html
It seems I was wrong in original message. And singleton init order is correct right now. But anyways singletons should be initialized completely before all other nodes. because as main_loop they must be accessed at any time by normal modes. UPD: #72266 |
This was actually only partially addressed by the linked PR. |
What part of the issue is still relevant after #72248? |
@akien-mga Singletons initialization is not split from other nodes. I've made another pull request (closed now) for discussion #72266 , you can read more of problem in description |
Godot version
4.0.dev (14fdd28)
System information
Windows 11
Issue description
Experimenting with nodes initialization order, I have found something strange.
I have sample hierarchy like this:
Every node prints its status upon construction, being ready, and entering and exiting tree. For Mainloop it's construction, initialization and finalization
I have expected order like this:
Real order imho is broken (output from my test project attached to ticket):
(0.) during init of first frame custom mainloop is not initialized yet (related problem is fixed here #70771, and discussion in ticket led to this experiment)
(1.) Singletons while being slightly glorified nodes break tree initialization order : they enter tree before root scene node and are expected to be ready before it (because they are siblings), but in reality "singleton enters tree, node enters tree, singleton becomes ready, node becomes ready".
(2.). And mainloop is only created and becomes initialized after all nodes, and also is destroyed before final destruction of tree, while nominally being a container for all nodes. Such behavior diminishes it's usefulness, because user can't count on custom mainloop for early initialization checks (cli arguments, hardware, etc) or final cleanups. (Ok they can be set in very first singleton in list, but it's too easy to break their order).
More to this: Nodes of very first scene expect to have tree available at any moment. I have tried accessing mainloop from
Node2D._ready
. This leads to change in initialization order!Like this
Mainloop becomes constructed before everything else, and during first scene initialization nodes get access to half-baked mainloop, while it's init completion and finalization stay where they very.
My question is are (1.) and (2.) bugs or such behavior has some purpose?
Steps to reproduce
Minimal reproduction project
test_init_order.zip
The text was updated successfully, but these errors were encountered: