ARFace's GetUndisposable throws error on UnityEditor
Hi, I am making an ARFoundation remote simulation tool. Making a subclass of XRFaceSubsystem that works on UnityEditor.
ARFace.GetUndisposable throws on only UnityEditor, since NativeArray.cs is checked read/write access on Editor. it works if remove GetUndisposable and simply return the native array. any workaround?
// ARFace.cs
public unsafe NativeArray<Vector3> vertices
{
get
{
// throws error on Editor
return GetUndisposable(m_FaceMesh.vertices);
// It works
return m_FaceMesh.vertices;
}
}
Error Message
NullReferenceException: Object reference not set to an instance of an object
Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at /Users/builduser/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:117)
Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at /Users/builduser/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:139)
Unity.Collections.NativeArray`1+Enumerator[T].get_Current () <0x14a2783c0 + 0x0007a> in <85963591c1a04aad836445db604e7807>:0
UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.TryCopyToList[T] (Unity.Collections.NativeArray`1[T] array, System.Collections.Generic.List`1[T] list) (at Library/PackageCache/[email protected]/Runtime/AR/ARFaceMeshVisualizer.cs:46)
UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.SetMeshTopology () (at Library/PackageCache/[email protected]/Runtime/AR/ARFaceMeshVisualizer.cs:61)
UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.SetVisible (System.Boolean visible) (at Library/PackageCache/[email protected]/Runtime/AR/ARFaceMeshVisualizer.cs:34)
UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.UpdateVisibility () (at Library/PackageCache/[email protected]/Runtime/AR/ARFaceMeshVisualizer.cs:103)
UnityEngine.XR.ARFoundation.ARFaceMeshVisualizer.OnUpdated (UnityEngine.XR.ARFoundation.ARFaceUpdatedEventArgs eventArgs) (at Library/PackageCache/[email protected]/Runtime/AR/ARFaceMeshVisualizer.cs:108)
UnityEngine.XR.ARFoundation.ARFace.Update () (at Library/PackageCache/[email protected]/Runtime/AR/ARFace.cs:123)
Environment
- macOS
- UnityEtior 2019.2.8f1
- Packages
- "com.unity.xr.arcore": "3.0.0-preview.4",
- "com.unity.xr.arfoundation": "3.0.0-preview.4",
- "com.unity.xr.arkit": "3.0.0-preview.4",
- "com.unity.xr.arkit-face-tracking": "3.0.0-preview.4",
Thanks for reporting. This does not happen in current master, and, looking at the code for ARFace.cs, it looks like everything is guarded correctly. It may have been an issue in a 3.0 preview, but it looks like it was fixed. Please reopen if you are still seeing this.
Hello,
I have dealt with the exact same issue lately while working on an ARFoundation simulation tool as well. I managed to solve it temporarily with what @asus4 shared in his thread.
Are there any updates about this issue today ?
Environment : Unity Editor 2019.4.24f1 ARFoundation 4.1.7 ARKit 4.1.7 ARCore 4.1.7