Shader Graph_SearchWindowProvider: Create node causes null reference exception error

Hi,

I have recently started getting a null reference exception error when trying to add nodes to shader graph.

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.Drawing.SearchWindowProvider.GenerateNodeEntries () (at ./Library/PackageCache/com.unity.shadergraph@14.0.5/Editor/Drawing/SearchWindowProvider.cs:79)

Line 79:

bool hideCustomInterpolators = m_Graph.activeTargets.All(at => at.ignoreCustomInterpolators);

This is consistently occurring when trying to use the space bar shortcut and regularly occurring when using right click > create node. Sometimes restarting shader graph or unity seems to temporarily resolve the issue.

I’ve not touched Shader Graph package code. Is this a bug?

I am using:

  • Unity 2022.2.3f1
  • URP 14.05
  • Shader Graph 14.05

The full console print:

1 Like

I have this issue as well on 14.04. Not sure what causes it. I can close and then reopen the graph, but the bug always comes back, making Shader Graph nearly unusable.

I also have this issue.

Play mode might be causing this.
I also noticed that the Fullscreen options are missing from the Game window in this version.

Weirdly, sometimes it’s only the spacebar that triggers this bug, not the right mouse button menu.

  • Unity 2022.2.4f1
  • URP 14.05
  • Shader Graph 14.05

Downgraded Unity and now everything is working:

  • Unity 2022.2.0f1
  • URP 14.04
  • Shader Graph 14.04

Also, the Game window has Fullscreen options again in this downgraded version. (And there is Display Settings tab in Preferences).

Good to know that it is not just me.

Yes, I’m finding that it is specifically exiting play mode that seems to trigger the issue. I can edit the graph during play mode but as soon as I exit play mode I consistently get the null reference exception.

1 Like

I also have the same issue and have reported it to Unity with a simple reproducible project.

  • Reproduced with Unity 2022.2.5f1 and 2022.2.7f1
2 Likes

Same, 2022.2.6

1 Like

I get this a lot in 2022.2.8f1 as well (I think it started in 2022.2.5f1)
It’s not a 100% repro, and seems to relate to which objects are selected.

Workaround is to close and reopen the graph, one or two steps of work as well as the view positon will be lost even if you save on closing, which makes this quite jarring.

I tried to fiddle with searcher features, but to no avail. They seem to be unrelated, despite the name. So some more defensive programming here would be much appreciated, a single activeTarget that becomes null must never soft-lock the user out of any meaningful interaction with the entirety of ShaderGraph.

I’m considering working around the issue by adding some exception handling to the crashing code, but rolling custom RP package is always a hassle.

Edit: In fact, the patch would be in the ShaderGraph package, but I can’t turn that into a custom package for some magical reason (totally breaks all shadergraphs, won’t reimport). Would be offtopic, but moving this to Packages from Package Cache doesn’t work, which is weird. Aren’t packages supposed to be, you know, like packages?

Edit2: Had to reimport all shadergraphs that were DefaultAssets now for some reason, then reimport all custom subgraphs from another package, and then all of my shadergraphs again.

I got a reply from the Unity team after submitting a bug report. It seems to be fixed in 16.0.0 and under consideration in 14.0.x and 15.0.x.

Issue Tracker is here:

1 Like