iOS SwiftUI App crashes on hide keyboard when over Map in simulator and profiler

When using simulator or building to phone tethered and running its default watcher the app will crash with the below workflow. It seeeeems ok once its not connected to usb, but I have run into this before I think even off of it.

I have discovered that when auto closing a keyboard from a textfield entry via return key and a Map zoomed in at unknown value the app will crash consistently over time upon closing the keyboard or at times opening the keyboard.

The errors have been various forms of this Thread 9: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

Even when zoomed out it can crash eventually from repeating the process, it just seems to take a bit longer

recreation flow: Tap on textfield, type on virtual keyboard any number of characters, press return key, repeat

Specs: iOS simulator iPhone 11 Xcode 12.5.1 Swift 5



import SwiftUI

import MapKit



struct ContentView: View {

    

    @State private var isEditing = false

    @State private var searchFieldData: String = ""

    

    var body: some View {

        // also tried VStack, hence the commented out Map below

        ZStack{

            

            MapView()

            

            VStack{

                TextField(

                    "Search Weeeeee",

                    text: $searchFieldData

                ) { isEditing in

                    self.isEditing = isEditing

                    print("ttttt")

                }

                .padding()

                .background(Color(.systemGray6))

                .cornerRadius(50)

                 

                Spacer()

            }

            

            //MapView()

            

        }

    }

}





struct MyAnnotationItem: Identifiable {

    var coordinate: CLLocationCoordinate2D

    let id = UUID()

}



struct MapView: View {

    

    @State private var region = MKCoordinateRegion(

        center: CLLocationCoordinate2D(

            latitude: 40.741852,

            longitude: -73.993878

        ),

        span: MKCoordinateSpan(

            latitudeDelta: 0.01,

            longitudeDelta: 0.01

        )

    )

    

    var annotationItems: [MyAnnotationItem] = [

        MyAnnotationItem(coordinate: CLLocationCoordinate2D(latitude: 40.741668, longitude: -73.994211)),

        MyAnnotationItem(coordinate: CLLocationCoordinate2D(latitude: 40.739990, longitude: -73.994568)),

        MyAnnotationItem(coordinate: CLLocationCoordinate2D(latitude: 40.744028, longitude: -73.998001)),

    ]

    

    var body: some View {

        Map(coordinateRegion: $region,

            annotationItems: annotationItems) {item in

            MapPin(coordinate: item.coordinate)

        }

    }

    

}





struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}
iOS SwiftUI App crashes on hide keyboard when over Map in simulator and profiler
 
 
Q