Crash when exceeding old shader keyword limit of 64 keywords

Bug #1372050

Basically, whenever I get much over 64 local/fragment shader keywords, I seem to crash Unity.

FWIW I just checked - a simple test shader with 100 keywords works just fine.

We’ll take a look at the case you submitted after QA finish processing it.

1 Like

@aleksandrk

So this has been fixed in 2022.1a, but is it going to be back ported to 2021 at all? Or will we have a year of Unity versions that crash? One of my releases hits this repro 100% of the time, and I’d hate to have to wait a full year to release an update because of it. Is there a way to work around it?

Also, it appears that mat.shaderKeywords always returns a 0 length array in 2021.2f1. I can see the shader keywords in the debug inspector, but the list is always a 0 length array. I’m uploading a repro project now, but you can easily repro this:

  1. Create a new material
  2. Switch to the debug inspector
  3. Add a keyword “_Foo” to the shaderKeywords array
  4. write a script which Debug.Log(mat.shaderKeywords.Length) and it will always print 0

case 1380745

(It appears that the shader keyword list is now being checked against the shader’s actual keywords, and stripping anything which is not backed by the shader. This breaks megasplat, which uses the keyword list but not backed by shader_features, because it’s got like 700 of them and Unity’s surface shader system explodes at about 15-20. This also prevents you from manually revisioning that list of keywords when doing updates, as keywords magically disappear when the shader changes).

I’ll check this tomorrow.
I don’t think 1372050 reached our team.

Thanks!

Sorry, this was a mistake with case handling on the QA side. We’ll figure it out :slight_smile:

Regarding this one: I’ll wait till QA processes this properly. It may have been broken even before the big keyword changes.

@aleksandrk
Any chance we’re going to see a backport of 1372050 in the 2021 series or will it have to wait an entire year?

@jbooth_1 Toss a coin! :slight_smile:
I fixed it properly yesterday. The backport is in flight as well, so it should be there in 2-3 weeks.

Great!

@jbooth_1 the fix will be available in 2022.1.0b1 and 2021.2.6f1 :slight_smile:

1 Like