Search Unity

Bug ARMeshAnchor data corrupted when accessed from ARFrame* pointer

Discussion in 'AR' started by boruds, May 6, 2021.

Thread Status:
Not open for further replies.
  1. boruds

    boruds

    Joined:
    Aug 7, 2020
    Posts:
    28
    I am trying to access the native ARMeshAnchor from the arsession. ARFrame.anchors property stores all these anchors and I can filter out ARMeshAnchors from them.
    I have also tried this in a native only iOS app and the ARMeshAnchor data seems to be fine, but when I pass the nativePtr to the ARFrame from unity c# to objective C and then read the anchors, the plane anchors come out fine, but the Mesh Anchors, some of them are missing face data. Why could this be happening?
     
  2. boruds

    boruds

    Joined:
    Aug 7, 2020
    Posts:
    28
  3. boruds

    boruds

    Joined:
    Aug 7, 2020
    Posts:
    28
    I tried an experiment where I set the class in my plugin as the delegate of the ARSession. and if I watch for the anchors in the ARFrame pointer for the last updated frame before the session is paused, then the data is right and all Mesh Anchors have the right data.

    But when I do the same thing on unity.
    Capture the ARFrame then immediately pause the ARSession (I call pause on the ARSession object in objective C) and then read the mesh anchors, the mesh anchor data is corrupted. Many of the meshes are missing face indices. For example out of 36 meshes, 14 had corrupted data. This doesn't happen when I access the Mesh anchors in the session:didUpdateFrame callback.

    My theory is that there is a disparity between the unity and ARKit frame rates so when I try to access the ARFrame from unity OnFrameReceived callback from the ARCameraManager, ARKit must be in the middle of an update of the mesh anchors and hence the data is corrupted.

    Any thoughts?
     
  4. boruds

    boruds

    Joined:
    Aug 7, 2020
    Posts:
    28
    So I also tried accessing the anchors 3 ways.
    1. I called getWorldMap on the ARSession and from the world map accessed the anchor property just before the session is paused. I still saw the corrupted meshes with missing faces.
    2. Instead of calling getWorldMap I called ARSession.currentFrame and accessed the anchors property of the ARFrame object, it still failed.
    3. I accessed the anchors property on ARFrame every time ARCameraManager sends a callback for frame received. The meshes were still corrupted.

    This is only happening for a few meshes. No Idea why this is happening.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    Apologies for the delay! I'll touch base with the team for some guidance!
     
  6. boruds

    boruds

    Joined:
    Aug 7, 2020
    Posts:
    28
  7. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    I didn't realize this thread was the same as the thread you have going here. I'm going to close this one, so that it's less confusing.
     
Thread Status:
Not open for further replies.