godot: Remote Scene Tree is unusably slow in large scenes

(Update: 4.1 and 4.2 have gotten progressively worse. Now, the editor is entirely useless, even without the remote scene tree open. See comments below)

Godot version

Godot 4.1.beta3

System information

Windows 11/64, RTX 3070, Vulkan

Issue description

My largest scene has 80,000 nodes in it and we have countless more to add. Foliage, rocks, and houses made up of individual components. Running the game, editing the SceneTree, and debugging line by line is fine, but viewing the remote scene tree is unusably slow.

Click on something in the remote scene tree, even expanding/collapsing nodes with few children, clicking anything, or typing into the search filter, or stopping the program, and wait 10-20 seconds before you get a response.

Even if the remote scene tree is not active, the editor menu is very sluggish, though not as bad. Maybe 1s per response.

I wrote an MRP that generates meshes in the scene tree. Browsing the large tree in the editor is no problem. Running the objects in game is no problem. Only the remote tree and editor menus when running the game has a problem.

I found that even starting around 3000 the remote tree starts to get sluggish and gets progressively worse from there. 90k is unusable. Interestingly at around 100k nodes in my running scene (108,935) I started getting this error message repeated on the console and the remote scene tree operated at normal speed, though with maybe 70k nodes in the remote tree instead of the total.

ERROR: Condition "err != OK || size > out_buf.size() - 4" is true. Continuing.
   at: _write_out (core/debugger/remote_debugger_peer.cpp:106)

I’ve been struggling with this issue for a long time, all of the GD4 builds, and maybe before. Still present in 4.1.beta3. I thought it was caused by #68232, but no. This MRP has only the automatic material and MeshInstance3D. It’s not a custom shader issue, nor physics, gpuparticles, nor rendering. It’s slow even if the objects are invisible.

Steps to reproduce

  • Run the MRP
  • Set per_side to one of:
    • 30 for 28k objects (3s/click)
    • 45 for 91k objects (painful - this is my life)
    • 47 for 106k to overflow the buffer and it works at normal speed
  • Generate. Wait 20-30 seconds.
  • Expand/collapse nodes in the tree and observe it is normal speed
  • Run the game
  • Switch back to the editor, enable the remote tree and see its lag. With remote tree up, click on the menus and see how it kills everything. Good luck doing anything for 10+ seconds. You can click back to local for a usable editor.

Minimal reproduction project

4.1b3 project file, but everything works in 4.0 if you set the message limit to 102400.

test_slow_remote_tree.zip

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 26
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I did some profiling, and the main issue with this problem is not that the remote scene tree rebuilds every time it’s modified, but that during the rebuild process, EditorNode::get_class_icon is called, which check the existence of path remap file every time. After commenting out this part, the remote scene tree’s performance returned to normal.

Here’s a simple workaround build (node icons are missing). If anyone is still suffering from this issue, feel free to give it a try. https://drive.google.com/file/d/1wObYh0WXGf-4PIDFwoNvXm0ankDFwTdL/view?usp=sharing

And based on what I find in #100109, this is likely to be a Windows specific problem. Has anybody tested on Linux or MacOS?

I also ran into this problem, I have 125k nodes, click on the remote scene can not see the scene tree. 4.1.1.stable

#101435 should resolve regression introduced by #88427 completely. Now bottleneck moves to Tree operations, we may have to adopt something like #99700 to tackle this.

I’ve got a project that dynamically generates nodes from a binary file - the result is around 22,000 nodes according to what’s obtained from the debugging server. Assuming the issue is the same, this seems to be caused by the fact that the (local state) remote tree gets cleared and recreated every single time the remote tree is updated.

https://github.com/godotengine/godot/blob/d443f127ef1db9fb2fe623ba1c17ded5402aff10/editor/debugger/editor_debugger_node.cpp#L627-L633

The create_item call in the loop that recreates the tree is a significant hotspot in large scenes, to perhaps nobody’s surprise:

https://github.com/godotengine/godot/blob/d443f127ef1db9fb2fe623ba1c17ded5402aff10/editor/debugger/editor_debugger_tree.cpp#L157-L160

I assume a way to do this that would be faster in large scenes would be to only send changed nodes or even the changed attributes, rather than the entire tree. But it’s not clear to me how or if this could be implemented in Godot due to my lack of experience with the codebase.

To add more data, I encountered this error on Mac with Godot v4.4.beta3.

E 0:01:17:0547   _write_out: Condition "err != OK || size > out_buf.size() - 4" is true. Continuing.
  <C++ Source>   core/debugger/remote_debugger_peer.cpp:108 @ _write_out()

This error fires once a second while the Remote tree is open. The Remote tree is blank. It has 84,787 mostly static nodes in it. For scenes with fewer nodes, the Remote tree is viewable.

Godot v4.4.beta3 - macOS Sonoma (14.6.1) - Multi-window, 1 monitor - Metal (Forward+) - integrated Apple M1 Pro (Apple7) - Apple M1 Pro (10 threads)

Thanks.

Does anyone have a work around for this issue,

I have not discovered any workaround. I needed to position objects so I did it in a copy of my game with just a few objects. Not ideal at all.

This has gotten worse. When I reported it, the editor was functional while running a game until you enabled the remote scene tree. Now in 4.1.2 while running my game, with a scene w/ 80k nodes open, the editor is half useless. The code editor, local scene tree and inspector are ok. All of the menus, open window, and loading/closing a scene are slow. The visual profiler stops every few seconds anytime you hover over something while the tooltip loads.

I built 4.1.2 with module_text_server_fb_enabled=yes module_text_server_adv_enabled=no and now the editor interface is normal with a game running. The menus popup and the profilers don’t halt when loading the tooltip. Opening and closing scenes is normal.

Then I enabled the remote scene tree and the editor performance fell off a cliff. Back to 20-30s per click in the tree or editor menus. So the advanced text server is not the cause of this. #82105 might indeed have the same cause. But the advanced text server is a whole other separate problem.