ARWorld loading works differently on iOS 15

There is a difference in how ARWorldMap loading/relocalization works on iOS 14 and 15, which is not mentioned in iOS 15 release notes.

Whenever you start an AR session by providing an initialWorldMap and relocalization succeeds, on iOS 14 the AR world's origin is automatically updated to match the previously saved world's origin. However, on iOS 15 it's not.

In my case, I've used RealityKit for rendering and found out about it by creating an AnchorEntity() (default identity transform) and adding it to my ARView's scene after relocalization. On iOS 14, it is placed where the previously saved session started, as expected. While on iOS 15, it is placed exactly where the current session started.

It's not the case for the Apple's sample: Saving and Loading World Data, because the virtual object is restored using ARSessionDelegate's method where a previously saved ARAnchor is provided by the session. This is also the solution I use right now – to add an anchor before saving the world so you can use it later to e.g. update the world's origin using setWorldOrigin(relativeTransform:).

I'm sharing in case someone runs into this problem, and it'd be great if someone at Apple could confirm that's the desired behavior.

Answered by Graphics and Games Engineer in 690203022

Hi, if there is a difference in how your app runs between iOS 14 and iOS 15 without you using new APIs, then please file this as a bug on Feedback Assistant. Post the feedback number here, and if this is indeed expected behavior, the feedback item will get sent back to you. Then you can update this post with that info. My guess is this is a bug, but file the bug so it can get routed to ARKit for confirmation.

Meant to post my response as a comment rather than an answer. I'd delete this if I could figure out how to do it.

Thank you so much for this. This change has really broken my app, and I was having no luck at all figuring out how to address it. I will give this a shot.

Accepted Answer

Hi, if there is a difference in how your app runs between iOS 14 and iOS 15 without you using new APIs, then please file this as a bug on Feedback Assistant. Post the feedback number here, and if this is indeed expected behavior, the feedback item will get sent back to you. Then you can update this post with that info. My guess is this is a bug, but file the bug so it can get routed to ARKit for confirmation.

I’d like to take the opportunity to reemphasize the purpose of ARAnchors: By adding a user ARAnchor you tell ARKit that you’re interested in that location, which is important in case of pose graph updates as ARKit’s internal map is growing. In order words, this helps ARKit to optimize world-tracking accuracy in the area around the anchor, so that virtual objects appear to stay in place relative to the real world. Therefore, even if your application doesn't use the save/load map API, it’s generally recommended to always add virtual content using ARAnchors, rather than simply placing it in world coordinates (see also the ARAnchor documentation).

For best practices on restoring virtual content after relocalizing to a saved ARWorldMap, please refer to this developer sample.

If I'm not mistaken, the transform of this ARAnchor that was added just before saving will not be updated after a relocalization until the moment it is in the camera's field of view again. So the after relocalization, the user should be made to point the camera at this ARAnchor and then when the ARSCNViewDelegate func didUpdate is called, we can use setWorldOrigin(relativeTransform:)?

(or maybe better session(_ session: ARSession, didUpdate anchors: [ARAnchor]) of ARSessionObserver, to not be dependent on SceneKit.)

Could someone elaborate a bit on the workaround, please. I’m apparently not getting it. I’ve tried creating an anchor a Identity at save time, then setting that anchor as origin when loaded. But, it appears that origin remains at session start position. I imagine I’m just missing the point. Any guidance would be helpful. Thanks in advance.

The issue appears to have been fixed in iOS 15.2. Nothing about it in the release notes but it looks like relocalization works like it used to, again.

ARWorld loading works differently on iOS 15
 
 
Q