I then transition back to the world tracking scene
At step 4, tracking seems to be lost, and I can’t recover it. My objects are essentially ‘stuck to the camera’ as they don’t stick to the world. The camera stream is still working (not black, like in some other posts). The tracking is NOT lost if I go to step 2 and then back to the world tracking scene.
Things I’ve tried:
I’ve tried deleting and re-creating the ARSession object.
I’ve tried calling Reset on the ARSession object.
I’ve tried going to an empty scene between steps 3 & 4.
Each scene has its own ARSession & ARSession Origin objects.
I’m using ARFoundation4. Testing on an iPhone XR.
This appears to be a bug in ARKit (specifically iOS 14) and is reproducible in a purely native project (i.e., outside of Unity). It happens when ARFaceTrackingConfiguration.worldTrackingEnabled is true (this uses the user facing camera with 6 degrees of freedom), and the configuration is subsequently changed to an ARWorldTrackingConfiguration (world facing camera).
It does not happen when ARFaceTrackingConfiguration.worldTrackingEnabled is false. In ARFoundation, this corresponds to an [ARSession.requestedTrackingMode](Class ARSession | AR Foundation | 4.0.12) of “Rotation Only”.
As a workaround, when you switch to the user-facing camera, also change the ARSession.requestedTrackingMode to RotationOnly. When you switch back to world facing camera mode, you’ll want to make sure you also switch the requestedTrackingMode back to PositionAndRotation.
Note that older devices, like the iPhone X, do not support the “Position and Rotation” tracking mode while in a user-facing camera mode, so you will only see this situation on newer devices like the iPhone 11.
I don’t think the issue is specific to iOS 14, I replicated this bug also in iOS 13.
I think the issue is applicable to devices that support 6 degrees of freedom on the front camera.
Confirmed both posts! It is indeed an issue with iOS 13 as well, but the fix works either way. I turned tracking to Rotation only for the face tracking AR scene, and tracking in the world tracking scene resumed perfectly fine.
I’ve run into the same issue, unfortunately, with RotationOnly, the face tracking acts slightly differently and it’s enough to throw off my app compared to AR Foundation 3.
Does anyone know of any other options for me? I’m pretty sure AR Foundation 3 isn’t compatible with anything after Unity 2019.