Ensure that SceneTree is initialized and finalized at correct time
SceneTree should be fully initialized before any tree operation with any node and finalized only after all nodes exited tree.
Accounts only for in-tree operations, not constructors. After fix init-deinit order will be:
- constructors (_init) in unspecified order
- SceneTree native _initialize
- SceneTree script _initialize
- All nodes in-tree lifecycle (_enter_tree ->_ready -> ...-> _exit_tree)
- SceneTree script _finalize
- SceneTree native _finalize
Partially fixes https://github.com/godotengine/godot/issues/71695
Possibly related to #70771 ? CC @kleonc
Added one more pull request as follow up to this https://github.com/godotengine/godot/pull/72266 It's experimental and is meant for discussion.
Possibly related to #70771 ? CC @kleonc
@akien-mga Kinda related as both are fixing some aspects of likely not-so-logical initialization order for MainLoop/SceneTree. But I do think both PRs are fine on their own / independent.
Needs a rebase though :)
@RandomShaper Could you also look into this https://github.com/godotengine/godot/pull/70771 ? It would be nice to have both fixes in upstream @YuriSizov done
Thanks! Yeah, we're aiming to merge this for 4.2 dev1.
Thanks!