AR app crashes on iOS18: SlamAnchor.cpp:37 : HasValidPose()

We tried out our Unity-based AR app for the very first time under iOS 18 and noticed an immediate, repeatable crash.

When run in Xcode 16, we get this error message:

Assert: /Library/Caches/com.apple.xbs/Sources/AppleCV3D/library/VIO/CAPI/src/SlamAnchor.cpp:37 : HasValidPose() Assert: /Library/Caches/com.apple.xbs/Sources/AppleCV3D/library/VIO/CAPI/src/SlamAnchor.cpp:37 : HasValidPose()

That's a blocker to us.

We're using Unity 2022.3.27f1.

Answered by DTS Engineer in 805264022

Generally speaking, you'll want to get support from Unity if you change something in their integration of ARKit lifecycle like this: "our app delays [Unity's] AR initialisation on first app start".

The last messages from Unity in the Xcode log are:

UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x3033ea900 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x302861680 imageResolution=(1920, 1440) pixelFormat=(420f) framesPerSecond=(60) captureDeviceType=AVCaptureDeviceTypeBuiltInWideAngleCamera captureDevicePosition=(1)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=None collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None maximumNumberOfTrackedImages=0 automaticImageScaleEstimation=Disabled detectionImages=[count: 5, <name="B6682C11-1D0B-F34C-9D56-ED47198E76EA", physicalSize=(0.460, 0.434)>, <name="2402EEA5-7849-3240-9BC2-EA2C74BA965A", physicalSize=(0.300, 0.371)>, <name="87D47FD5-B984-2F4F-8ACC-F139DEAD64ED", physicalSize=(0.400, 0.314)>, <name="D4982507-114D-8D49-9C70-6C513E6F17CF", physicalSize=(0.110, 0.064)>, <name="341728DD-2A44-0C41-AFA3-51C1E9F3B856", physicalSize=(0.430, 0.359)>] appClipCodeTracking=Disabled>

UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x3033fd700 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x302861680 imageResolution=(1920, 1440) pixelFormat=(420f) framesPerSecond=(60) captureDeviceType=AVCaptureDeviceTypeBuiltInWideAngleCamera captureDevicePosition=(1)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=None collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None maximumNumberOfTrackedImages=0 automaticImageScaleEstimation=Disabled detectionImages=[count: 6, <name="B6682C11-1D0B-F34C-9D56-ED47198E76EA", physicalSize=(0.460, 0.434)>, <name="2402EEA5-7849-3240-9BC2-EA2C74BA965A", physicalSize=(0.300, 0.371)>, <name="87D47FD5-B984-2F4F-8ACC-F139DEAD64ED", physicalSize=(0.400, 0.314)>, <name="256FA82D-DE1F-CE49-A4FF-5824728C7845", physicalSize=(0.500, 0.834)>, <name="D4982507-114D-8D49-9C70-6C513E6F17CF", physicalSize=(0.110, 0.064)>, <name="341728DD-2A44-0C41-AFA3-51C1E9F3B856", physicalSize=(0.430, 0.359)>] appClipCodeTracking=Disabled>

Just realized that these crashes happen only on the very first app start (which is a super bad UX, of course).

Later starts just work fine.

The main difference is that our app delays AR initialisation on first app start, because we show a couple of onboarding screens first.

If you want to try the app out, you can find it as "Marbleverse" in the App Store.

Generally speaking, you'll want to get support from Unity if you change something in their integration of ARKit lifecycle like this: "our app delays [Unity's] AR initialisation on first app start".

I was able to fix the issue on Unity side, by using AddComponent<ARAnchor>() instead of ARAnchorManager.addAnchor(pose). Unity seems to do things differently in the former approach.

Yet whatever it is, I still believe this is a regression in iOS 18, though, since it worked well in iOS 17.

Glad to hear about the workaround!

If you feel this is something ARKit engineering needs to look at then please file a bug report with the Feedback Assistant.

AR app crashes on iOS18: SlamAnchor.cpp:37 : HasValidPose()
 
 
Q