-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
EXPERIMENTAL/ FOR DISCUSSION separated autoload initialization from normal node initialization #72266
EXPERIMENTAL/ FOR DISCUSSION separated autoload initialization from normal node initialization #72266
Conversation
b84a0e8
to
ce84e49
Compare
I don't see why that has to be the case. They are accessible via SceneTree and by a script constant when they are marked as
I don't think that should be the case. The only thing I see value is getting all of them
Same as above. It does have value initializing them fully before starting the next, but they should not really be treated specially after that. |
Basicly my fix behaves exactly like that. We add singletons only on application start and order is changed only for _enter_tree and _ready events. Then tree traverse order is exactly the same as before. I think _deinitialization should be changed, that singletons are destroyed after all nodes.
Ok. I'll split singleton init one by one |
autoload singletons should be accessible from any normal node at any time. Right now singletons init as any other node and thus are not yet initialized during initialization of start scene. Order is something like this ``` singleton1 _enter_tree ... singletonN _enter_tree mainSceneRootNode _enter_tree mainSceneChild1 _enter_tree .... mainSceneChildN _enter_tree singleton1 _ready ... singletonN _ready mainSceneChild1 _ready .... mainSceneChildN _ready mainSceneRootNode _ready ``` As you can see during main scene _enter_tree phase singletons are not yet ready. This change treats autoloaded singletons (and its descendant) as separate tree which becomes fully _ready before main scene tree. Like this: ``` singleton1 _enter_tree ... singletonN _enter_tree singleton1 _ready ... singletonN _ready mainSceneRootNode _enter_tree mainSceneChild1 _enter_tree .... mainSceneChildN _enter_tree mainSceneChild1 _ready .... mainSceneChildN _ready mainSceneRootNode _ready ```
Made it so each other autoload node in order could safely access previously initialized autoloads. New order of scenetree init is like this ``` singleton1 _enter_tree singleton1 _ready .... singletonN _enter_tree singletonN _ready scene root node _enter_tree ...its children scene root node _ready scene root node _exit_tree singletonN _exit_tree ... singleton1 _exit_tree ```
ce84e49
to
e363983
Compare
Small update:
|
What I meant is that it shouldn't happen every time a Node propagates So the Node class itself should not care about this, only the SceneTree when doing the initialization (and finalization as you mentioned), by controlling when propagating the TBH I'm not sure if SceneTree is the one to handle this, maybe it's something for |
I'll think about another solution then. And this particular PR can be closed. |
BTW, you should open a proposal about this. I do see the merit of doing this but I'm not the only one you need to convince. It also helps reaching an agreement on how to implement before actually writing the code. |
(continuation of #72248)
THIS CHANGE IS EXPERIMENTAL AND PROVIDED FOR DISCUSSION FOR #71695
Autoload singletons should be accessible from any normal node at any time. Right now singletons init as any other node and thus are not yet initialized during initialization of start scene.
Order is something like this
As you can see during main scene _enter_tree phase singletons are not yet ready.
This change treats autoloaded singletons (and its descendant) as separate tree which becomes fully _ready before main scene tree.
Like this:
From documentation https://docs.godotengine.org/en/latest/classes/class_node.html
Thus it is slightly(?) breaking change. And it doesn't take into account possible dependencies between autoload singletons (aka singletons can't use each other from _ready in any order).
Some things to discuss: