Author Topic: [Unity 2019.2.2f1] Extreme lag when selecting sbsar file, long waits.  (Read 8528 times)

Ever since I included a single sbsar file, my project will freeze for 10 seconds or so every time I click on the asset in the project tab. It will also freeze for 10-30 seconds or so when hitting Play in the editor (usually when ending a session)

Here's a video: https://files.catbox.moe/6rnhq3.mp4

Without the file, there is no wait after starting or stopping a play session. What's causing the huge wait?

The sbsar file only has a single graph in it, and I optimized the graph the best I could (Takes around 800ms to render in Subtance Designer with the CPU engine.)
I can't seem to access the optimization guidelines, what can I do to prevent my workflow from getting wrecked with huge waits?

EDIT:

It also causes the editor to freeze for 10-20 seconds every time I interact with certain unrelated UI elements. It's pretty much unusable while a sbsar file exists in the project...

Deleting the sbsar fixes all issues immediately.
Last Edit: August 23, 2019, 08:07:48 am

Ever since I included a single sbsar file, my project will freeze for 10 seconds or so every time I click on the asset in the project tab. It will also freeze for 10-30 seconds or so when hitting Play in the editor (usually when ending a session)

Here's a video: https://files.catbox.moe/6rnhq3.mp4

Without the file, there is no wait after starting or stopping a play session. What's causing the huge wait?

The sbsar file only has a single graph in it, and I optimized the graph the best I could (Takes around 800ms to render in Subtance Designer with the CPU engine.)
I can't seem to access the optimization guidelines, what can I do to prevent my workflow from getting wrecked with huge waits?

EDIT:

It also causes the editor to freeze for 10-20 seconds every time I interact with certain unrelated UI elements. It's pretty much unusable while a sbsar file exists in the project...

Deleting the sbsar fixes all issues immediately.

Hi,

Can you send me the sbs file and we will take a look.

Cheers,
Wes
Head of Substance Demo Art Team
the3dninja@adobe.com
Twitter: The3DNinja

The last time I tried to export with dependencies it skipped a couple dependencies. It seems like they're all there this time, but let me know if something is missing.

https://drive.google.com/open?id=1Iq299aB9kz5rCRnYtqzjge0pEehaG32-

And here's a magnet mirror:
Code: [Select]
magnet:?xt=urn:btih:8e60121701c11f174a6b2fb82e9b8cbd1e2f0e3a&dn=Kobold.zip
Thanks for the help!

It's also probably a good idea to profile the editor to get a better sense of exactly what is causing Unity to freeze up. The only caveat is that if it freezes up for more than 10-15 seconds (as you mentioned it did) it could be hard to capture that time range in the profiler. But, if you can do this, it should tell you exactly which code is the cause of the issue.

It's also probably a good idea to profile the editor to get a better sense of exactly what is causing Unity to freeze up. The only caveat is that if it freezes up for more than 10-15 seconds (as you mentioned it did) it could be hard to capture that time range in the profiler. But, if you can do this, it should tell you exactly which code is the cause of the issue.

That's a great idea, I'll test if I can find anything and make a post about it.


Simply appears to be regenerating the graph as much and as fast as it can whenever I click on it, though I'm not sure.


The last time I tried to export with dependencies it skipped a couple dependencies. It seems like they're all there this time, but let me know if something is missing.

https://drive.google.com/open?id=1Iq299aB9kz5rCRnYtqzjge0pEehaG32-

And here's a magnet mirror:
Code: [Select]
magnet:?xt=urn:btih:8e60121701c11f174a6b2fb82e9b8cbd1e2f0e3a&dn=Kobold.zip
Thanks for the help!

Hi Dalton,

Thanks very much for supplying the sbs files. I was able to take a look and I think the issue is that the graph is in need of optimization. You can find the optimization guidelines here. https://docs.substance3d.com/sddoc/performance-optimization-guidelines-102400075.html

From what I see, I think the graph it trying to do too much and there is a lot being thrown at the substance engine to compute. I am not surprised it's taking a long time in the editor. There were many embedded bitmaps and a large number of subgraphs to compute. I think it's  best to break the substance into multiple substance files, when you find your are creating many subgraphs. Here are the top issues I was able to find.

1. There are many embedded bitmaps and many were set to RAW compression. The Normal maps will need to be raw but other than that, jpeg should be used. It might be better in this case to expose inputs and not embed the maps in the sbsar file itself. This way, you decouple the maps from the substance and can more easily update the content. This way, you can import the supporting maps into Unity and feed them into the sbsar within Unity via the substance input parameter.

2. All color operations were set to 32F bpc. This will definitely cause a slow down in the computing of the textures. Every uniform color node was set to 32F. Color operations should be kept at 8bpc whenever possible. Try to keep the graph grayscale and save color operations closer to the final output. I found situations where 32F color operations where being processed at the very beginning of the graph.

3. Many nodes were set to relative to parent when then could be set to a much lower resolution. Anytime you can lock at node at a lower compute resolution it will be faster. I saw this in some cases where the nodes were set to absolute 16x16, but there were also many uniform color nodes there were set to absolute. In those cases, the resolution would be whatever is set and unity and then it was also computing at 32F as well.

I attached an updates sbsar file. This should be a little better in terms of use in the editor. It is still very slow. The size has been cut down to 66mb from 122mb. I switched all color operations to 8bpc.

Please let me know if you have any questions on optimization. It doesn't look like this is an issue with the plugin, but more of an optimization issue. I double checked with the devs and they say that we are not doing anything in the plugin when you click on asset in the project (such as computing). At this point, the data has been generated. I am asking them to follow up on this in case there is something we can do in the plugin to help. 

Updated file: https://www.dropbox.com/s/bv6ofrl29lt8jgn/Kobold_update.sbsar?dl=0

Cheers,
Wes
Last Edit: August 26, 2019, 06:58:24 pm
Head of Substance Demo Art Team
the3dninja@adobe.com
Twitter: The3DNinja

Thank you very much! That's extremely helpful. Using inputs instead of embedding it in the file sounds like a really good idea. Then I can rely on Unity's speedy compression instead. I feel like I can optimize this now.

Though even though it's unoptimized, is it really supposed to take 8 seconds per frame when simply selecting the graph? That seems like a bug to me.