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

Unity 2020.2 URP 10.2.2: ScriptableRenderContext.Cull() crashes Unity

Discussion in 'Universal Render Pipeline' started by adamgryu, Jan 26, 2021.

  1. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    167
    My stack trace is included below - any workarounds? It crashes every time I open Unity unless I uninstall the feature.

    The render feature I'm trying to use is based on this:
    https://github.com/Kink3d/kDecals

    Code (CSharp):
    1. 0x00007FF6B3906B94 (Unity) SendShadowCullingCallbacks
    2. 0x00007FF6B3E2F4D4 (Unity) PrepareDrawShadowsCommandStep1
    3. 0x00007FF6B3E27234 (Unity) ScriptableRenderContext::ExecuteScriptableRenderLoop
    4. 0x00007FF6B492F9FF (Unity) ScriptableRenderContext_CUSTOM_Submit_Internal_Injected
    5. 0x0000020AC0008667 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal_Injected (UnityEngine.Rendering.ScriptableRenderContext&)
    6. 0x0000020AC00085AB (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal ()
    7. 0x0000020AC0008543 (Mono JIT Code) UnityEngine.Rendering.ScriptableRenderContext:Submit ()
    8. 0x0000020ABDFC0C63 (Mono JIT Code) [C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:392] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData,bool)
    9. 0x0000020ABDFB24AB (Mono JIT Code) [C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:510] UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderCameraStack (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
    10. 0x0000020ABDF6E1EB (Mono JIT Code) [C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:238] UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])
    11. 0x0000020ABDF6D829 (Mono JIT Code) UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])
    12. 0x0000020ABDF5B9EB (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)
    13. 0x0000020ABDF5BC20 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr)
    14. 0x00007FF82A92E0C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2812] mono_jit_runtime_invoke
    15. 0x00007FF82A8B2902 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
    16. 0x00007FF82A8BB95F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
    17. 0x00007FF6B46A5D94 (Unity) scripting_method_invoke
    18. 0x00007FF6B469E585 (Unity) ScriptingInvocation::Invoke
    19. 0x00007FF6B3E2941D (Unity) ScriptableRenderContext::ExtractAndExecuteRenderPipeline
    20. 0x00007FF6B393DBCF (Unity) RenderManager::RenderCamerasWithScriptableRenderLoop
    21. 0x00007FF6B393D2E6 (Unity) RenderManager::RenderCameras
    22. 0x00007FF6B51C2F32 (Unity) RepaintController::RenderPlayModeViewCameras
    23. 0x00007FF6B5B5A53E (Unity) EditorGUIUtility::RenderPlayModeViewCamerasInternal
    24. 0x00007FF6B63A8F99 (Unity) EditorGUIUtility_CUSTOM_RenderPlayModeViewCamerasInternal_Injected
    25. 0x0000020ABDF5A6F7 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.EditorGUIUtility:RenderPlayModeViewCamerasInternal_Injected (UnityEngine.RenderTexture,int,UnityEngine.Vector2&,bool,bool)
    26. 0x0000020ABDF5A613 (Mono JIT Code) UnityEditor.EditorGUIUtility:RenderPlayModeViewCamerasInternal (UnityEngine.RenderTexture,int,UnityEngine.Vector2,bool,bool)
    27. 0x0000020ABDF57DC3 (Mono JIT Code) UnityEditor.PlayModeView:RenderView (UnityEngine.Vector2,bool)
    28. 0x0000020ABBF4668B (Mono JIT Code) UnityEditor.GameView:OnGUI ()
    29. 0x0000020ABAF659C3 (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect,UnityEngine.Rect)
    30. 0x0000020ABAF65733 (Mono JIT Code) UnityEditor.DockArea:DrawView (UnityEngine.Rect,UnityEngine.Rect)
    31. 0x0000020ABA9BAC53 (Mono JIT Code) UnityEditor.DockArea:OldOnGUI ()
    32. 0x0000020A340D58B0 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    33. 0x0000020A340D49EB (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    34. 0x0000020A340D3193 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint ()
    35. 0x0000020A340D04CB (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&)
    36. 0x0000020A340CE00B (Mono JIT Code) UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&)
    37. 0x0000020A340C8523 (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChain:Render ()
    38. 0x0000020A340B5AA3 (Mono JIT Code) UnityEngine.UIElements.UIRRepaintUpdater:Update ()
    39. 0x0000020A3408EF1E (Mono JIT Code) UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase)
    40. 0x0000020A3408EE4B (Mono JIT Code) UnityEngine.UIElements.Panel:UpdateForRepaint ()
    41. 0x0000020A3408E833 (Mono JIT Code) UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event)
    42. 0x0000020A3408E097 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    43. 0x0000020A3408DD5B (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    44. 0x0000020A3408DB5F (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
    45. 0x0000020A3408DA9B (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    46. 0x0000020A3408D8FD (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    47. 0x0000020A3408D9AE (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    48. 0x00007FF82A92E0C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2812] mono_jit_runtime_invoke
    49. 0x00007FF82A8B2902 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
    50. 0x00007FF82A8BB95F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
    51. 0x00007FF6B46A5D94 (Unity) scripting_method_invoke
    52. 0x00007FF6B469E585 (Unity) ScriptingInvocation::Invoke
    53. 0x00007FF6B46976B5 (Unity) ScriptingInvocation::Invoke<void>
    54. 0x00007FF6B2D5F7CD (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
    55. 0x00007FF6B52C4EA6 (Unity) GUIView::ProcessRetainedMode
    56. 0x00007FF6B5D479B5 (Unity) GUIView::OnInputEvent
    57. 0x00007FF6B52C4D98 (Unity) GUIView::ProcessInputEvent
    58. 0x00007FF6B5D3E755 (Unity) GUIView::DoPaint
    59. 0x00007FF6B5D4A9AD (Unity) GUIView::RepaintAll
    60. 0x00007FF6B5D4016E (Unity) GUIView::GUIViewWndProc
    61. 0x00007FF8AF68E858 (USER32) CallWindowProcW
    62. 0x00007FF8AF68E3DC (USER32) DispatchMessageW
    63. 0x00007FF8AF6A0BC3 (USER32) SendMessageTimeoutW
    64. 0x00007FF8B078FDE4 (ntdll) KiUserCallbackDispatcher
    65. 0x00007FF8AE721704 (win32u) NtUserDispatchMessage
    66. 0x00007FF8AF68E2EA (USER32) DispatchMessageW
    67. 0x00007FF6B5D102E6 (Unity) PumpMainThreadMessages
    68. 0x00007FF6B5D10F4F (Unity) ModalProgressBackendWindows::Update
    69. 0x00007FF6B59B31EE (Unity) UpdateProgressBarState
    70. 0x00007FF6B59B2AA1 (Unity) ProgressScope::Section
    71. 0x00007FF6B5397468 (Unity) Application::FinishLoadingProject
    72. 0x00007FF6B5D12C16 (Unity) WinMain
    73. 0x00007FF6B7B58FC6 (Unity) __scrt_common_main_seh
    74. 0x00007FF8AEA87034 (KERNEL32) BaseThreadInitThunk
    75. 0x00007FF8B073D0D1 (ntdll) RtlUserThreadStart
    More stacktrace, in case it's helpful:

    Code (CSharp):
    1. Stacktrace:
    2.  
    3.   at <unknown> <0xffffffff>
    4.   at (wrapper managed-to-native) UnityEngine.Rendering.ScriptableRenderContext.Submit_Internal_Injected (UnityEngine.Rendering.ScriptableRenderContext&) [0x00007] in <e414e10bfe5f45729ff122f3359de21b>:0
    5.   at UnityEngine.Rendering.ScriptableRenderContext.Submit_Internal () [0x00001] in <e414e10bfe5f45729ff122f3359de21b>:0
    6.   at UnityEngine.Rendering.ScriptableRenderContext.Submit () [0x00009] in <e414e10bfe5f45729ff122f3359de21b>:0
    7.   at UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData,bool) [0x0012f] in C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:391
    8.   at UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderCameraStack (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) [0x00239] in C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:509
    9.   at UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[]) [0x00078] in C:\Users\adamg\Code\UnityProjects\ProjectNight\Library\PackageCache\com.unity.render-pipelines.universal@10.2.2\Runtime\UniversalRenderPipeline.cs:237
    10.   at UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[]) [0x0001f] in <e414e10bfe5f45729ff122f3359de21b>:0
    11.   at UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle) [0x0004c] in <e414e10bfe5f45729ff122f3359de21b>:0
    12.   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr) [0x00036] in <e414e10bfe5f45729ff122f3359de21b>:0
    13.   at <unknown> <0xffffffff>
    14.   at (wrapper managed-to-native) UnityEditor.EditorGUIUtility.RenderPlayModeViewCamerasInternal_Injected (UnityEngine.RenderTexture,int,UnityEngine.Vector2&,bool,bool) [0x0000c] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    15.   at UnityEditor.EditorGUIUtility.RenderPlayModeViewCamerasInternal (UnityEngine.RenderTexture,int,UnityEngine.Vector2,bool,bool) [0x00007] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    16.   at UnityEditor.PlayModeView.RenderView (UnityEngine.Vector2,bool) [0x000ea] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    17.   at UnityEditor.GameView.OnGUI () [0x002ee] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    18.   at UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect,UnityEngine.Rect) [0x00066] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    19.   at UnityEditor.DockArea.DrawView (UnityEngine.Rect,UnityEngine.Rect) [0x00004] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    20.   at UnityEditor.DockArea.OldOnGUI () [0x0019d] in <1e441e8684a14fe4b8f8a926d91afc3a>:0
    21.   at UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool) [0x001e1] in <3cdf672c21b849dea215f9c9aff21f77>:0
    22.   at UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool) [0x000c8] in <3cdf672c21b849dea215f9c9aff21f77>:0
    23.   at UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () [0x0005a] in <3cdf672c21b849dea215f9c9aff21f77>:0
    24.   at UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&) [0x000c1] in <3cdf672c21b849dea215f9c9aff21f77>:0
    25.   at UnityEngine.UIElements.UIR.UIRenderDevice.EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&) [0x00536] in <3cdf672c21b849dea215f9c9aff21f77>:0
    26.   at UnityEngine.UIElements.UIR.RenderChain.Render () [0x0011f] in <3cdf672c21b849dea215f9c9aff21f77>:0
    27.   at UnityEngine.UIElements.UIRRepaintUpdater.Update () [0x0006c] in <3cdf672c21b849dea215f9c9aff21f77>:0
    28.   at UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase) [0x0001f] in <3cdf672c21b849dea215f9c9aff21f77>:0
    29.   at UnityEngine.UIElements.Panel.UpdateForRepaint () [0x0003c] in <3cdf672c21b849dea215f9c9aff21f77>:0
    30.   at UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event) [0x00099] in <3cdf672c21b849dea215f9c9aff21f77>:0
    31.   at UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel) [0x00029] in <3cdf672c21b849dea215f9c9aff21f77>:0
    32.   at UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&) [0x0003f] in <3cdf672c21b849dea215f9c9aff21f77>:0
    33.   at UnityEngine.UIElements.UIEventRegistration.ProcessEvent (int,intptr) [0x0001f] in <3cdf672c21b849dea215f9c9aff21f77>:0
    34.   at UnityEngine.UIElements.UIEventRegistration/<>c.<.cctor>b__1_2 (int,intptr) [0x00003] in <3cdf672c21b849dea215f9c9aff21f77>:0
    35.   at UnityEngine.GUIUtility.ProcessEvent (int,intptr,bool&) [0x00018] in <a8eb1be68acb4659af00824c7808e2c0>:0
    36.   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr) [0x0002d] in <a8eb1be68acb4659af00824c7808e2c0>:0
     
    alexmalyutindev likes this.
  2. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    167
    Welp, I solved it already. EDIT: It was not solved.

    The problem was I incorrectly updated kDecals to the new version of the URP.
    I think I was constantly getting new CommandBuffers from the CommandBufferPool and never releasing them.
    Calling CommandBufferPool.Get(stringArguement) seemed to be creating a whole bunch of instances of Profiler.BeginSample().
    Furthermore, it only crashed when trying to get the cull arguments from the Camera, seemingly.

    Hope this is helpful to someone!
     
    Last edited: Jan 29, 2021
  3. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    167
    I spoke too soon, the above fix was not the root of the issue. This still happens for me.

    I've narrowed it down to this code inside the ScriptableRenderPass
    Code (CSharp):
    1. cullingResults = context.Cull(ref cullingParameters);
    Removing this line of code stops Unity from crashing - but why? I'd like to be able to cull...
     
    Last edited: Jan 29, 2021
    equalsequals likes this.
  4. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    167
    I can get it to not crash by using
    renderingData.cullResults
    instead of calculating them again.
    However, there's not much documentation on what's in here. Is this what I should be using to decide if I should render a decal?
     
    vincurekf likes this.
  5. oleg_v

    oleg_v

    Joined:
    Nov 10, 2017
    Posts:
    67
    For me it helped to call immediately context.Submit() after context.Cull.
    Unity 2020.3.11f1, URP
     
    vincurekf likes this.
  6. oleg_v

    oleg_v

    Joined:
    Nov 10, 2017
    Posts:
    67
    Still the same, nothing helped. Working with simple scene but crashes on large one.
    Mostly crashed on: scene load in editor, enter play mode, change camera.
    So tried to add delay (frame counter) for each camera in render pass.
    Tried to use this delay to skip pass or to not context.Cull but w/o luck.
    Skipping 100-500 frames leading to work for several seconds and Unity crash.
     
  7. qwerty20210918

    qwerty20210918

    Joined:
    Sep 26, 2021
    Posts:
    1
    Do you find any way to fix this? I encounter the same problem. I need dynamic change camera clip range and fov to draw additional game objects. but this line always crashes my editor.