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
- "NullReferenceException" error thrown in UnityEditor.ObjectListArea when an audio clip is selected in one of two opened Project tabs while the second Project tab is not active/painted
- Pop-up to save unsaved changes does not appear when closing a custom editor window using ESC key
- A new Additive Scene cannot be created when an empty Untitled Scene is not dirty
- [Scene View][Ubuntu] Prefab mode UI ghosting in HDRP
- Deleting AudioMixer asset throws MissingReferenceException and breaks the Audio Mixer window
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().