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
454 stars 18 forks source link

Errors in Godot 4.1-stable-mono #11

Open claychinasky opened 1 year ago

claychinasky commented 1 year ago

There are many errors at runtime, most of them about red colored errors:

E 0:00:00:0987   is_auto_translating: 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.
  <C++ Error>    Condition "!is_readable_from_caller_thread()" is true. Returning: (false)
  <C++ Source>   scene/gui/control.cpp:3047 @ is_auto_translating()

many of these errors are Use call_deferred() probably cause of the changes in 4.1 and this :

E 0:00:00:0527   viewport_set_measure_render_time: Condition "!viewport" is true.
  <C++ Source>   servers/rendering/renderer_viewport.cpp:1253 @ viewport_set_measure_render_time()

plugin seems to work fine but not sure if any of the errors impacts the performance or make the calculations incorrect.

Calinou commented 1 year ago

I don't know why an is_auto_translating() threading warning appears, since I never call it in the project.

I could probably disable automatic translation in the debug menu, as it's not really designed for internationalization and can be counterproductive for the use cases stated in the README. This probably won't fix the warning though.

claychinasky commented 1 year ago

I tried to fix these but many of these API calls are not even used directly, most of the errors are confusing to me, VBoxContainer/... and a few others. I was able to fix a few but here is the rest of the errors. image

isirode commented 1 year ago

Hello,

To Calinou, I was doing to push a PR, but I've noticed your change in the changelog when looking at the contributing.md document.

This code also works:

var viewport_rid_for_thread := get_viewport().get_viewport_rid()
thread.start(
  func():
      # Enable required time measurements to display CPU/GPU frame time information.
      # These lines are time-consuming operations, so run them in a separate thread.
      RenderingServer.viewport_set_measure_render_time(viewport_rid_for_thread, true)
      call_deferred("update_information_label")
      call_deferred("update_settings_label")
)

Since you've already made a fix I won't make a PR, but I thought you might want to know this.

Calinou commented 1 year ago

Since you've already made a fix I won't make a PR, but I thought you might want to know this.

It appears my fix isn't complete for 4.1, so a PR is still welcome 🙂

isirode commented 1 year ago

It's there https://github.com/godot-extended-libraries/godot-debug-menu/pull/12

I did not updated the changelog nor version, let me know if I should update them (maybe the changelog).

LeeWannacott commented 1 year ago

Get 500+fps less (which is about 25%) in VISIBLE_DETAILED vs VISIBLE_COMPACT; Guessing it's because all of the errors :/. Also get a couple hundred more fps than what is reported in the Godot profiler in both modes... I don't know if this plugin/addon is currently very accurate.

Calinou commented 1 year ago

Get 500+fps less (which is about 25%) in VISIBLE_DETAILED vs VISIBLE_COMPACT; Guessing it's because all of the errors :/.

If no errors are spammed every frame, this is because 2D rendering is expensive in Vulkan: https://github.com/godotengine/godot/issues/71084 Rendering more elements slows down rendering, since more glyphs need to be drawn.

Note that FPS is not a linear metric, so I suggest you compare the difference in frametime (milliseconds per frame) instead of FPS. 5000 vs 5500 FPS is a very small difference, while 50 FPS vs 550 FPS is a huge difference.

Also get a couple hundred more fps than what is reported in the Godot profiler in both modes... I don't know if this plugin/addon is currently very accurate.

I suggest using an external FPS counter to compare with, such as RTSS, MangoHud or Special K. At very high FPS values (more than 1,000), you should expect significant discrepancies to occur anyway. What FPS value are you getting, and on which hardware?