Unexpectedly bad performance adding a property to a Shader Graph

I’ve been using Shader Graph under 2019.3, having previously used it in 2019.1, and so far my main reaction is that the performance of the Shader Graph editor seems much worse than it was under 2019.1. Under 2019.1, I could make nearly any change to the Shader Graph, as long as the object I was modifying wasn’t connected to the output, without any performance impact. If I was editing something connected to the master output, I could expect a bit of a delay when editing that node. But under 2019.3, I’m noticing that doing nearly anything in Shader Graph feels very laggy.

One surprisingly bad point is simply adding a property to a shader. As soon as I hit Enter after entering a name for the properly, there’s a 3-10 second delay where Unity becomes inresponsive. This doesn’t happen in a brand new project, so it seems that shader graph now performs worse as projects become more complex.

I profiled what was going on when adding a property to some new Shader Graph I made. It resulted in a two back-to-back frames of very long delays. I’ll show the results below, but the expensive part are some called to Shader.EditorCompileVariant:

Note that I haven’t saved the Shader Graph yet, and I don’t have the master preview on. Yet it still appears Unity is recompiling the shader, and this takes a long time.

For comparison, in a brand new project, this doesn’t occur. Adding a property to a shader graph is instantaneous. And in 2019.1, there’s essentially no delay either for this same project, which I’ve only just migrated to 2019.3. My project is fairly large, but under 2019.1, editing a shader graph is very responsive. Now, though, under 2019.3, it’s very sluggish.

Is this a known problem? Is there something I’ve got in my project that’s potentially causing this behavior?

Another annoying thing is that just pressing Space to add a new node to the graph incurs about a 1 second delay. Profiling that, I see this:

This graph has a single HDRP Lit output node in it. Should it really be calling the constructor for all the different output node types every time I add a node to the graph?

If it’s the same problem as what I think it is, this had been reported some time ago in the following thread:

The bug report is here:

I can confirm that in the 9.x.x versions, performance was improved a lot. There still is a wait time when opening/closing large graphs and adding/removing properties, but it is way better than before. Unfortunately, it’s only available in 2020.1 beta versions of Shader Graph, and I don’t know if it’s going to be backported to 2019.3 7.x versions.

I remember reading somewhere that they were addressing the node menu delay as well.

Thanks very much for pointing out that bug. I’ll keep an eye on it. Hopefully that gets backported, as I’ll be staying on 2019.4 LTS for a long time to come.

Bump, this is as bad as ever if not more so in the 2020.2 editor versions. It can take up to a minute at the end when making several changes in a row on a pretty decent rig. This should be a high priority (at worst a third of the day is spent waiting for preview compiles even with every preview closed etc) and i’d imagine a lot of people would certainly want this backported to the previous LTS versions atleast.

Well, that issue claims it’s fixed in 9.x+, so if you’re still seeing an issue you should probably report it, as it might be unrelated to this.