Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

ARKit face tracking examples crashing on iphone x.

Discussion in 'AR/VR (XR) Discussion' started by AlexiJohansen123, Jan 17, 2018.

  1. AlexiJohansen123

    AlexiJohansen123

    Joined:
    Apr 5, 2016
    Posts:
    17
    I've got the AR examples running just fine but all the examples that uses face tracking make the app crash instantly. Camera permission are assigned. Any ideas?
     
  2. AlexiJohansen123

    AlexiJohansen123

    Joined:
    Apr 5, 2016
    Posts:
    17
    I'm building for IOS11 with 64 bit support, it has all the permissions, I'm pulling out my hair here.
     
  3. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    40
    Hey there

    We have the exact same problem. Even the test face tracking scenes are crashing. We are on arkit 1.5 and ios 11.3 and its working fine otherwise. Any new info?

    Thx Daniel
     
  4. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    40
    Alexi did you solve? We’re still getting crashes on the face anchor test scene.
     
  5. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    40
    Nothing? Anyone?
     
  6. michaelcolin

    michaelcolin

    Joined:
    Jun 12, 2018
    Posts:
    9
    'FaceMeshScene.scene' -

    I have noticed that the sample scene for mesh face tracking from Unity's ARkit 1.5 crashes when you try to load a new scene after loading one with face tracking enabled. Even when you try to load a blank scene.

    Debugging if it doesn't do proper clean up when you load another scene ... any ideas?


    libc++abi.dylib: terminating with uncaught exception of type Il2CppExceptionWrapper
     
  7. michaelcolin

    michaelcolin

    Joined:
    Jun 12, 2018
    Posts:
    9

    3 hours later, I've fixed it :

    In the file
    UnityARFaceMeshManager.cs ( from Unity, in their 1.5 release of ArKit )

    Make sure to add this :

    Code (CSharp):
    1.  
    2.  
    3. void OnDestroy()
    4.     {
    5.         Debug.Log("FaceMeshOnDestroy");
    6.         meshFilter.mesh = null;
    7.         faceMesh = null;
    8.     }
    9.  
    10.  
    This performs the proper cleanup that was missing when you go between scenes. :/
     
  8. michaelcolin

    michaelcolin

    Joined:
    Jun 12, 2018
    Posts:
    9
    I had a similar issue when loading a new scene from the Face Axis demo provided in ARKit 1.5 from Unity.

    You can't load a new scene after running >> FaceAnchorScene.scene - you will crash the next scene with the error:

    libc++abi.dylib: terminating with uncaught exception of type Il2CppExceptionWrapper

    To fix, in the file :
    UnityARFaceAnchorManager.cs ( from Unity, in their 1.5 release of ArKit )

    Be sure to add checks to see if ''anchorPrefab' exists!

    Code (CSharp):
    1.  
    2.  
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using UnityEngine.XR.iOS;
    7.  
    8. public class UnityARFaceAnchorManager : MonoBehaviour
    9. {
    10.  
    11.     public GameObject anchorPrefab;
    12.  
    13.     private UnityARSessionNativeInterface m_session;
    14.  
    15.     // Use this for initialization
    16.     void Start()
    17.     {
    18.         m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
    19.  
    20.         Application.targetFrameRate = 60;
    21.         ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();
    22.         config.alignment = UnityARAlignment.UnityARAlignmentGravity;
    23.         config.enableLightEstimation = true;
    24.  
    25.         if (config.IsSupported)
    26.         {
    27.  
    28.             m_session.RunWithConfig(config);
    29.  
    30.             UnityARSessionNativeInterface.ARFaceAnchorAddedEvent += FaceAdded;
    31.             UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
    32.             UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
    33.  
    34.         }
    35.  
    36.     }
    37.     void FaceAdded(ARFaceAnchor anchorData)
    38.     {
    39.         if (anchorPrefab)
    40.         {
    41.             anchorPrefab.transform.position = UnityARMatrixOps.GetPosition(anchorData.transform);
    42.             anchorPrefab.transform.rotation = UnityARMatrixOps.GetRotation(anchorData.transform);
    43.             anchorPrefab.SetActive(true);
    44.         }
    45.     }
    46.  
    47.     void FaceUpdated(ARFaceAnchor anchorData)
    48.     {
    49.         if (anchorPrefab)
    50.         {
    51.             if (anchorPrefab.activeSelf != anchorData.isTracked)
    52.             {
    53.                 anchorPrefab.SetActive(anchorData.isTracked);
    54.             }
    55.  
    56.             if (anchorData.isTracked)
    57.             {
    58.                 anchorPrefab.transform.position = UnityARMatrixOps.GetPosition(anchorData.transform);
    59.                 anchorPrefab.transform.rotation = UnityARMatrixOps.GetRotation(anchorData.transform);
    60.             }
    61.         }
    62.     }
    63.  
    64.     void FaceRemoved(ARFaceAnchor anchorData)
    65.     {
    66.         if (anchorPrefab)
    67.         {
    68.             anchorPrefab.SetActive(false);
    69.         }
    70.     }
    71.  
    72.     // Update is called once per frame
    73.     void Update()
    74.     {
    75.  
    76.     }
    77.  
    78.     void OnDestroy()
    79.     {
    80.         Debug.Log("Face Axis OnDestroy called");
    81.         if (anchorPrefab)
    82.         {
    83.             anchorPrefab.SetActive(false);
    84.         }
    85.     }
    86. }
    87.  
     
  9. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    40
    Thx guys!
     
  10. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    40
    Btw: in the latest Arkit are these fixes still neccessary?
    Thx
    Daniel
     
  11. ElizaW004

    ElizaW004

    Joined:
    May 21, 2018
    Posts:
    3
    Hi
    i have Quary - please if anyone can resolve me this!
    here i posted my question - https://forum.unity.com/threads/new-apple-animoji.539965/

    im making Animoji like in iphoneX - working in Xcode only not in uniyt.
    can anyone resolve me this how to make animoji like in iphone X.
    is ther any role of uniyt3d or just Xcode?
    and is there anything in Export files from 3ds Max like .Dae or .FBX or anyother formate.??
     
unityunity