Search Issue Tracker
Fixed in 7.2.0
Votes
0
Found in [Package]
6.9.0, 7.1.1
Issue ID
1185439
Regression
No
[HDRP] Editor crashes after leaving Play mode, using HDRP and calling Graphics.DrawMesh from BeginCameraRendering callback
How to reproduce:
1. Create a HDRP template project and open "SampleScene" (URP or LWRP does not reproduce the issue)
2. Import attached "CameraMeshDraw.cs" script
3. In Hierarchy window, select "Main Camera"
4. Attach "CameraMeshDraw.cs" script as a component to the "Main Camera" inspector
5. Enter Play mode
6. Leave Play mode
Expected result: Unity does not crash
Actual result: Unity crashes
Reproducible with: 2019.2.7f2(6.9.0), 2019.3.0b4(7.0.1), 2020.1.0a5(7.1.1)
Could not test with: 2017.4 HDRP was not yet implemented, 2018.4.9f1 due to (error CS0246: The type or namespace name 'ScriptableRenderContext' could not be found)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- MaskField Choices Elements tooltip covers the entire window while scrolling through the Elements
- Reordering Enum Values in VFX Graph Uint Property expands the “Value” field
- Visual Effect Graph sample titles display in non-human-readable format
- UxmlNamespacePrefix does not apply when using UIBuilder documents
- UI Builder Data Path Source List starts flickering and scrolling when trying to select the last item in the list
Resolution Note (fix version 7.2.0):
The crash is caused by code that doesn't clean up properly, when the MonoBehavior-object is destroyed. This happens, when the user exits the play mode. The HDRP to which the custom rendering code was attached stays alive, while the MonoBehavior is destroyed. The HDRP then keeps calling the code in the destroyed MonoBehavior via BeginCameraRendering callback. This results in undefined behavior and in this case a crash.
The user should take care of removing the custom script from the callback. This can be done in OnDestroy(), similarly to the attaching code in Start().