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
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
- Entities Hierarchy Search “Show/Hide” button’s Lens Icon is blurry when the Editor is on an external monitor
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().