- Home /
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
On Unity4, when I've used the first script on the following thread, I got exactly this issue (`$$anonymous$$esh.Bake PhysX CollisionData`). I've fixed it along the thread, with a new code. Basically, I believe, I just removed the mesh from a global scope, thus recreating from zero after each iteration. $$anonymous$$aybe the point is: trying to remake a mesh can lead to collisiondata somehow. http://forum.unity3d.com/threads/14378-Raycast-without-colliders
Answer by ricardo_arango · Apr 17, 2012 at 02:21 PM
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:
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.
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)
The Mesh is malformed in some way and is causing pathological behaviour from the collision data calculation.
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
Thank's for your quick answer Ricardo, it was very useful. Here are my comments:
About avoiding to calculate the $$anonymous$$esh Collision Data... these are bad news :-P So, what optimization gives you to enable the option "Generate Colliders" in the FBXImporter?
Confirmed! the application use too much memory and...
... seems that when the ios watchdog timeout was triggered (caused by the mesh processing) makes the memory crash "more possible". It was completely confirmed by the "low memory" logs (thank you for the documentation recommended).
$$anonymous$$esh is Ok.
Hope it is not! :-P
We have optimized several $$anonymous$$B of texture memory and now we are dividing the mesh mentioned. We have already implemented a kind of "scene loader" and activating the game objects one by one through the updates. As soon as we have the results of the tests I'm going to give you the results :-)
Thanks
Answer by georgem85 · Apr 20, 2012 at 02:03 AM
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!
Your answer
Follow this Question
Related Questions
Full FPS For iPad? 2 Answers
iPad: Line Renderer causes crash on on startup 0 Answers
Line Renderer causes crash on iPad on Startup 0 Answers
App crashing in one iPad and running ok in another 0 Answers