I have found that my Vision Pro device can get into a state where my app is no longer receiving fresh SceneReconstructionProvider updates. It reports that the SceneReconstructionProvider goes into the DataProviderState.running state, and .anchorUpdates will report a set of stale mesh anchors when first fired up, but does not produce any further updates. Once the device gets into this state, I can force quit the app, and even uninstall and re-install it, and I get the same few mesh updates, but no fresh updates until I restart the device.
Sample async function below. I can confirm that print("WE FELL OFF THE END OF sceneReconstruction.anchorUpdates") never gets executed, so it stays inside the sceneReconstruction.anchorUpdates loop.
let session = ARKitSession()
var handTracking = HandTrackingProvider()
let sceneReconstruction = SceneReconstructionProvider()
let planeDetection = PlaneDetectionProvider(alignments: [.horizontal, .vertical])
let worldTracking = WorldTrackingProvider()
...
func start() async {
do {
await requestAuth()
if dataProvidersAreSupported && isReadyToRun && !isRunning {
// print("ARKitSession starting.")
try await session.run([sceneReconstruction, handTracking, planeDetection, worldTracking])
startCount += 1
// TODO: Fail gracefully if we have to attempt start too many (# TBD) times
} else {
print("dataProvidersAreSupported: \(dataProvidersAreSupported). isReadyToRun: \(isRunning)")
print("handTracking.state: \(handTracking.state), sceneReconstruction.state: \(sceneReconstruction.state) worldTracking.state: \(worldTracking.state), planeDetection.state; \(planeDetection.state)")
}
}catch {
print("ARKitSession error:", error)
}
}
...
func processReconstructionUpdates() async {
while (true) {
for await update in sceneReconstruction.anchorUpdates {
let meshAnchor = update.anchor
guard let shape = try? await ShapeResource.generateStaticMesh(from: meshAnchor) else { continue }
switch update.event {
case .added:
let entity = try! await generateModelEntity(geometry: meshAnchor.geometry)
entity.transform = Transform(matrix: meshAnchor.originFromAnchorTransform)
entity.collision = CollisionComponent(shapes: [shape], isStatic: true)
entity.components.set(InputTargetComponent())
entity.name = "mesh"
entity.physicsBody = PhysicsBodyComponent(mode: .static)
let sortComponent = ModelSortGroupComponent(group: modelSortGroup, order: 1)
entity.components.set(sortComponent)
entity.components.set(OpacityComponent(opacity: 0.5))
meshEntities[meshAnchor.id] = entity
meshesParent.addChild(entity, preservingWorldTransform: true)
case .updated:
guard let entity = meshEntities[meshAnchor.id],
let updatedEntity = try? await generateModelEntity(geometry: meshAnchor.geometry) else { continue }
entity.transform = Transform(matrix: meshAnchor.originFromAnchorTransform)
entity.collision?.shapes = [shape]
if let newMesh = updatedEntity.model?.mesh {
entity.model?.mesh = newMesh
}
case .removed:
meshEntities[meshAnchor.id]?.removeFromParent()
meshEntities.removeValue(forKey: meshAnchor.id)
}
print("We now have '\(meshEntities.count)' mesh entities")
}
print("WE FELL OFF THE END OF sceneReconstruction.anchorUpdates")
try? await Task.sleep(nanoseconds: 1_000_000)
}
Post
Replies
Boosts
Views
Activity
I am getting the error "Initializing hosting entity without a context" in the console when I build and run my game in XCode 16.0 beta, targeting Vision Pro OS 2.0 (22N5252n).
Not sure where the error is originating.