Debug CanvasItem redraw

I wanted to add this tool for years and always forget. This command line option:

```
$ godot.exe -e --debug-canvas-item-redraw
```

Allows to see when a canvas item is redrawn. This helps find out if something
in the UI is refreshing in a way it should not. Examples as such:

* Signals causing more of the UI to redraw.
* Container resizing causes more UI elements to redraw.
* Something using a timer is redrawing all time time, which can go unnoticed.

To my surprise, the editor UI is redrawing very efficiently. There is some
weird stuff with the scene tabs, redrawing when the inspector changes but most
things for the most part are fine.
This commit is contained in:
Juan Linietsky 2023-07-07 19:35:54 +02:00 committed by Rémi Verschelde
parent 713bfaf5ea
commit 407b16ab00
No known key found for this signature in database
GPG key ID: C3336907360768E1
14 changed files with 124 additions and 0 deletions

View file

@ -209,6 +209,7 @@ static bool debug_collisions = false;
static bool debug_paths = false;
static bool debug_navigation = false;
static bool debug_avoidance = false;
static bool debug_canvas_item_redraw = false;
#endif
static int max_fps = -1;
static int frame_delay = 0;
@ -471,6 +472,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n");
OS::get_singleton()->print(" --debug-avoidance Show navigation avoidance debug visuals when running the scene.\n");
OS::get_singleton()->print(" --debug-stringnames Print all StringName allocations to stdout when the engine quits.\n");
OS::get_singleton()->print(" --debug-canvas-item-redraw Display a rectangle each time a canvas item requests a redraw (useful to troubleshoot low processor mode).\n");
#endif
OS::get_singleton()->print(" --max-fps <fps> Set a maximum number of frames per second rendered (can be used to limit power usage). A value of 0 results in unlimited framerate.\n");
OS::get_singleton()->print(" --frame-delay <ms> Simulate high CPU load (delay each frame by <ms> milliseconds). Do not use as a FPS limiter; use --max-fps instead.\n");
@ -1414,6 +1416,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
debug_navigation = true;
} else if (I->get() == "--debug-avoidance") {
debug_avoidance = true;
} else if (I->get() == "--debug-canvas-item-redraw") {
debug_canvas_item_redraw = true;
} else if (I->get() == "--debug-stringnames") {
StringName::set_debug_stringnames(true);
#endif
@ -3050,6 +3054,9 @@ bool Main::start() {
NavigationServer3D::get_singleton()->set_active(true);
NavigationServer3D::get_singleton()->set_debug_enabled(true);
}
if (debug_canvas_item_redraw) {
RenderingServer::get_singleton()->canvas_item_set_debug_redraw(true);
}
#endif
if (single_threaded_scene) {