godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.34k stars 21.06k forks source link

BlendSpace2D outputs `This function in this node... Use call_deferred() instead.` many times when creating a new point. #85456

Open Mantissa-23 opened 10 months ago

Mantissa-23 commented 10 months ago

Godot version

4.2.rc2.mono

System information

Godot v4.2.rc2.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.3734) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Issue description

The following error is output to the console when performing the below reproduction steps:

Add Animation Point
  This function in this node (/root/@EditorNode@17119/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@PanelContainer@6818/@VBoxContainer@6819/@AnimationTreeEditor@12449) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
  This function in this node (/root/@EditorNode@17119/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@PanelContainer@6818/@VBoxContainer@6819/@AnimationTreeEditor@12449) can only be accessed from either the main thread or a thread group. Use call_deferred() instead

The error will print 32 times on my machine per created point on my machine.

Steps to reproduce

Assuming the provided MRP:

  1. Open res://Games/Kinship/Characters/HumanoidBase.tscn
  2. Enter the AnimationTree editor
  3. Open either of the BlendSpace2D editors
  4. Use the "Create point" tool to create a point with any animation

Minimal reproduction project

AnimationTreeErrorReproduction.zip

TokageItLab commented 10 months ago

I guess this is a bug related to the GraphNode rework since this bug might appeared at a time unrelated to the animation rework. It would be helpful if you could bisect.

cc @Geometror

YuriSizov commented 10 months ago

I guess this is a bug related to the GraphNode rework since this bug might appeared at a time unrelated to the animation rework.

GUI code must be called from the main thread. You should check if any methods of the animation editor are calling methods of GUI nodes, especially related to tree manipulation, from a sub-thread. I don't think there is any threading in GraphEdit so it shouldn't be the cause of the issue.

Kylemcarthur commented 8 months ago

I believe I'm encountering the same bug. Version 4.2.1 stable. My project also uses BlendSpace2D as mentioned. image

Eluem commented 7 months ago

I'm not sure if this is the same bug or a different, but related bug..

I'm getting the following error 3 times any time I save a change to my code while my animation tree is open. I don't have any blend trees, just an animation state machine with a nested animation state machine and a few animation nodes.

This function in this node (/root/@EditorNode@17120/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@PanelContainer@6819/@VBoxContainer@6820/@AnimationTreeEditor@12462) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.

Edit: Further testing revealed that moving all the animations into the root state machine and deleting the nested one eliminated the error.

Edit 2: Never mind.. the errors are back. I'm not sure why..

baz-atak commented 6 months ago

If I close the editor when a scene with an animation tree in it is open, when opening the project again I get a number of errors as per

This function in this node (/root/@EditorNode@17120/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@PanelContainer@6819/@VBoxContainer@6820/@AnimationTreeEditor@12462) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.

If the scene isn't the highlighted/open scene then the errors don't occur, and if I switch to that scene then no errors are reported.

tiloc commented 6 months ago

I'm getting the same behaviour on 4.2.1 and 4.2.2. Whenever I open my project with an AnimationTree in it I get 15 of these error messages. My tree has a state machine and 2 BlendSpace2D in it.

MicroGame0 commented 4 months ago

image change [Callback Mode]-->[Method]-->Immediate. revise back。

baz-atak commented 4 months ago

@MicroGame0 I tried changing the setting to Immediate just in case that's what you meant, errors were still reported so changed back to deferred. My guess is that the blendspace code in the background isn't following the instruction.

Fichberg commented 3 months ago

Not sure if people are still having issue with this - very likely - but I just stumbled across this very same problem and it turns out I had both an AnimationPlayer node and an AnimationTree node, this one using said AnimationPlayer node, with the property active on. Turning off the AnimationPlayer node active property did the trick.

The error printed in the terminal seems very misleading and should be looked upon by the developers, assuming that is indeed the root of the problem.

David-DiGioia commented 1 month ago

@Fichberg Unchecking active on the AnimationPlayer node solved the issue for me too. Thanks!

j3du commented 2 days ago

I have the same error but in my case it seems Blend2 causes the issue. eg. blendSpace2D -> Output (this works) blendSpace2D -> Blend2 -> Output (blendSpace2D no longer works) godot 4.3 window10