Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

M1 Native 2021.2.0b33078.7, Shader Keyword Remapping related crashing, both editor and build

Discussion in '2021.2 Beta' started by anatolyV, Jul 15, 2021.

  1. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Hi, can't provide a repro to file a proper bug report since I haven't yet figured out the definite cause, so I'm in hopes that this is either a known issue or easy to localize.

    Both editor and 'iOS on Mac' build crash with a similar-looking stacktrace, seemingly more likely on scene change. It seems to be related to shader keyword remapping. Happens pretty randomly, sometimes together with shader related changes, sometimes just when it feels like it, but it does happen pretty often. I've made a project with the custom shaders I use and I was enacting the same changes I was in the game build but I couldn't cause a crash. I haven't been able to google anything that makes sense in regards to this issue.

    I hope someone from the Unity team finds the attached stack traces useful.

    I'll try using the same version on Rosetta and see if the issue persists, will update the post.
     

    Attached Files:

  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Hi!
    I don't have a good suggestion on where to look exactly, unfortunately.
    All I can say to help localise this is it can happen only to shaders with fallbacks and UsePass.

    It would be really great if you found a good repro for this - I haven't seen this happen elsewhere.
     
    anatolyV likes this.
  3. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Thanks for the tips. Still happens on b4, I'll be looking harder for a repro as this is a game-breaking bug for me. In the meantime, I could attach the repro attempt as it is right now (no crash) with the custom shaders I'm using. Would that be useful at all?
     
  4. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Do they have to contain both UsePass and fallbacks or just either of them? The only shaders with UsePass in the project are the ones from TerrainTools, and I'm not sure they'd even be loaded in playmode/build.
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Either. This particular message means that somehow it ended up in a state when it has no data to convert keywords between a shader and either its fallback or a shader usepass comes from.
    Please submit a bug report and ask QA to help you figure out, what triggers this condition.
     
    anatolyV likes this.
  6. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Thanks for the info. I've tried removing all the UsePass-having shaders from the project, and also pruning fallbacks from my own shaders, made no difference, still crashing. Could be a third-party one with fallback causing this. Could references to '4Pass' in the stack trace mean that this is a terrain shader?

    Also I've submitted a bug report, case #1350950.
     
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    No, that's just a mangled function name.

    Thank you for the bug report!
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Seems like a good idea to add info on which shader causes the issue, though :D
     
  9. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    I would if I knew that lol. Like I said I've tried screwing around with the shaders I have and I haven't been able to repro the crash.
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    That's a good idea for me to add this info when bad things happen :D
     
  11. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    If I figure out which shader is causing the issue, I'll post it here. So far I haven't been able to figure that out. I had removed fallbacks from all of my own custom shaders, as well as removing any UsePass ones from the project as a test and it still crashed in the same way.

    Update: removed ALL fallbacks and still got the same crash. Probably one of the built-in UI or Terrain Standard shaders then.
     

    Attached Files:

    Last edited: Jul 16, 2021
  12. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63

    Attached Files:

  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    The messages are likely related, but not the issue you linked, it was fixed in 2021.2.0a18 :)
     
  14. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Okay, got another clue - crash doesn't happen when shadows are off (distance set to 0). I then increased the shadow distance and once the shadow distance covered a particular object, the editor crashed. Is this helpful? I'll keep digging.

    Edit: Iteration time on this issue would be much faster if not for this issue lol https://forum.unity.com/threads/m1-...setcache-each-time-the-project-loads.1149857/

    Edit2: I turned off all the sub-objects of the offending object, and when turning them on one by one, it crashes on random ones inconsistently between each run. Tends to happen more when enabling groups of meshes rather than a particular one. I'll try to recreate this in a repro but I don't feel like it'll work.

    Edit3: Yeah I stuck the same model with the same materials and similar lighting, same ProjectSettings, into a new project and I'm not able to get it to crash.
     
    Last edited: Aug 2, 2021
  15. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I had issues with shader-related exceptions preventing builds after going from 2021.2 alpha to beta. It wasn't crashing the editor but maybe this will help someone with problems like I had. What I did that solved it (..good idea to back up your project before trying), in Project Settings->Graphics, first clear every shader out of "Always Included Shaders". Then hit "Clear" on the "Currently tracked" shaders at the very bottom. Then play your game, go to whatever scenes so your shaders get exposed, toggle any in-game graphics options on/off (like shadows for example). Then before you exit play mode, click the "Save to asset" button. Then add the Shader Variant Collection you've just saved to "Preloaded shaders". After doing this, everything worked again without exceptions. Also note, you can click the Shader Variant Collection asset, then in the Inspector you can add and remove whatever if you want to (vs. going through the entire process again just for a small change).
     
  16. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @aVolnov 2021.2.0b8 is out - it has extra logging in a place that searches for a keyword remapping table. Can you please try to run with the new version and see if there's any new info in the log?
     
  17. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Hi, just got a crash with b8 and indeed it's now pointing at a shader at least:

    No keyword remapping data found. Source shader Legacy Shaders/Diffuse, destination shader Legacy Shaders/VertexLit.


    Attaching a bigger chunk of the log around it and the stack trace just in case.
     

    Attached Files:

  18. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Could you please send me a full log from the Editor?
    You can do so in DM if you don't want to attach it to a public thread.

    I don't see any mention of these two shaders in the log that is attached to the bug report, save for compilation.
     
  19. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    That's on line 68 of the 'editor log for shader crash' file. I'll post or DM you a full log once the crash happens again, didn't save the full one from this crash unfortunately.
     
  20. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Well, yes, apart from the expected message :D
    I saw the one on line 68 :)
     
    anatolyV likes this.
  21. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @aVolnov OK, I think I know what the issue is. The shadow rendering code path can in rare cases have a hash collision, and end up trying to render with a pass that doesn't belong to the shader provided.
    Before the keyword system update in 2021.2 this would just result in incorrect rendering, now it's, fortunately, a crash, so I can attempt to fix it.
     
  22. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    A potential fix is going to available in 2021.2.0b12. If all goes well, it's going to be released around Sep 15th.
     
  23. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @aVolnov Beta 12 is now available. Please check if it fixes your issue :)
    Thank you!
     
  24. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Hi, thanks for the fix and the update. I haven't been able to play around on b12-b13 too much due to the domain reloading issue (Unity 2021.2.b12+13: Script domain reload does not work). Quite annoying to have to force a script recompile each time I want to enter play mode. But the ~10 or so times I did so, I enabled shadows and it didn't crash out so that's good. Once the domain reloading issue is fixed (fingers crossed for b14) I'll test this out properly.
     
    aleksandrk likes this.
  25. sS_Naomichi

    sS_Naomichi

    Joined:
    Oct 28, 2020
    Posts:
    13
    @aleksandrk

    Hi.

    It seems that this issue is still happening.
    ShaderVariantCollection.WarmUp causes the crash when using a shader contains "UsePass".

    I tried report a bug (Case 1425801) in Unity 2021.2.19 with URP 12.1.6, and it also happened in Unity 2021.3.1.

    Here is a editor log when a crash occurs.

    Code (CSharp):
    1.  
    2. No keyword remapping data found. Source shader Test/Unlit, destination shader Universal Render Pipeline/Unlit.
    3. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    4. SVCWarmUpper:Start () (at Assets/SVCWarmUpper.cs:12)
    5.  
    6. [Assets/SVCWarmUpper.cs line 12]
    7.  
    8.  
    9. =================================================================
    10.     Native Crash Reporting
    11. =================================================================
    12. Got a UNKNOWN while executing native code. This usually indicates
    13. a fatal error in the mono runtime or one of the native libraries
    14. used by your application.
    15. =================================================================
    16.  
    17. =================================================================
    18.     Managed Stacktrace:
    19. =================================================================
    20.       at <unknown> <0xffffffff>
    21.       at UnityEngine.ShaderVariantCollection:WarmUp <0x00140>
    22.       at SVCWarmUpper:Start <0x0008a>
    23.       at System.Object:runtime_invoke_void__this__ <0x00187>
    24. =================================================================
    25. Received signal SIGSEGV
    26. Obtained 34 stack frames
    27. 0x00007ff640c10cb1 (Unity) ShaderLab::Program::GetMatchingSubProgram
    28. 0x00007ff640c174ec (Unity) ShaderLab::ShaderState::FindSubProgramsToUse
    29. 0x00007ff640c16086 (Unity) ShaderLab::ShaderState::ApplyShaderState
    30. 0x00007ff640c083d7 (Unity) ShaderLab::Pass::ApplyPass
    31. 0x00007ff640bf0dbe (Unity) DrawVBOChunkWithPass
    32. 0x00007ff640bfab5b (Unity) ShaderVariantCollection::WarmupOneShaderImpl
    33. 0x00007ff640bfb3da (Unity) ShaderVariantCollection::WarmupShadersImpl
    34. 0x00007ff640bfae68 (Unity) ShaderVariantCollection::WarmupShaders
    35. 0x00007ff6400df356 (Unity) ShaderVariantCollection_CUSTOM_WarmUp
    36. 0x000002de6fa4b551 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.ShaderVariantCollection:WarmUp (UnityEngine.ShaderVariantCollection)
    37. 0x000002de6fa4b3ab (Mono JIT Code) [SVCWarmUpper.cs:12] SVCWarmUpper:Start ()
    38. 0x000002ddf96f84c8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    39. 0x00007ffac2ace0a4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
    40. 0x00007ffac2a0e744 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
    41. 0x00007ffac2a0e8dc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
    42. 0x00007ff640e1f454 (Unity) scripting_method_invoke
    43. 0x00007ff640e1a074 (Unity) ScriptingInvocation::Invoke
    44. 0x00007ff640dee5d2 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
    45. 0x00007ff640dee708 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
    46. 0x00007ff640de8d32 (Unity) MonoBehaviour::DelayedStartCall
    47. 0x00007ff6408e9d04 (Unity) DelayedCallManager::Update
    48. 0x00007ff640af8d89 (Unity) `InitPlayerLoopCallbacks'::`2'::EarlyUpdateScriptRunDelayedStartupFrameRegistrator::Forward
    49. 0x00007ff640ae06bc (Unity) ExecutePlayerLoop
    50. 0x00007ff640ae0793 (Unity) ExecutePlayerLoop
    51. 0x00007ff640ae63d9 (Unity) PlayerLoop
    52. 0x00007ff641a27ac8 (Unity) PlayerLoopController::UpdateScene
    53. 0x00007ff641a137e4 (Unity) PlayerLoopController::EnterPlayMode
    54. 0x00007ff641a22b37 (Unity) PlayerLoopController::SetIsPlaying
    55. 0x00007ff641a25f3d (Unity) Application::TickTimer
    56. 0x00007ff641e6e10a (Unity) MainMessageLoop
    57. 0x00007ff641e729db (Unity) WinMain
    58. 0x00007ff64319427e (Unity) __scrt_common_main_seh
    59. 0x00007ffb57817034 (KERNEL32) BaseThreadInitThunk
    60. 0x00007ffb58442651 (ntdll) RtlUserThreadStart
    61.  
    Regards.
     
    Last edited: May 6, 2022
  26. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
  27. sS_Naomichi

    sS_Naomichi

    Joined:
    Oct 28, 2020
    Posts:
    13
    @aleksandrk

    Oh, I had overlooked it.
    I hope that changes will be merged soon.
    Thanks!