Native Crash - PhysicsContacts2D::RemoveContact(std::__ndk1::pair<Collider2D const*, Collider2D cons

I’m having this Native Crash a lot lately:

what does it mean and how can i fix it?

Note: The crash happens on devices and also in Unity Editor during play mode (Unity would just crash and close) and asks me to report a Bug.

@florianpenzkofer can you help please?

UPDATE: This happens when i disable “Physics2D → callbacks on disable”, when re-enable it, the Crash doesn’t happen. Is it a bug in Unity?

Sounds like a bug. Can you please creat a bug report with repro project? Please post the case number here once you have one.

1 Like

I have just received a bug report about this and will investigate soon.

1 Like

@FadiObaji I have fixed two high-priority bugs related to this and they’re both currently under review so will land in a release ASAP.

For your refererence: Case 1262936 and a similar case 1231211.

NOTE: Whilst the callbacks maybe not look similar, there are a lot of duplicate cases that report this issue with your callstack. Also the fact that you can change it via “callbacksOnDisable” means it’s almost 100% guaranteed to be the same issue. If you want to submit a bug report and send me the case number or just DM me a simple reproduction project with instructions I’d be happy to verify that it’s fixed.

1 Like

@MelvMay

Actually the crashes happen when i Disable the callBacksOnDisable not when Enabling it.
It is enabled by default when creating a new project, but when disabling this feature → crashes.

I don’t know how to make Reproduction steps because my project has a lot of scripts and prefabs, doing that in an empty project doesn’t seem to cause crashes. I’ll try to reproduce the crash with an empty project and send you the case.

Note: the crashes happen when destroying gameObjects inside a List or when removing them from the List,

This code is making the crashes:
ClearBullets() is called on gameOver or when going to mainMenu

private void ClearBullets()
    {
        if (bulletList == null) return;
        foreach (var bullet in bulletList.ToArray())
        {
            bulletList.Remove(bullet);
            Destroy(bullet.gameObject);
        }
        // TODO: do we need bulletList.Clear(); ?
    }

Commenting out the code make the crashes go away.

Each bullet has a RigidBody2D, CircleCollider2D, SpriteRenderer and a BulletController script.

Yes, I mistyped that in the resolution notes. With that option on, the contacts are processed during the callback sequence however with it off, the contacts are left orhaned and cause the crash. I’ll update the notes, hopefully that’ll update the web-site.

1 Like

Just to note that both the above cases have now landed in 2020.2.0a20, 2020.1.1f1 & 2019.4.7f1 none of which have been released yet.

The public issue trackers will show this when the respective cases have been closed.

1 Like

Wow amazing!, can’t wait for 2019.4.7f1 to be released.