iOS (iPad1) CRASH caused by Mesh.Bake PHYSX CollisionData

Hi!
I have a very annoying issue in iOS. Currently I’m developing a game with extensive use of physics. The game is very particular, and really needs to have in a scene a big mesh with a “Mesh Collider” attached.
Everything works fine on almost all the iOS platforms (from 3GS to iPad3), but sometimes I have a crash when loading my scenes.
I tried enabling and disabling almost everything (from algorithms, to game objects), and finally I figured out that my crash was caused for the following instruction:
Mesh.Bake PhysX CollisionData

This instruction was executed when my mesh with the mesh collider became activated in the scene.
I tried both keep activated in the scene from the beginning the game object, and activating it with certain delay with no luck.

Also, al tried all the tricks detailed in the following link, but none of them works:
http://forum.unity3d.com/threads/65346-What-is-quot-Bake-Scaled-Mesh-Physx-Collision-Data-quot

Also, I tried enabling the option “Generate Colliders” in the FBXImporter, and nothing.

Please, someone knows how to avoid the Mesh Collision Data to be calculated in runtime?

One more thing: when the MeshCollider is enabled, the mentioned instruction takes about 20 seconds to be completed in iPad 1 (causing the crash). When the collider is disabled, the scene loads as usual (loading level async doesn’t make any difference).

Thanks for your time.

George

[649-Screen+Shot+2012-04-16+at+10.40.17+PM.png|649]

Currently (3.5.x) we calculate the Mesh Collision Data always at load time. There is no way to avoid that.

In your case I can think of four reasons why this is happening:

  1. The application runs out of memory. You can determine this by looking at the Crash report. If it doesn’t contain a callstack it is an out of memory error : https://developer.apple.com/library/ios/#technotes/tn2008/tn2151.html.

  2. The Mesh is too big and Physx processes it for too long, locking the UI and triggering the ios watchdog timeout that will kill your app. (also documented in the previous link)

  3. The Mesh is malformed in some way and is causing pathological behaviour from the collision data calculation.

  4. A bug in Unity.

For cases 1 and 2 I suggest you test breaking the mesh into smaller meshes. If that doesn’t resolve the problem then we would like to investigate this. You can send us a bug report following the instructions found here: http://answers.unity3d.com/questions/9292/how-do-i-report-a-bug-in-unity.html

Ricardo, Too much better now! We were able to successful split the mesh and now the scenes load without freezing the execution of the game :-).
This change, and several texture optimizations, allow us to have almost no more memory crashes in iPod Touch 4. Still we have minor issues in iPad, but your confirmation of how Mesh collider data was processed, help us to know were we have to tweak.

Thanks!