SIGABRT when navigating from ARView with cameraMode = `nonAR` to a regular AR mode ARView

179 Views Asked by At

I'm using SwiftUI and RealityKit to make an AR app. I am trying to transition from a nonAR camera mode ARView to a regular ARView using a NavigationLink, but I'm running into a SIGABRT and see the following error whenever I select the link:

validateTextureDimensions, line 1227: error 'MTLTextureDescriptor has width (4294967295) greater than the maximum allowed size of 16384.'

I've reproduced this behavior in a fresh RealityKit app with these simple views:

// ContentView (nonAR ARView)
import SwiftUI
import RealityKit

struct ContentView : View {
    var body: some View {
        NavigationView {
        VStack {
            ARViewContainer().edgesIgnoringSafeArea(.all)
            NavigationLink(destination: ContentView2()) {
                Text("Go!")
            }
        }
       }

    }
}

struct ARViewContainer: UIViewRepresentable {
    
    func makeUIView(context: Context) -> ARView {
        
        let arView = ARView(frame: .zero, cameraMode: .nonAR, automaticallyConfigureSession: true)
        return arView
        
    }
    
    func updateUIView(_ uiView: ARView, context: Context) {}
    
}



// ContentView2 (AR ARView)

import SwiftUI
import RealityKit

struct ContentView2: View {
    var body: some View {
        return ARViewContainer2().edgesIgnoringSafeArea(.all)
    }
}


struct ARViewContainer2: UIViewRepresentable {
    
    func makeUIView(context: Context) -> ARView {
        
        let arView = ARView(frame: .zero)
        return arView
        
    }
    
    func updateUIView(_ uiView: ARView, context: Context) {}
    
}

It seems like some cleanup needs to be performed with the first nonAR ARView before navigating but I'm not sure what the best way to manage that is. I saw the answer in this post and I tried adding a @Binding to ARViewContainer that I set in the parent view to flag to that the uiview should be removed in updateUIView before navigating, but I'm still hitting the crash :/ Any help here would be greatly appreciated!

1

There are 1 best solutions below

0
On

I ended up resolving this for the time being by using a SceneKit view in place of the nonAR AR view.