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.
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.
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 thisARAnchor
and then when theARSCNViewDelegate
funcdidUpdate
is called, we can use setWorldOrigin(relativeTransform:)?(or maybe better
session(_ session: ARSession, didUpdate anchors: [ARAnchor])
ofARSessionObserver
, to not be dependent on SceneKit.)