Prevent Sync blocking if added after the parent node - #71
Conversation
Sync will now only await parent's ready signal if the parent is not already ready.
|
Allowing to dynamically add a sync node is a very good idea. I have not tested this but have had a look at the code: Following line is removed: and then replaced by these lines: However isn't this the same as: Because I only see a difference between the original line and the replaced lines, when Maybe the code is doing something else I am not currently seeing? |
|
If the parent node is already ready, that means the ready signal was already emitted as well. In the standard use setup that's fine, sync's ready will be called before the parent is ready, and the await is used to allow the scene to load (so that we have available aicontrollers). However, if you were to add the sync node after, then its ready method would be awaiting a signal that will not be sent again. |
|
Thanks, that explains it. So without the if-condition, the sync node would wait forever for the ready Signal that will not be emitted again because the parent node already is ready. |
That's correct. It's fine for the standard use case as in the examples, this just adds the option of adding the sync node later. |
The main supported method for using the sync node currently is to add it initially to the training scene.
However, if you add the sync node later (e.g. in code) after you've initialized the scene, its ready method will not complete.
This should address that specific scenario without altering functionality otherwise (note: yet to be tested).
There is a related issue here: #55