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
- "Draw Additional Lights Shadowmap" calls increase when custom MaterialBlockProperty is used
- Crash on _platform_memmove when importing the "Dragon Crashers - URP 2D Sample Project" to a new 2D project
- "Shader is not supported on this GPU" warnings and and shaders are not loading when building the project for non-Chromium browsers
- [iOS][URP] The screen flickers and the "Execution of the command buffer was aborted due to an error during execution" error is thrown continuously
- Shortcut Manager shows empty conflict filter when resolving runtime conflicts involving different contexts
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().