prevent _ready() hang when using dynamic agent setup#56
prevent _ready() hang when using dynamic agent setup#56nongvantinh wants to merge 1 commit intoedbeeching:mainfrom
Conversation
Fixes: edbeechingGH-55 Avoids waiting on already-fired `ready` signals by deferring _initialize() using `call_deferred()`. This ensures all dynamically added nodes and dependencies have completed their own _ready() methods before initialization.
There was a problem hiding this comment.
Hello and thanks for this PR, I haven't tried it but the solution seems elegant. I'd like to do a brief test if I get some time on both Windows and Linux, but likely it will be fine.
There might be an edge case if some of the important nodes use "await frame/physics frame/etc" in their ready methods (or are otherwise not loaded within a single frame), but this case can also happen with the previous code.
For all such cases, there might be a simple alternate solution. One possible way might be to extend sync.gd in the project, override _ready() to do nothing (just return), then just call sync _initialize() from your game/scene manager node once the scene has fully loaded.
| _initialize() | ||
| await get_tree().create_timer(1.0).timeout | ||
| get_tree().set_pause(false) | ||
| call_deferred("_try_initialize") |
There was a problem hiding this comment.
| call_deferred("_try_initialize") | |
| _try_initialize.call_deferred() |
Fixes: GH-55
Avoids waiting on already-fired
readysignals by deferring _initialize() usingcall_deferred(). This ensures all dynamically added nodes and dependencies have completed their own _ready() methods before initialization.