Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Crash when exceeding old shader keyword limit of 64 keywords

Discussion in '2021.2 Beta' started by jbooth, Oct 10, 2021.

  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,432
    Bug #1372050

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

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,819
    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.
     
    jbooth likes this.
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,432
    @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).
     
    Last edited: Nov 14, 2021
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,819
    I'll check this tomorrow.
    I don't think 1372050 reached our team.
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,432
    Thanks!
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,819
    Sorry, this was a mistake with case handling on the QA side. We'll figure it out :)

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

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,432
    @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?
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,819
    @jbooth Toss a coin! :)
    I fixed it properly yesterday. The backport is in flight as well, so it should be there in 2-3 weeks.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,432
    Great!
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,819
    @jbooth the fix will be available in 2022.1.0b1 and 2021.2.6f1 :)
     
    jbooth likes this.