Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug AR Foundation TryAcquireLatestCPUImage broken

Discussion in 'AR' started by thomasvaniseghemSB, Feb 6, 2023.

  1. thomasvaniseghemSB

    thomasvaniseghemSB

    Joined:
    Sep 15, 2022
    Posts:
    13
    [Repost from IOS discussion, I think this is the right place.]
    The following code results in the camera preview freezing on IOS. I've reliably narrowed it down to using the function TryAcquireLatestCpuImage(out XRCpuImage image). The cameraManager is present so this isn't the problem.
    Commenting TryAcquireLatestCpuImage results in the preview working again. Also tried turning of multithreaded rendering and putting it in the Update() function.
    Also can't see anything or any errors in the logs.

    Also the documentation at https://docs.unity3d.com/Packages/c...#accessing-the-device-camera-image-on-the-cpu contains an error. It should be "frameReceived" instead of "cameraFrameReceived".

    Platforms:
    Unity 2021.3.14f
    ARKit 5.0.3
    AR Foundation 5.0.3
    Xcode 14.1
    iPad Pro 3th gen IOS 16.2

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.XR.ARFoundation;
    3. using UnityEngine.XR.ARSubsystems;
    4.  
    5. public class TestXRCpuImage : MonoBehaviour
    6. {
    7.     public ARCameraManager cameraManager;
    8.    
    9.     void OnEnable()
    10.     {
    11.         cameraManager.frameReceived += FrameChanged;
    12.     }
    13.  
    14.     void OnDisable()
    15.     {
    16.         cameraManager.frameReceived -= FrameChanged;
    17.     }
    18.  
    19.     private void FrameChanged(ARCameraFrameEventArgs args){
    20.         if (!cameraManager.TryAcquireLatestCpuImage(out XRCpuImage image))
    21.             return;
    22.     }
    23.  
    24. }
    25.  
     
    ina likes this.
  2. thomasvaniseghemSB

    thomasvaniseghemSB

    Joined:
    Sep 15, 2022
    Posts:
    13
    Note: I think it might be related to the IOS 16 update. I had it working before I updated to IOS 16.
     
    ina likes this.
  3. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    989
  4. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,078