Search Issue Tracker

Fixed in 2019.3.X

Votes

0

Found in

2017.4.0f1

2018.3.0a1

2018.4.4f1

2019.1.0a1

2019.2.0a1

2019.3.0a1

Issue ID

1170742

Regression

No

Crash on RendererScene::SceneAfterCullingOutputReady when using GameObject.DestroyImmediate()

Scripting

-

How to reproduce:
1. Open the Scene "reproduction" in the attached "case_1170742.zip" Unity project
2. Enter Play Mode and wait
3. Observe the crash

Reproducible with: 2017.4.31f1, 2018.4.5f1, 2019.1.13f1, 2019.2.0f1, 2019.3.0a11

Note: it might take more than one attempt of entering Play Mode to reproduce the crash. If GameObject.DestroyImmediate() is swapped with GameObject.Destroy() in ObiRope.cs (line 64 and line 65), the crash is not reproducible.

  1. Resolution Note (fix version 2019.3):

    We cannot add or destroy renderers after culling has started. DestroyImmediate bypasses this and destroys a renderer that is currently being rendered. This results in a crash. Destroy should be used instead of DestroyImmediate, this destroys the object when it is safe and rendering has finished. With the fix an error message will now be shown when attempting to call Destroy Immediate from one of the rendering call backs. The error message will recommend the use of Destroy instead. The editor should not longer crash when this happens.

    https://docs.unity3d.com/ScriptReference/Object.DestroyImmediate.html.

    Unity no longer crashes in 2020.1.0a22 - instead, an error is thrown indicating that "Destroy" should be used.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.