godot-extended-libraries / godot-debug-menu

Display in-game FPS/performance/hardware metrics in a Godot 4.x project
https://github.com/godot-extended-libraries/godot-debug-menu-demo
MIT License
429 stars 16 forks source link

With latest godot getting 4.1 a lot of "This function in this node can only be accessed from either the main thread or a thread group" #4

Closed Ughuuu closed 1 year ago

Ughuuu commented 1 year ago

About 25 errors similar to this one.

E 0:00:01:0591   get_viewport_rid: This function in this node can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
  <C++ Error>    Condition "!is_readable_from_caller_thread()" is true. Returning: (RID())
  <C++ Source>   scene/main/viewport.cpp:927 @ get_viewport_rid()
Calinou commented 1 year ago

cc @Ark2000

Does this occur with version 1.0.0 of this add-on? See https://github.com/godot-extended-libraries/godot-debug-menu/pull/1 which moved some computations to a thread.

matmas commented 1 year ago

I can also replicate the issue in v4.1.dev4.official [5c2295ff5] and 1.1.0 of this plugin. When I move the mentioned computations from the thread back to the _ready function to be called directly there then there are no errors produced.

Calinou commented 1 year ago

Still reproducible as of 3aaa78709 with version 1.1.1 of the add-on/demo:

ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_viewport_rid (scene/main/viewport.cpp:913)
ERROR: Condition "!viewport" is true.
   at: viewport_set_measure_render_time (servers/rendering/renderer_viewport.cpp:1253)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Information) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: is_auto_translating (scene/gui/control.cpp:3047)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Information). Use call_deferred() or call_thread_group() instead.
   at: queue_redraw (scene/main/canvas_item.cpp:394)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Information) can only be accessed from the main thread. Use call_deferred() instead.
   at: update_minimum_size (scene/gui/control.cpp:1597)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Information). Use call_deferred() or call_thread_group() instead.
   at: update_configuration_warnings (scene/main/node.cpp:3045)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: is_auto_translating (scene/gui/control.cpp:3047)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: queue_redraw (scene/main/canvas_item.cpp:394)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from the main thread. Use call_deferred() instead.
   at: update_minimum_size (scene/gui/control.cpp:1597)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: update_configuration_warnings (scene/main/node.cpp:3045)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: is_auto_translating (scene/gui/control.cpp:3047)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: queue_redraw (scene/main/canvas_item.cpp:394)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from the main thread. Use call_deferred() instead.
   at: update_minimum_size (scene/gui/control.cpp:1597)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: update_configuration_warnings (scene/main/node.cpp:3045)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: is_auto_translating (scene/gui/control.cpp:3047)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: queue_redraw (scene/main/canvas_item.cpp:394)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from the main thread. Use call_deferred() instead.
   at: update_minimum_size (scene/gui/control.cpp:1597)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: update_configuration_warnings (scene/main/node.cpp:3045)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_content_scale_mode (scene/main/window.cpp:1309)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_size (scene/main/window.cpp:353)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_size (scene/main/window.cpp:353)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_size (scene/main/window.cpp:353)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: is_auto_translating (scene/gui/control.cpp:3047)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: queue_redraw (scene/main/canvas_item.cpp:394)
ERROR: This function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings) can only be accessed from the main thread. Use call_deferred() instead.
   at: update_minimum_size (scene/gui/control.cpp:1597)
ERROR: Caller thread can't call this function in this node (/root/DebugMenu/DebugMenu/VBoxContainer/Settings). Use call_deferred() or call_thread_group() instead.
   at: update_configuration_warnings (scene/main/node.cpp:3045)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_camera_3d (scene/main/viewport.cpp:3668)
ERROR: This function in this node (/root) can only be accessed from either the main thread or a thread group. Use call_deferred() instead.
   at: get_msaa_2d (scene/main/viewport.cpp:3159)

Fixed by https://github.com/godot-extended-libraries/godot-debug-menu/commit/e73e8371dc0fed4308b0d7ffb4ba3900da0a93ab, which is designed to be backwards-compatible with 4.0.x.