Godot SceneTree Group Queries Lack Pagination and Result Limits
0 reputation · 07 Aug 2021, 02:20 UTC
0 reputation · 07 Aug 2021, 02:20 UTC
Godot 4.x's SceneTree.get_nodes_in_group(group_name) returns a full Array of every node in the named group. The method walks the entire scene tree, collects references, and allocates an array whose size scales linearly with group membership. There is no limit, offset, or lazy-iteration parameter, and no filtered count API exists alongside the new get_node_count() introduced in 4.3.
NOTIFICATION_ENTER_TREE and NOTIFICATION_EXIT_TREE manually._process but does not quantify a cost threshold.The common workaround is a custom autoload registry that maintains its own Array or Dictionary and uses slice(offset, limit) for paging, but this adds boilerplate and must handle multi-scene setups, editor-vs-runtime differences, and reference-cycle cleanup.
get_nodes_in_group becomes a measurable frame-time cost in Godot 4.3?NOTIFICATION_ENTER_TREE/EXIT_TREE reliably stay consistent across scene instancing and multi-threaded loading?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.