Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CRASH in Unity 4.1.2 where 3.5.6 works fine (ContactMessage::onContactNotify)

Discussion in 'iOS and tvOS' started by liven410, Apr 18, 2013.

  1. liven410

    liven410

    Joined:
    Dec 23, 2010
    Posts:
    36
    Hello,

    Help! Stuck in CRASH. Need some fix asap.

    Please download the project source files from the below dropbox link. It contains the project source code files, and two text files in assets folder which explains the issue, steps to reproduce and untiy's editor log of the crash.

    https://www.dropbox.com/s/a2j1cik4g8p1c24/ARGame_180413.zip


    Below is the text copied from the "Read me" file of the project in case if you cannot download that.

    ====================================================================
    Rigidbody null reference issue / crash, when target is lost / found continously repeatedly.
    in Vuforia 2.0.31 and Unity 4.1.2 (But in Unity 3.5.6 it is working great)

    - 18.April.2013
    ====================================================================


    >>> ISSUE:
    --------------------------------------------------------
    This project, if you run, will let you move a ball on a plane, according to you moving your target image.
    But in Unity 4.1.2 it is crashing when the target is lost and visible repeatedy quickly quickly.
    Whereas In Unity 3.5.6 is working fine.

    ("Repeatedly quickly quickly" means as fast as you can move in and out the image target from the camera view.
    But keep it at that pace that it should at-least be detectable In just 5-6 times of doing this, will not show you the real error or issue)




    >>> ISSUE (In details), ITS CAUSE and TEMPORARY SOLUION :-
    --------------------------------------------------------

    1) While running the game, When the marker (trackerable image) continuesly appears and dis-appears
    in front of the camera then the game crashes in iphone, giving me some Physics (PhyX) error in XCode console.
    Below is the error give by Xcode console:
    0xc472f4: beq 0xc47310;
    ContactMessage::eek:nContactNotify(NxContactPair, unsigned int) + 104 at PhysicsManager.cpp:230

    2) When I do this same thing in Unity 4.1.2 PRO editor itself, on my mac. Then, It quites the unity program
    itself. And when I checked the Editor log. It displayed 'Null Reference'

    3) When I debuged my script Ball.cs by using couple of Debug.Logs, I found that it is giving me 'null refernce'
    due to the current rigidbody object i.e my variable "_thisRigidbody"
    (i.e ball's own rigidbody, that I assign in the awake function)

    4) And If I comment all the two lines inside the PauseBallBehaviour() and ResumeBallBehaviour() functions.
    Then this error doesn't happens. Which makes me even more sure that my _thisRigidbody variable is giving null reference.

    5) SURPRIZINGLY. Its happens in unity 4.1.2 editor and xcode project build from Unity 4.1.2
    either its pro or basic.
    BUT. This issue does not happens in unity 3.5.6 editor and not even in xcode project build from Unity 3.5.6.

    so, does that means UNTIY 4.1.2 is having some issue ?
    or Vuforia SDK 2.0.31 is having some problem with Unity 4.1.2 ??
    or Does I am doing something wrong with rigidbody or something else ???


    >>> Note:
    --------------------------------------------------------
    a) If Xcode project build, is giving you any error regarding QCAR, then manually add the "QCARUnityPlayer.h"
    to your xcode project, from Assets > Plugins > ios > QCARUnityPlayer.h

    b) I am using Unity 4.1.2 + ios Basic license, Xcode 4.6.1, OSX Lion 10.7.5, ipod Touch ios 5.1.1, iphone 3gs ios 6.1.2


    I am bady before this issue to solve it. But not lucky enough to see some success.
    PLEASE REPLY ME IF YOU GOT ANY GOOD SOLUTION TO IT. OR ANY SUGGESTION.


    Thank you. :)
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,623
    hm, judging from code around - were you destroying some objects in collision callbacks (or smth like that)
     
  3. liven410

    liven410

    Joined:
    Dec 23, 2010
    Posts:
    36
    Hi Alexey,
    Thank you friend for atleast checking in.

    Well, No, I am not destroying any object during the gameplay.
    There is only a ball and a base plane. Ball is moving using rigidbody and downward gravity on that plane.

    What I am doing, is just caching the rigidbody of that ball into a private variable. And then using that variable, I enable or disable the ball's rigidbody's isKinematic and useGravity properties when the tracker (target image) is visible or lost.

    There are only two easy and simple scripts in the code. I have commented those as much as i could to explain anybody about that error and its cause.
    What i can't figure out it its solution.


    Have you checked my code? Were you able to get the same error at your end?
    If not, please check my scripts once. I will really appreciate.

    take care n thanks.
    - liven
     
  4. a1studmuffin

    a1studmuffin

    Joined:
    Apr 20, 2013
    Posts:
    2
    Hi Liven,

    I was seeing a similar Unity hard crash to yours. Mine looked like this:

    (0x013D33E9) c:\buildagent\work\812c4f5049264fad\runtime\dynamics\physicsmanager.cpp (256 + 0x15): ContactMessage::eek:nContactNotify + 0x1c9
    (0x0199EC22) c:\buildagent\work\f2fe5c66f78ff1a0\sdks\core\common\src\scene.cpp (3159 + 0x12): Scene::fireQueuedContactCallbacks + 0x92
    (0x01968D20) c:\buildagent\work\f2fe5c66f78ff1a0\sdks\physics\src\npscene.cpp (717 + 0x0): gPreFFCallback + 0x0
    (0x019A4740) c:\buildagent\work\f2fe5c66f78ff1a0\sdks\core\common\src\scene.h (538 + 0x0): Scene::getNxScene + 0x0
    (0x908B018B) ((module-name not available)): (filename not available): (function-name not available) + 0x0
    (0x993EB440) ((module-name not available)): (filename not available): (function-name not available) + 0x0

    After half a day of messing about I managed to isolate the problem for my particular case. In my code, I was changing transform.parent of a gameObject with an enabled BoxCollider on it while it was currently colliding with something. Somehow, this was causing Unity to hard crash at the stack location above.

    I managed to completely dodge the crash with these two magical lines right before I changed transform.parent to null:

    collider.enabled = false; // new line 1
    collider.enabled = true; // new line 2
    transform.parent = null;

    I figured collider.enabled would just be a bool, but I guess it's a property that does some get/set stuff and it must clear out old contacts when set to false or something like that. I hope that's of some use!
     
  5. liven410

    liven410

    Joined:
    Dec 23, 2010
    Posts:
    36
    Hi a1studmuffin,

    Thanks for posting and trying out :) .

    I tried out your collider.enabled stuff before enabling or dissabling the rigibody's useGravity property.
    But in my case it was not working like magical lines. Please if you get some time, please check my code (download link in the first post), maybe you could find where the problem is actually.

    -liven
     
  6. liven410

    liven410

    Joined:
    Dec 23, 2010
    Posts:
    36
    -------FINALLY CRASH FIXED :) ------

    Hi all, if anybody else here facing the same kind of crash issue in Unity 4.x,

    then do just a simple thing. Remove or comment-out the below lines from the Default Trackable EvenHandler .CS

    // Disable colliders

    foreach (Collider component in colliderComponents)

    {

    component.enabled = false;

    }

    this FIXED the unity 4.x CRASH issue in my case.

    I Will also post my game link here once it is uploaded.

    Big Thanks to 'NalinS' (Vuforia-AR Moderator) ;)

    and also to 'a1studdmuffin' for guiding me in right direction.

    -Liven (ashish)
     
    Last edited: Apr 22, 2013
  7. a1studmuffin

    a1studmuffin

    Joined:
    Apr 20, 2013
    Posts:
    2
    Awesome, glad you were able to fix the problem, and most of all I'm really glad those 5 hours I spent playing around with this damn crash on my end actually helped someone else out! :D
     
  8. liven410

    liven410

    Joined:
    Dec 23, 2010
    Posts:
    36
    Hey all!

    I am very glad that my first Unity and Vuforia Augmented Reality Game
    i.e Real Maze 3D Augmented Reality has been approved by apple and google play.

    Thanks to @a1studmuffin and @alexey for helping me out of an issue some time back on the game.

    And sorry for posting late, i was busy in some client project. But Finally I have it there now. ;)

    Friends, please check out my game and give me any feedback, or suggestion for that.
    Download links are below:-

    REAL MAZE 3D Augmented Reality - ANDROID version
    https://play.google.com/store/apps/details?id=com.mahadevinteractive.realmaze

    REAL MAZE 3D Augmented Reality - IOS version
    https://itunes.apple.com/us/app/real-maze-3d-augmented-reality/id641528473?mt=8


    Big Thanks to Vuforia and Unity.

    Cheers..
    - Liven. :)