Godot: SceneTree.call_group() is doing a deferred call

Created on 11 Feb 2020  路  2Comments  路  Source: godotengine/godot

Godot version:
40d1b0b

OS/device including version:
Ubuntu 18.04 64bit

Issue description:
Using SceneTree.call_group() will perform in-explicitly a deferred call. This behavior is not described in any documentation and can lead to potential function misuse.
I'm not sure but I assume it should be changed to just perform call normally for consistency (the same way how we have node.call() and node.call_deferred() functions, we would have SceneTree.call_group() and SceneTree.call_group_flags()).

Worth to notice this change could potentially break compatibility.

Steps to reproduce:
Manual:

  1. Create scene called GroupCallReceiver
  2. Add root node of GroupCallReceiver to "GroupCallReceiver" group
  3. Add func some_function(): print("performing GroupCallReceiver function") inside
  4. Create scene called CallGroupIssue, instance GroupCallReceiver inside
  5. Add such implementation of ready to CallGroupIssue
func _ready():
    get_tree().call_group("GroupCallReceiver", "some_function")
    print("After doing a call_group()")
  1. Run CallGroupIssue scene and see in the output the "After doing a call_group()" string is printed before "performing GroupCallReceiver function"

Automatic:

  1. Download reproduction project
  2. Open it
  3. Start with F5
  4. See in the output the "After doing a call_group()" string is printed before "performing GroupCallReceiver function" (related scenes: IssueCallGroup.tscn and GroupCallReceiver.tscn)

Minimal reproduction project:
call_group_deferred.zip

discussion documentation core

Most helpful comment

It might be worth changing this in 4.0 for consistency, but I wonder why it's deferred by default in the first place.

All 2 comments

Hello @kubecz3k this is not a bug, indeed call_group is by default executed on an idle/deferred time. For realtime group call you should use the method "call_group_flags" and use the GROUP_CALL_REALTIME enumerator.

Scene Tree/Call Group Flags

It might be worth changing this in 4.0 for consistency, but I wonder why it's deferred by default in the first place.

Was this page helpful?
0 / 5 - 0 ratings