Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug SRPBatcher ignores UsePass for ShaderLab shaders (2021.3.11f1)

Discussion in 'Universal Render Pipeline' started by ElliotB, Oct 24, 2022.

  1. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Hi,

    In 2021.3.11f1, SRPBatcher fails to render shaders that include forward render passes through USEPASS. As far as I am aware, this behavior was working in 2021.3.6f1, so the issue is relatively new.

    Simple test case:

    I create two shader lab materials. One defines a universal pipeline forward renderer pass to output a color property (dotted with face normals). The other does nothing but declare the property and USEPASS to include this pass.

    ShaderLabShader:
    Code (csharp):
    1. Shader "Bugs/ShaderLabShader"
    2. {
    3.     Properties
    4.     {
    5.         _Color("Color", Color) = (1, 1, 1, 1)
    6.     }
    7.  
    8.     SubShader{
    9.         Tags{
    10.             "RenderType" = "Opaque"
    11.             "RenderPipeline" = "UniversalPipeline"
    12.         }
    13.  
    14.         Pass{
    15.             Name "Universal Forward"
    16.             Tags
    17.             {
    18.                 "LightMode" = "UniversalForward"
    19.             }
    20.  
    21.             Cull Off
    22.             ZWrite On
    23.             ZTest On
    24.             Blend Off
    25.  
    26.             HLSLPROGRAM
    27.             #pragma vertex vert
    28.             #pragma fragment frag
    29.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
    30.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    31.  
    32.             CBUFFER_START(UnityPerMaterial)
    33.             float4 _Color;
    34.             CBUFFER_END
    35.  
    36.             uniform sampler2D _MainTex;
    37.             float4 _MainTex_TexelSize;
    38.  
    39.             struct v2f {
    40.                 float4 pos : SV_POSITION;
    41.                 float4 scrPos:TEXCOORD1;
    42.                 float3 normal : NORMAL;
    43.             };
    44.  
    45.             struct appdata_base
    46.             {
    47.                 float4 vertex   : POSITION;  // The vertex position in model space.
    48.                 float3 normal   : NORMAL;    // The vertex normal in model space.
    49.                 float4 texcoord : TEXCOORD0; // The first UV coordinate.
    50.             };
    51.  
    52.             v2f vert(appdata_base v) {
    53.                 v2f o;
    54.                 o.pos = TransformObjectToHClip(v.vertex.xyz);
    55.                 o.scrPos = ComputeScreenPos(o.pos);
    56.                 o.normal = v.normal;
    57.                 return o;
    58.             }
    59.  
    60.             void frag(v2f i, out float4 color: COLOR) {
    61.                 color = dot(i.normal, float3(0.2, 0.7, 0.2)) * _Color;
    62.             }
    63.         ENDHLSL
    64.         }
    65.     }
    66. }
    67.  
    UsePassFromShaderLab:
    Code (csharp):
    1. Shader "Bugs/UsePassFromShaderLab"
    2. {
    3.     Properties
    4.     {
    5.         _Color("Color", Color) = (1, 1, 1, 1)
    6.     }
    7.    
    8.     SubShader
    9.     {
    10.         Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
    11.         UsePass "Bugs/ShaderLabShader/UNIVERSAL FORWARD"
    12.     }
    13. }
    14.  
    I create a test scene with eight cubes. Four use a material with the first shader, four use a material with the second shader. I set the color properties of these to blue and green, to differentiate the two groups of objects.

    upload_2022-10-24_17-41-22.png


    Results of the test:

    With the SRPBatcher enabled (default settings) I see only the green objects (which use the first 'ShaderLabShader'), and the USEPASS shader objects are invisible.
    upload_2022-10-24_17-27-22.png

    I use the Inspector in debug mode to disable the SRPBatcher on the render pipeline asset. After doing so, the other group of objects (which use the UsePassFromShaderLab shader) appear.
    upload_2022-10-24_17-29-31.png

    It is clear from this that the SRPBatcher is failing to draw shaders that USEPASS to include a forward renderer pass. The shaders are marked as 'compatible with the SRPBatcher', but the behavior is different with/without the SRPBatcher enabled.

    To confuse matters further, sometimes with the SRPBatcher on I see the blue objects rendered, but all at the scene origin - as if the transforms are off (I guess there's a local to world matrix being set incorrectly?) In other projects (with a more complicated setup) I've noticed what looks like CBUFFERs going out of sync, with object colors flickering, positions being off, etc.

    upload_2022-10-24_17-43-46.png

    Any thoughts greatly appreciated,

    Cheers,
    Elliot
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    It would be great if you could report a bug.
    Thanks!
     
  3. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Thanks aleksandrk, bug and files submitted as IN-20904 (also references this thread).

    There's also a SRPBatcher crash bug but I'll make a separate report for that (as soon as I have a minimal test case)
     
    aleksandrk likes this.
  4. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    More info: the behavior of this bug seems non-deterministic. I opened up the example today, and now it works with the SRPBatcher; I can clearly see the two shaders below:
    upload_2022-10-25_10-27-53.png

    I tried a few things to see if I could trigger it again, most were unsuccessful:

    Disabling/Enabling the SRPBatcher seems to have no effect. Project Settings -> Graphicsshows 18 shaders, 20 total variants being tracked.

    I disabled all cubes in the scene, save and then re-open unity. There's now 16 shaders, 17 total variants being tracked. I then re-enable them and the scene works as before. Now at 17 shaders, 18 total variants with all cubes on the scene.

    So I keep poking to see if I can trigger the bug. I did the same approach as above, but using a ShaderGraph shader; I make a simple ShaderGraph that just outputs the color property to the surface color. I added it to the scene and it displays fine. I then make a ShaderLab shader that exploits USEPASS to take the forward rendering pass from the ShaderGraph:
    Code (csharp):
    1.  
    2. Shader "Bugs/Test"
    3. {
    4.     Properties
    5.     {
    6.         [MainColor] _Color("Color", Color) = (1, 1, 1, 1)
    7.         [HideInInspector]_QueueOffset("_QueueOffset", Float) = 0
    8.         [HideInInspector]_QueueControl("_QueueControl", Float) = -1
    9.         [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
    10.         [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
    11.         [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
    12.     }
    13.    
    14.         SubShader
    15.     {
    16.         Tags
    17.         {
    18.             "RenderPipeline" = "UniversalPipeline"
    19.             "RenderType" = "Opaque"
    20.             "UniversalMaterialType" = "Lit"
    21.             "Queue" = "Geometry"
    22.             "ShaderGraphShader" = "true" // Not sure if this does anything?
    23.             "ShaderGraphTargetId" = "UniversalLitSubTarget"
    24.         }
    25.  
    26.         UsePass "Bugs/TestGraph/UNIVERSAL FORWARD"
    27.         UsePass "Bugs/TestGraph/SHADOWCASTER"
    28.         UsePass "Bugs/TestGraph/DEPTHONLY"
    29.         UsePass "Bugs/TestGraph/DEPTHNORMALS"
    30.     }
    31. }
    32.  
    At this point the error crashes out:
    Code (csharp):
    1.  
    2. Obtained 88 stack frames
    3. 0x00007ff610a87a1e (Unity) malloc_internal
    4. 0x00007ff610f0c4c5 (Unity) keywords::LocalKeywordState::Resize
    5. 0x00007ff610f180ce (Unity) ShaderLab::Program::GetMatchingSubProgram
    6. 0x00007ff610f103a7 (Unity) ShaderLab::Pass::ComputePassValuesHash
    7. 0x00007ff610ee8ee3 (Unity) Material::UpdateHashes
    8. 0x00007ff610edb92c (Unity) Material::BuildProperties
    9. 0x00007ff610ee1e5a (Unity) Material::HasProperty
    10. 0x00007ff61036179f (Unity) Material_CUSTOM_HasProperty
    11. 0x000002b3018eb72c (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Material:HasProperty (UnityEngine.Material,int)
    12. 0x000002b420ce5cbb (Mono JIT Code) UnityEngine.Material:HasProperty (string)
    13. 0x000002b420e5406b (Mono JIT Code) UnityEditor.Utils.PerformanceChecks:CheckMaterial (UnityEngine.Material,UnityEditor.BuildTarget)
    14. 0x000002b420e5327b (Mono JIT Code) UnityEditor.MaterialEditor:PropertiesChanged ()
    15. 0x000002b420e52f13 (Mono JIT Code) UnityEditor.MaterialEditor:OnEnable ()
    16. 0x000002b3524ca838 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    17.  
    Anyway, after reopening the scene looks fine - I have all objects being correctly rendered

    upload_2022-10-25_10-40-58.png

    Finally triggering the error

    Still continuing to poke around, I made a minor change to the ShaderGraph (e.g. set smoothness from 0.5 to 1) and saved it. The plan was just to force the graph to recompile - which it did. The red cube flashes during recompilation of the shader, but the scene is otherwise the same and displays as before.

    However, the ShaderLab shader that incorporates the USEPASS from SG won't have been updated, because Unity doesn't automatically recompile/rebuild shaders that USEPASS when the underlying shader is changed. With this in mind, I then right click and reimport the ShaderLab shader that USEPASS's the ShaderGraph shader. As soon as I do the error appears:

    upload_2022-10-25_10-45-43.png

    Note that in the above image, all of the USEPASS shaders have been corrupted. Both USEPASS shaders (blue and yellow in previous pic) appear to have lost the color information, and render as if the transform is missing (on the origin). Note that regarding color information, it's hard to tell if its both shaders losing the color property because there could also be one shader rendered over the other, they are all at the same location.

    In this case, closing and reopening the project was sufficient to fix the issue (unlike yesterday).

    With the scene reloaded and working, it says 19 shaders 22 total variants. I saved this into a shader variant asset, and then triggered the break again (changing and resaving the shadergraph shader). Unity crashes (again) and when I reload it, the USEPASS shader is rendering in the right place, but the wrong color (so the symptom can change each time):
    upload_2022-10-25_10-54-37.png

    For instance, in some cases all USEPASS shaders just disappear from the scene - they don't even appear at the origin (No screenshot because image limit reached :( ). As before, if I disable the SRPBatcher the scene appears correctly.

    Graphics tab now reads 19 shaders, 23 total variants (+1 more than before, but as far as I can see it's just now also using a mainlight shadow cascade variant). Looking at the variants, I see the ShaderLab (which USEPASS from the SG) has PassType 13 with no keywords, whereas the SG has PassType 13 with and without keywords and also PassType 8:
    upload_2022-10-25_11-0-16.png
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Thank you very much for the deep investigation!
     
  6. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Hi @aleksandrk, I reported this as IN-20904, but I think the ticket got stuck! I never got anything more than 'New Incident created'. The status can be checked via this link ( https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-20904 ), but I can't authenticate any credentials to see the status.

    I also reported IN-20982 (a related crash bug involving the SRPBatcher), which was closed as Not Qualified, and IN-21134 (another crash bug on SRPBatcher, for GL), which was closed as duplicate (of this issue https://issuetracker.unity3d.com/is...-drawbuffersbatchmode-when-entering-play-mode).

    I'm still getting frequent crashes on the SRPBatcher, the crashes don't occur if I roll back to 2021.3.6f1. Do you have any suggestions/workarounds to avoid SRPBatcher crashes while these issues are still live?

    Thanks!
     
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    IN-21134 is waiting to be investigated. Asked about the other two :)
     
  8. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Thanks very much!

    One crash occurs for OpenGL only, the other occurs on all platforms (but occurs unreliably, in that rerunning the same actions doesn't guarantee it to occur). If you give it ten minutes it does occur, and seems related to SRPBatcher doing a bad allocation:
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    No, "BatchAllocator" is a different beast :)
    If you open / attach the Editor.log, it should show, where the crash happens.
     
  10. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    I'll reply with more info when I'm back at my PC, for now this is an example of a log I had from before:

    Code (csharp):
    1. Obtained 77 stack frames
    2. 0x00007ff6047239fa (Unity) ScriptableBatchRenderer::ApplyShaderPass
    3. 0x00007ff60473b5b9 (Unity) ScriptableRenderLoopDrawSRPBatcher
    4. 0x00007ff60473b8b5 (Unity) ScriptableRenderLoopJob
    5. 0x00007ff604a42a33 (Unity) GfxDevice::ExecuteAsync
    6. 0x00007ff604ce279c (Unity) GfxDeviceClient::ExecuteAsync
    7. 0x00007ff604739d08 (Unity) ScheduleRenderJobs
    8. 0x00007ff6047369e6 (Unity) ExecuteDrawRenderersCommand
    9. 0x00007ff604726a7b (Unity) ScriptableRenderContext::ExecuteScriptableRenderLoop
    10. 0x00007ff603db9faf (Unity) ScriptableRenderContext_CUSTOM_Submit_Internal_Injected
    11. 0x000001c6e2a9770a (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal_Injected (UnityEngine.Rendering.ScriptableRenderContext&)
    12. 0x000001c6e2a9763b (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal ()
    13. 0x000001c6e2a975d3 (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit ()
    14. 0x000001c9da1eed03 (Mono JIT Code) [UniversalRenderPipeline.cs:432] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData,bool)
    15. 0x000001c6e2bc138b (Mono JIT Code) [UniversalRenderPipeline.cs:325] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    16. 0x000001c9da1d91fb (Mono JIT Code) [UniversalRenderPipeline.cs:281] UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>)
    17. 0x000001c9da1d8829 (Mono JIT Code) UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>)
    18. 0x000001c9da1b3273 (Mono JIT Code) UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    19. 0x000001c9da1b34d8 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr)
    20. 0x00007ffb0594fe24 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
    21. 0x00007ffb0588e764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
    22. 0x00007ffb0588e8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
    23. 0x00007ff604af7614 (Unity) scripting_method_invoke
    24. 0x00007ff604ad6eb4 (Unity) ScriptingInvocation::Invoke
    25. 0x00007ff604728a7f (Unity) ScriptableRenderContext::ExtractAndExecuteRenderPipeline
    26. 0x00007ff60453d643 (Unity) Camera::CustomRenderWithPipeline
    27. 0x00007ff604552b4f (Unity) Camera::StandaloneCustomRender
    28. 0x00007ff604552da8 (Unity) Camera::StandaloneRender
    29. 0x00007ff604549e2f (Unity) CameraScripting::Render
    30. 0x00007ff603d381d4 (Unity) Camera_CUSTOM_Render
    31. 0x000001c6e3a8aa71 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Camera:Render (UnityEngine.Camera)
    32. 0x000001c6e3a8a2bb (Mono JIT Code) UnityEditor.PreviewRenderUtility:Render (bool,bool)
    33. 0x000001c6e3a88f0b (Mono JIT Code) UnityEditor.MaterialEditor:DoRenderPreview (UnityEditor.PreviewRenderUtility,bool)
    34. 0x000001c6e3a7974b (Mono JIT Code) UnityEditor.MaterialEditor:DefaultPreviewGUI (UnityEngine.Rect,UnityEngine.GUIStyle)
    35. 0x000001c6e3a792cb (Mono JIT Code) UnityEditor.ShaderGUI:OnMaterialPreviewGUI (UnityEditor.MaterialEditor,UnityEngine.Rect,UnityEngine.GUIStyle)
    36. 0x000001c6e3a791f6 (Mono JIT Code) UnityEditor.MaterialEditor:OnPreviewGUI (UnityEngine.Rect,UnityEngine.GUIStyle)
    37. 0x000001c6e3a79163 (Mono JIT Code) UnityEditor.MaterialEditor:OnHeaderIconGUI (UnityEngine.Rect)
    38. 0x000001c6e3a77319 (Mono JIT Code) UnityEditor.Editor:DrawHeaderGUI (UnityEditor.Editor,string,single)
    39. 0x000001c6e3a76603 (Mono JIT Code) UnityEditor.MaterialEditor:OnHeaderGUI ()
    40. 0x000001c6e2c1f4d9 (Mono JIT Code) UnityEditor.Editor:DrawHeader ()
    41. 0x000001c6e2c1f26b (Mono JIT Code) UnityEditor.UIElements.EditorElement:DrawEditorLargeHeader (UnityEditor.Editor[],bool&)
    42. 0x000001c6e2c1ed93 (Mono JIT Code) UnityEditor.UIElements.EditorElement:DrawEditorHeader (UnityEditor.Editor[],UnityEngine.Object,bool&)
    43. 0x000001c6e2c2f35b (Mono JIT Code) UnityEditor.UIElements.EditorElement:HeaderOnGUI ()
    44. 0x000001c6e26750ff (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    45. 0x000001c6e26743cb (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    46. 0x000001c6e271edab (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint ()
    47. 0x000001c6e271c784 (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&)
    48. 0x000001c6e271aac3 (Mono JIT Code) UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&)
    49. 0x000001c6e2714e53 (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChain:Render ()
    50. 0x000001c6e26f5d93 (Mono JIT Code) UnityEngine.UIElements.UIRRepaintUpdater:Update ()
    51. 0x000001c6e25f66be (Mono JIT Code) UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase)
    52. 0x000001c6e26f54ab (Mono JIT Code) UnityEngine.UIElements.Panel:UpdateForRepaint ()
    53. 0x000001c6e26f3c3b (Mono JIT Code) UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event)
    54. 0x000001c6e25f5f1f (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    55. 0x000001c6e25f5c33 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    56. 0x000001c6e25f59ef (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
    57. 0x000001c6e25f590b (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    58. 0x000001c6e25f576d (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    59. 0x000001c6e25f5826 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    60. 0x00007ffb0594fe24 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
    61. 0x00007ffb0588e764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
    62. 0x00007ffb0588e8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
    63. 0x00007ff604af7614 (Unity) scripting_method_invoke
    64. 0x00007ff604ad6eb4 (Unity) ScriptingInvocation::Invoke
    65. 0x00007ff604ad1ac5 (Unity) ScriptingInvocation::Invoke<void>
    66. 0x00007ff604bf411a (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
    67. 0x00007ff60562f5e8 (Unity) GUIView::ProcessRetainedMode
    68. 0x00007ff605b7a31b (Unity) GUIView::OnInputEvent
    69. 0x00007ff60562f3fa (Unity) GUIView::ProcessInputEvent
    70. 0x00007ff605b7314e (Unity) GUIView::DoPaint
    71. 0x00007ff605b7c55d (Unity) GUIView::RepaintAll
    72. 0x00007ff605703067 (Unity) PlayerLoopController::UpdateScene
    73. 0x00007ff60570106f (Unity) Application::TickTimer
    74. 0x00007ff605b4ff5a (Unity) MainMessageLoop
    75. 0x00007ff605b5480b (Unity) WinMain
    76. 0x00007ff606ee20ce (Unity) __scrt_common_main_seh
    77. 0x00007ffbc73d7034 (KERNEL32) BaseThreadInitThunk
    78. 0x00007ffbc75226a1 (ntdll) RtlUserThreadStart
    The exact stack for that error dialog is below. The BatchAllocator throws the error, but the SRPBatcher is still involved according to the stack:
    Code (csharp):
    1. 0x00007FF8C2DE4F69 (KERNELBASE) RaiseException
    2. 0x00007FF7AD2817AF (Unity) LaunchBugReporter
    3. 0x00007FF7ACC59DE2 (Unity) EditorMonoConsole::LogToConsoleImplementation
    4. 0x00007FF7ACC5A73D (Unity) EditorMonoConsole::LogToConsoleImplementation
    5. 0x00007FF7AD8FD5A7 (Unity) DebugStringToFilePostprocessedStacktrace
    6. 0x00007FF7AD8FCCFD (Unity) DebugStringToFile
    7. 0x00007FF7ABAFC3EE (Unity) MemoryManager::OutOfMemoryError
    8. 0x00007FF7ABAF5D9D (Unity) MemoryManager::Allocate
    9. 0x00007FF7ABAF5A6F (Unity) MemoryManager::Allocate
    10. 0x00007FF7ABAFFEAE (Unity) malloc_internal
    11. 0x00007FF7ABB06A29 (Unity) BatchAllocator::Commit
    12. 0x00007FF7ABDE243F (Unity) ScriptableBatchRenderer::RenderMultipleMeshes
    13. 0x00007FF7ABDDB5BA (Unity) ScriptableBatchRenderer::Flush
    14. 0x00007FF7ABDEE4CD (Unity) ScriptableRenderLoopDrawSRPBatcher
    15. 0x00007FF7ABDEE935 (Unity) ScriptableRenderLoopJob
    16. 0x00007FF7AC108723 (Unity) GfxDevice::ExecuteAsync
    17. 0x00007FF7AC3ADEEC (Unity) GfxDeviceClient::ExecuteAsync
    18. 0x00007FF7ABDEC688 (Unity) ScheduleRenderJobs
    19. 0x00007FF7ABDE93E6 (Unity) ExecuteDrawRenderersCommand
    20. 0x00007FF7ABDD860B (Unity) ScriptableRenderContext::ExecuteScriptableRenderLoop
    21. 0x00007FF7AB366EB9 (Unity) ScriptableRenderContext_CUSTOM_Submit_Internal_Injected
    22. 0x0000021A1A2E8AFA (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal_Injected (UnityEngine.Rendering.ScriptableRenderContext&)
    23. 0x0000021A1A2E8A2B (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal ()
    24. 0x0000021A1A2E89C3 (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit ()
    25. 0x0000021A1828414B (Mono JIT Code) [G:\Unity Projects\ProPixelizer_2022\Library\PackageCache\com.unity.render-pipelines.universal@13.1.8\Runtime\UniversalRenderPipeline.cs:449] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData,bool)
    26. 0x0000021A1A36161B (Mono JIT Code) [G:\Unity Projects\ProPixelizer_2022\Library\PackageCache\com.unity.render-pipelines.universal@13.1.8\Runtime\UniversalRenderPipeline.cs:339] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    27. 0x0000021A1750D3C3 (Mono JIT Code) [G:\Unity Projects\ProPixelizer_2022\Library\PackageCache\com.unity.render-pipelines.universal@13.1.8\Runtime\UniversalRenderPipeline.cs:295] UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>)
    28. 0x0000021A1750C9B9 (Mono JIT Code) UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>)
    29. 0x0000021A17487C93 (Mono JIT Code) UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    30. 0x0000021A17487EF8 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr)
    31. 0x00007FF84FB802F4 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke
    32. 0x00007FF84FABEB34 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3066] do_runtime_invoke
    33. 0x00007FF84FABECCC (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3113] mono_runtime_invoke
    34. 0x00007FF7AC1BF114 (Unity) scripting_method_invoke
    35. 0x00007FF7AC19EA64 (Unity) ScriptingInvocation::Invoke
    36. 0x00007FF7ABDDA63F (Unity) ScriptableRenderContext::ExtractAndExecuteRenderPipeline
    37. 0x00007FF7ADC91A59 (Unity) Camera::ExecuteCustomRenderPipeline
    38. 0x00007FF7ADC94615 (Unity) Camera::RenderEditorCamera
    39. 0x00007FF7ADC95F83 (Unity) Camera::RenderEditorCamera
    40. 0x00007FF7AB7E7440 (Unity) Handles_CUSTOM_Internal_DrawCameraWithGrid
    41. 0x0000021A1A86CB98 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.Handles:Internal_DrawCameraWithGrid (UnityEngine.Camera,UnityEditor.DrawCameraMode,UnityEditor.DrawGridParameters&,bool,bool)
    42. 0x0000021A1A862DE3 (Mono JIT Code) UnityEditor.Handles:DrawCameraImpl (UnityEngine.Rect,UnityEngine.Camera,UnityEditor.DrawCameraMode,bool,UnityEditor.DrawGridParameters,bool,bool,bool,UnityEngine.GameObject[])
    43. 0x0000021A1A862863 (Mono JIT Code) UnityEditor.Handles:DrawCameraStep1 (UnityEngine.Rect,UnityEngine.Camera,UnityEditor.DrawCameraMode,UnityEditor.DrawGridParameters,bool,bool)
    44. 0x0000021A1A85FB13 (Mono JIT Code) UnityEditor.SceneView:DoDrawCamera (UnityEngine.Rect,UnityEngine.Rect,bool&)
    45. 0x0000021A1A853D5B (Mono JIT Code) UnityEditor.SceneView:DoOnGUI ()
    46. 0x0000021A1A8530FB (Mono JIT Code) UnityEditor.SceneView:OnSceneGUI ()
    47. 0x00000219910238A7 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    48. 0x0000021991022B7B (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    49. 0x0000021A1740B07B (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint ()
    50. 0x0000021A174094AC (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&)
    51. 0x0000021A17407B7B (Mono JIT Code) UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&)
    52. 0x0000021A174047D3 (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChain:Render ()
    53. 0x0000021A17131713 (Mono JIT Code) UnityEngine.UIElements.UIRRepaintUpdater:Update ()
    54. 0x0000021991003E5E (Mono JIT Code) UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase)
    55. 0x0000021A17106CDB (Mono JIT Code) UnityEngine.UIElements.Panel:UpdateForRepaint ()
    56. 0x0000021A171054EB (Mono JIT Code) UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event)
    57. 0x000002199100358C (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    58. 0x0000021991003233 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    59. 0x0000021991002FEF (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
    60. 0x0000021991002F0B (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    61. 0x0000021991002D6D (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    62. 0x0000021991002E26 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    63. 0x00007FF84FB802F4 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke
    64. 0x00007FF84FABEB34 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3066] do_runtime_invoke
    65. 0x00007FF84FABECCC (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3113] mono_runtime_invoke
    66. 0x00007FF7AC1BF114 (Unity) scripting_method_invoke
    67. 0x00007FF7AC19EA64 (Unity) ScriptingInvocation::Invoke
    68. 0x00007FF7AC199685 (Unity) ScriptingInvocation::Invoke<void>
    69. 0x00007FF7AC2E46CA (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
    70. 0x00007FF7ACCB8138 (Unity) GUIView::ProcessRetainedMode
    71. 0x00007FF7AD278343 (Unity) GUIView::OnInputEvent
    72. 0x00007FF7ACCB7F45 (Unity) GUIView::ProcessInputEvent
    73. 0x00007FF7AD270F1D (Unity) GUIView::DoPaint
    74. 0x00007FF7AD27A4BC (Unity) GUIView::RepaintAll
    75. 0x00007FF7ACDE724A (Unity) Application::TickTimer
    76. 0x00007FF7AD24DA7A (Unity) MainMessageLoop
    77. 0x00007FF7AD252884 (Unity) WinMain
    78. 0x00007FF7AE5C7CCE (Unity) __scrt_common_main_seh
    79. 0x00007FF8C3F97034 (KERNEL32) BaseThreadInitThunk
    80. 0x00007FF8C5242651 (ntdll) RtlUserThreadStart
    81.  
    Different code paths though, so it could be two different crash bugs!
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Yeah, looks like potentially two different issues.
     
  12. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    From the linked issue:

    RESOLUTION NOTE (FIX VERSION 2023.1):

    SRP batcher was not handling UsePass and Fallback correctly in the Editor which could cause both Editor crashes and broken rendering.
    Root cause found and fixed.

    So yes, it likely is.
     
  14. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Fingers crossed for a fix back port!
     
    aleksandrk likes this.
  15. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Hi @aleksandrk , do you know if there are any updates on back porting this for either of the LTS versions (2020, 2021) and/or 2022.2? It is a crash bug that occurs every ~5 minutes in editor. It means that SRPBatcher can't be reliably used in 2020, 2021 or 2022 atm
     
    DEEnvironment likes this.
  16. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi @ElliotB , there was an issue with the fix, so it'll take a bit more time.
     
    ElliotB likes this.
  17. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    I appreciate the update, thank you
     
  18. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Do you know if there is any further progress on the UsePass incompatibility with SRPBatcher? Thanks!
     
  19. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Backports are in progress, not sure when they will appear in a release yet.
     
    ElliotB likes this.
  20. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Does this mean the fix is available in current alpha (I can help test)?
     
  21. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    The fix will be available (or is available already) in 2023.1.0b1 and 2021.3.19f1. 2022.2 to follow :)
     
  22. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Still seeing crashes under the same conditions in 2022.3.7f1, do you know if the fix was ever backported?
     
  23. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    I remade and reuploaded the test case in 2022.3.7f1, under
    IN-53934 - Crash bug when using UsePass with SRPBatcher
     
    aleksandrk likes this.
  24. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Yes, it was backported as it says in the link above.
     
  25. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    That's unfortunate, it looks like it didn't fix the crash bug then. The instructions in the bug report are 100% repeatable for me (open up the shader graph, save it, project will instantly crash), so hopefully that helps reproduction
     
    aleksandrk likes this.
  26. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    268
    Issue once again closed as Not Qualified. I've been asked to submit a video of the crash happening, I'll do this when I have time this evening