ARKit, visionOS: Creating my own data provider

As the scene data providers in ARKit on visionOS simulator are not supported, I try to create my own with dummy data.

As soon as I try to run an ARKit session with an instance of that provider I get a crash (EXC_BREAKPOINT).

So what am I doing wrong?

Definition of data provider:

@available(visionOS 1.0, *)
public final class TestSceneDataProvider: DataProvider, Equatable, @unchecked Sendable {
    public static func == (lhs: TestSceneDataProvider, rhs: TestSceneDataProvider) -> Bool {
        lhs.id == rhs.id
    }
    
    public typealias ID = UUID
    
    public var id: UUID = UUID()
    
    public static var isSupported: Bool = true
    
    public static var requiredAuthorizations: [ARKitSession.AuthorizationType] = []
    
    public var state: DataProviderState = .initialized
    
    public var description: String = "TestSceneDataProvider"
}

Running the session:

            do {
                if TestSceneDataProvider.isSupported {
                    print("ARKitSession starting.")
                    let sceneReconstruction = TestSceneDataProvider()
                    try await session.run([sceneReconstruction])
                }
            } catch {
                print("ARKitSession error:", error)
            }

Answered by Vision Pro Engineer in 772267022

Sorry, creating your own data provider types is not supported.

Accepted Answer

Sorry, creating your own data provider types is not supported.

Most of the data providers give you some mesh information that you then need to place into an entity as a collision component.

If you’re trying to get planes or world meshes to test interactions with, you may try adding those entities yourself instead of going through the ARKit providers.

I did this with some Planes so I could test plane interactions like placing things on walls.

ARKit, visionOS: Creating my own data provider
 
 
Q