godot icon indicating copy to clipboard operation
godot copied to clipboard

Ensure that SceneTree is initialized and finalized at correct time

Open RedwanFox opened this issue 2 years ago • 3 comments

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:

  1. constructors (_init) in unspecified order
  2. SceneTree native _initialize
  3. SceneTree script _initialize
  4. All nodes in-tree lifecycle (_enter_tree ->_ready -> ...-> _exit_tree)
  5. SceneTree script _finalize
  6. SceneTree native _finalize

Partially fixes https://github.com/godotengine/godot/issues/71695

RedwanFox avatar Jan 28 '23 12:01 RedwanFox

Possibly related to #70771 ? CC @kleonc

akien-mga avatar Jan 28 '23 12:01 akien-mga

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.

RedwanFox avatar Jan 28 '23 18:01 RedwanFox

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.

kleonc avatar Jan 28 '23 18:01 kleonc

Needs a rebase though :)

YuriSizov avatar Jun 20 '23 14:06 YuriSizov

@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

RedwanFox avatar Jun 20 '23 21:06 RedwanFox

Thanks! Yeah, we're aiming to merge this for 4.2 dev1.

YuriSizov avatar Jul 07 '23 16:07 YuriSizov

Thanks!

YuriSizov avatar Jul 12 '23 15:07 YuriSizov