XRRayInteractor + Mesh Collider = Crash

As the title says. I was getting mysterious crashes when using a ray with mesh collider and couldn’t find the cause, but after testing everything I noticed that the only thing that was different was that I had changed from box collider to mesh collider…

I also searched about this and found other people complaining about mesh collider related crashes.

It crashes in the editor, crashes on Oculus.

Which Unity version and XRIT version?
Does it also happens with convex colliders?
Have others filed a bug report? If not, if it’s reprodable, make one

Unity 2022.3.22f1
XRIT 2.5.2

Have others filed a bug report? If not, if it’s reprodable, make one

I don’t know, and it’s kind of random, and it depends on the object as well. But it definitely happens because of mesh colliders. My guess is the ray detects too many hit points or something like that, there’s some kind of buffer overflow and everything crashes.

You can check the crash logs to make sure

Are you noticing any warnings? In general mesh colliders that are not convex are not properly supported with rigidbodies.

If is convex, I’m curious if you’ve tried xri 3.0. The ray code was completely rewritten and if it’s causing you a crash I’d like to see a repro.

Not a rigidbody. Kind of afraid to update, I remember I tried before in some other project and got a shit ton of errors and couldn’t fix them, even tried to downgrade back and it wouldn’t work. It installs 2.5.2 by default, though looking at the package manager it says 2.5.4 is the recommended one (so why it installs 2.5.2?). Anyways…if I find some time I will try to replicate the problem with a free model on 2.5.4, then try on 3.0 to see if the problem is still there.

It probably has to do with the model’s complexity as well. It has 793329 vertices and 505154 triangles, 60MB.

1 Like

My advice if you choose to upgrade is to:

  • open a blank scene
  • upgrade the package
  • upgrade the starter assets sample
  • replace your XR origin rig with a new one

If you use the prefabs we provide, upgrading to 3.0 can be fairly painless.

if you run into issues in between, I recommend deleting your package cache in your library folder and then reimporting everything.

All that said, your model sounds way too complex for a mesh collider and I would advise you to avoid adding physics to such complex geometry. Even in 3.0 I don’t think your app will be stable interacting with it.

The ideal is only use primitive colliders.
A tool like this one can help reduce the complexity of your colliders.

All that said, your model sounds way too complex for a mesh collider and I would advise you to avoid adding physics to such complex geometry. Even in 3.0 I don’t think your app will be stable interacting with it.

Thanks, so there is an issue. Can I ask to add an information note to the mesh collider component that models that are too complex may cause the app to crash? It’s not obvious the source the issue since it just crashes the app. Something like this I mean

I’ll make a note of it cheers.

1 Like

@ericprovencher Can you also check this post ? Thank you so much.