Structure Builder crashing with EXC_BAD_ACCESS

A case occured where the Structure Builder is crashing with EXC_BAD_ACCESS and the error cannot be handled without the app crashing.

I have two minimalistic models, one even reduced to the minimum of the "coreModel" itself. (See attachment)

  • Each model alone in the StructureBuilder works fine.
  • Using both causes the crash.

Has anyone found a way to handle this error without the app crashing?

override func viewDidLoad() {
    super.viewDidLoad()
    
    let capturedRooms: [CapturedRoom] = [
        loadCapturedRoom(fileName: "appleModel1"),
        loadCapturedRoom(fileName: "appleModel2")
    ]
     
    buildStructure(capturedRooms)
}

func buildStructure(_ capturedRooms: [CapturedRoom]) {
    let structureBuilder = StructureBuilder(options: [])
    
    Task {
        print("----- START BUILDING STRUCTURE -----")
        
        do {
            let capturedStructure = try await structureBuilder.capturedStructure(from: capturedRooms)
        } catch {
            print("----- FAILED BUILDING STRUCTURE -----")
        }
        
        // Crashing with: EXC_BAD_ACCESS
        // This part will never be reached
        print("----- FINISH BUILDING STRUCTURE -----")
    }
}

func loadCapturedRoom(fileName: String) -> CapturedRoom {
    do {
        guard let jsonFileURL = Bundle.main.url(forResource: fileName, withExtension: "json") else {
            fatalError("JSON file not found.")
        }
        let data = try Data(contentsOf: jsonFileURL)
        return try JSONDecoder().decode(CapturedRoom.self, from: data)
    } catch {
        fatalError(error.localizedDescription)
    }
}

Post not yet marked as solved Up vote post of JohnnyBanana Down vote post of JohnnyBanana
357 views
  • Occured on:

    iPhone 15 Pro Max with iOS Version 17.3 and lower.iPad Pro 11-inch 3rd gen with iPadOSVersion 17.2.

    Did not occur on iOSSimulator devices.

Add a Comment