godot_spatial_gardener icon indicating copy to clipboard operation
godot_spatial_gardener copied to clipboard

[BUG] (?) Hitching in editor

Open SlashScreen opened this issue 1 year ago • 14 comments

On the latest stable release, I have a lot of trees, and the editor hitches as I move the camera around (but in-game it seems fine). Is this something other people have seen? Should I try a nightly version?

SlashScreen avatar Apr 30 '24 09:04 SlashScreen

Hang on, my garden is using TRES instead of RES. That might be an issue. Is there an easy way to change which it's using?

SlashScreen avatar Apr 30 '24 09:04 SlashScreen

Hang on, my garden is using TRES instead of RES. That might be an issue. Is there an easy way to change which it's using?

Where exactly is it using tres instead of res? I don't think any critical code really depends on res over tres though

dreadpon avatar Apr 30 '24 10:04 dreadpon

On the latest stable release, I have a lot of trees, and the editor hitches as I move the camera around (but in-game it seems fine). Is this something other people have seen? Should I try a nightly version?

You need to provide a bit more info than that. How big is your scene? How many plants are you creating? Are you using scenes or mesh resources in your drawing process? Is there anything of note in the console when hitches occur? Do you have a Minimal Reproduction Project that I can test?

dreadpon avatar Apr 30 '24 10:04 dreadpon

Where exactly is it using tres instead of res? I don't think any critical code really depends on res over tres though

The garden work directory - greenhouse.tres, toolshed.tres. From experience I have learned that for larger/more often accessed files, .res can improve times related to parsing/serializing significantly.

You need to provide a bit more info than that. How big is your scene?

Sorry, I wrote this late at night. The scene is rather large, with over a thousand trees with collision nodes spawned. I'm using mesh resources, as far as I know, apart from the collision thing. The console says nothing. I don't have a minimal reproduction project at the moment.

SlashScreen avatar Apr 30 '24 16:04 SlashScreen

The setup you describe shouldn't cause much hitching.

Currently, the only thing that I know of that may cause these problems is spawning/respawning nodes when an LOD changes. But it usually has to spawn/despawn hundreds of nodes at a time...

Can you please enable the debug draw for your trees (at the top of 3D viewport when a Gardener is selected) and demonstrate the hitching on a video recording? Might be something about your setup that causes this, theoretically.

And/or give me an MRP, whenever you have the time.

dreadpon avatar Apr 30 '24 16:04 dreadpon

Here's a MRP. Just scrolling in and out should show it. Perhaps the problem is that the octree sizes are too big, and so it's not spawning a lot of things.

test.zip

SlashScreen avatar Apr 30 '24 20:04 SlashScreen

Changing the number of trees per chunk to be smaller did not change hitching.

SlashScreen avatar May 02 '24 23:05 SlashScreen

Can confirm the hitching, but there doesn't seem to be any bug causing this. So far, seems to just be how Godot behaves when adding tens/hundreds of nodes at once in the editor. In-game indeed works fine.

Tried adding nodes with INTERNAL flag, tried not giving an owner, tried naming them manually, doesn't seem to make a difference.

Will investigate further, but it's possible that a proper fix (offloading to threads or something similar) will be delayed for a major version (v2.x.x for example) because this potentially might be a breaking change.

dreadpon avatar May 03 '24 10:05 dreadpon

Before you try this: I've done testing when I was working with ProtonScatter, and instantiating a packed scene is much faster than duplicating a tree.

The fact that it's editor-only implies to me that the problem is adding nodes repeatedly to the editor scene tree; so what if you created an orphan node, added the static bodies to that node, and then added the orphan node to the scene, performing the operation all at once?

Should I pursue this avenue?

SlashScreen avatar May 04 '24 05:05 SlashScreen

Hi! Any known workaround for this issue? I have around ~2500 objects placed by gardener overall and it causes significant lags in editor, which makes usage of plugin rather painful

ar-russ avatar May 09 '24 18:05 ar-russ

@dreadpon maybe you could add checkbox for turning off processing octrees and/or LODs for objects in editor?

ar-russ avatar May 10 '24 07:05 ar-russ

I tried the static bodies node idea I had, but it didn't result in any performance gains. Is it critical that the tree be visible within the editor tree?

SlashScreen avatar May 10 '24 08:05 SlashScreen

@dreadpon maybe you could add checkbox for turning off processing octrees and/or LODs for objects in editor?

Upon profiling the engine, the problem does not appear to be fixable on my side. It's just a byproduct of updating AABBs, node names, owners and so on.

So an option to selectively stop processing certain features will most likely be the way I'll handle this, yes.

dreadpon avatar May 12 '24 12:05 dreadpon

1.4.0/1.4.1 will be releasing on 2025.03.05 (March), it has some changes in regards to how instances are spawned. It's better (at least in autotests it behaves somewhat faster) and LOD selection has been offloaded to a thread. Please test if these improvements are sufficient or not.

I do recommend reducing the amount of instances that spawn Nodes or at least keeping the node alive for ALL LODs (to reduce spawning/respawning). I'm not sure I can improve much beyond what I currently did.

I will look into how ProtonScatter handles its spawning process and see if there are any optimizations I can borrow from there. But it won't be soon: I unfortunately must turn my attention to other IRL stuff for a while

dreadpon avatar Mar 04 '25 08:03 dreadpon