Search Issue Tracker

Fixed in 2020.2.X

Fixed in 2019.4.X, 2020.1.X

Votes

1

Found in

2019.3.8f1

2019.4

2019.4.3f1

2020.1

2020.2

Issue ID

1262936

Regression

Yes

Editor crashes on PhysicsContacts2D::EndContact when exiting Play mode after Assertion failed on expression: GetShape() == NULL

Physics2D

-

Reproduction steps:
1. Open the attached "case_1262936.zip" project
2. Load the "SampleScene" and enter Play mode
3. Click twice the "Test Crouching" button and observe errors in the Console window
4. Exit Play mode
-- Observe the crash

Reproduces on: 2019.3.8f1, 2019.3.4f3, 2020.1.0b16, 2020.2.0a18
Not reproducible with: 2019.3.7f1
Could not test with 2018.4 due to multiple compilation errors

Note: instead of clicking "TestCrouching" button you can manually uncheck and then check again the "IsCrouchingTest" variable found in "PlayerMovement_Long" Component in the Inspector window when the "Player" GameObject is selected in the Hierarchy window

First lines of the stack trace:
0x00007FF66C524D63 (Unity) PhysicsContacts2D::EndContact
0x00007FF66C4A4835 (Unity) b2ContactManager::Destroy
0x00007FF66C4A4B14 (Unity) b2World::DestroyBody
0x00007FF66C53DD9F (Unity) Rigidbody2D::Cleanup
0x00007FF66B238558 (Unity) GameObject::ActivateAwakeRecursivelyInternal
<...>

  1. Resolution Note (fix version 2020.2):

    The "Physics2D.callbacksOnDisable" feature when enabled allows recursive physics callbacks and modifying of collider state. With it off, in this case specifically, a reparenting action results in the collider be recreated therefore leaving orphaned collision shapes. When the collider is enabled again, an assert throws which verifies that no collision shapes are present prior to it being enabled.

    Enabling this callback bypasses the issue however we have fixed the issue by ensuring that the enabled/disabled state of the component is actioned prior to any modifications to the 2D collider. This stops any side-effects of disabling/enabling from affecting the recursive call.

  2. Resolution Note (fix version 2020.1):

    The "Physics2D.callbacksOnDisable" feature when enabled allows recursive physics callbacks and modifying of collider state. With it off, in this case specifically, a reparenting action results in the collider be recreated therefore leaving orphaned collision shapes. When the collider is enabled again, an assert throws which verifies that no collision shapes are present prior to it being enabled.

    Enabling this callback bypasses the issue however we have fixed the issue by ensuring that the enabled/disabled state of the component is actioned prior to any modifications to the 2D collider. This stops any side-effects of disabling/enabling from affecting the recursive call.

  3. Resolution Note (fix version 2019.4):

    The "Physics2D.callbacksOnDisable" feature when enabled allows recursive physics callbacks and modifying of collider state. With it off, in this case specifically, a reparenting action results in the collider be recreated therefore leaving orphaned collision shapes. When the collider is enabled again, an assert throws which verifies that no collision shapes are present prior to it being enabled.

    Enabling this callback bypasses the issue however we have fixed the issue by ensuring that the enabled/disabled state of the component is actioned prior to any modifications to the 2D collider. This stops any side-effects of disabling/enabling from affecting the recursive call.

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.