I'm developing an AR Drawing app, and I encountered a bug/problem in AR Kit 3. World tracking stops working and the 3D objects added in the AR view are frozen.
My app switches between front and back camera, in both cases I'm enabling World Tracking.
1. I enable back camera session like this:
let configuration = ARWorldTrackingConfiguration()
configuration.isLightEstimationEnabled = true
configuration.planeDetection = [.horizontal, .vertical]
if #available(iOS 13.0, *) {
configuration.frameSemantics = [.personSegmentationWithDepth]
}
sceneView.session.run(configuration)
Everything works perfect if I just run this configuration on the scene session.
2. When I switch to the front camera like this:
let configuration = ARFaceTrackingConfiguration()
if #available(iOS 13.0, *) {
configuration.isWorldTrackingEnabled = true
}
configuration.isLightEstimationEnabled = true
if #available(iOS 13.0, *) {
configuration.frameSemantics = [.personSegmentation]
}
sceneView.session.run(configuration)
Everything still working perfect.
3. But when I switch back to back camera session (I switch back like point 1.):
The 3D objects added in the AR Scene become frozen in a static view and the world track stops working. And there's no way to getting it back to work, but closing the app and re-opening.
The funny things:
- When I disable the
configuration.isWorldTrackingEnabled = true
part. The bug does not appear. But I do need theconfiguration.isWorldTrackingEnabled = true
being set. - Front camera session never breaks, even after the bug appears if I switch back to front-camera, the world tracking works good there.
Here's a video (no bug appears) of the app with configuration.isWorldTrackingEnabled =
false
:
No bug video - https://www.youtube.com/watch?v=JPAa6zJe_kQ
And here's a video (bug appears) of the app with configuration.isWorldTrackingEnabled =
true
:
Yes bug video - https://www.youtube.com/watch?v=UF2Z8c4A42I
What have I tried already?
- I tried running the app first on front-camera to see if also breaks when I change to the back camera. And yes, it breaks too.
- I tried running a
ARFaceTrackingConfiguration()
withconfiguration.isWorldTrackingEnabled = true
and then re-running it again withconfiguration.isWorldTrackingEnabled = false
to see if it would override anything and fix it. But no lock, still breaking. - I've also tried pausing the session and then re-enabling it between camera switches, but still bugging. Even with delays.
- I've also tried to run the configuration with settings like:
sceneView.session.run(configuration,options: [.resetTracking,.removeExistingAnchors,.stopTrackedRaycasts])
, but still no luck.
Anyone has an idea on how to fix it? Anyone has encountered this weird behaviour?