blackears / cyclopsLevelBuilder

A Godot plugin to let you block in levels inside the Godot editor.
MIT License
1.03k stars 43 forks source link

Materials tab preview generations causes project to hang on save #195

Open CpazR opened 3 weeks ago

CpazR commented 3 weeks ago

I have a number of different materials (shaders included) that the material selector tabs likes to re-generate previews for every time it saves. This causes the editor to hang and become unresponsive for upwards of 20 or so seconds when a save is triggered.

This seems to be a new thing because I don't remember it being so bad before. There is a change that the godot 4.3 update did something here.

A good way to test is the have multiple a number of materials (lets say 10) in the materials tabs and save. Then filter then out (I typed "none" in the filter field, as an example) and saving no longer caused the editor to hang.

There is, of course, the possibility this is an issue with my project, but I'm not doing anything special with my shaders as far as I can tell.

NOTE: The materials tab doesn't need to be open either. This hanging issue was eluding me for a while because I thought it was related to a large asset.

CpazR commented 3 weeks ago

Some video evidence of this issue. Not quite so dramatic of a hang here. Made a point to trim down on some unused shaders I was experimenting with. Still demonstrates the issue: https://github.com/user-attachments/assets/7c0e379f-77ac-458e-b6b0-36ebd42fc481

blackears commented 3 weeks ago

I made a change to how the thumbnails are being generated in 1.0.4. Now it's using a Godot library routine to generate the thumbnails. It might be faster to switch back to the old method where I was generating them in a separate viewport, although I don't know if that will be faster or not.

Edit: I've not noticed much slowdown on my development machine - could something other than thumbnail generation possibly be causing this?

CpazR commented 3 weeks ago

I made a change to how the thumbnails are being generated in 1.0.4. Now it's using a Godot library routine to generate the thumbnails. It might be faster to switch back to the old method where I was generating them in a separate viewport, although I don't know if that will be faster or not.

Edit: I've not noticed much slowdown on my development machine - could something other than thumbnail generation possibly be causing this?

I was trying to find what else would have caused, but I narrowed it down to shaders. Then I saw the material tab and toyed around with that.

Maybe the process works different depending on hardware??? My main machine isn't a slouch, but maybe there's some inconsistencies there.

CpazR commented 3 weeks ago

Also feel it's worth asking, does it need to generate previews every time? Can't it cache the previews and only re-generate them when the material or shader in question is "dirty"?

Would mean not all previews are generated at once and only re-generated when they need to be.

blackears commented 2 weeks ago

The issue there is that I don't know when the shaders become dirty. They are resources managed outside of Cyclops and I don't think there is a way to be notified of them changing.

Do you still get the slowdown when the materials tab is not open? You could just not have the window open a s a workaround.

I don't know when I'll get enough time to work on this. I'm a bit pressed at the moment.

CpazR commented 2 weeks ago

OK. Little bit of a write-up after being able to spend more time looking into this.

Still don't have the full picture, though. Will defer to you if this should be closed.

The issue there is that I don't know when the sharers become dirty. They are resources managed outside of Cyclops and I don't think there is a way to be notified of them changing.

Understandable. But also a little surprising that plugins wouldn't be able to access that.

Do you still get the slowdown when the materials tab is not open? You could just not have the window open a s a workaround.

The reason this took as long to identify as it did was due to the fact this happened even with the material tab closed.

So, I was able to experiment a little more with this once I carved out some time. I think this is a compounding issue between multiple plugins. Maybe an issue with godot itself and how it manages plugins that read assets from the file system. I think the main culprit is somewhere in AssetDock. With the hanging stopping (or at least being significantly reduced down to a split second) once I disabled that addon. But it does seem to be worsened with the shader preview generation that cyclops does.

Hence my suspicion this is an issue with godot itself. But I don't know how the editor manages plugins to really be able to validate those suspicions.

I don't know when I'll get enough time to work on this. I'm a bit pressed at the moment.

Yeah, I wouldn't worry so much about this. Maybe see if you can replicate the hanging on your side? I'm curious how reproducible this is.