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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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().