J'ai deux contrôleurs de vue présentés comme des modales. L'un d'eux affiche Google Maps et renvoie un emplacement sélectionné à l'aide d'une segue unwind et le second affiche simplement la carte.
Le crash lorsque je rejette la VC modale sur un appareil 8 Plus fonctionnant sous 12.4.1. L'exception est la suivante.
validateNewTexture:89 : échec de l'assertion `BytesPerRow of a avec pixelFormat(MTLPixelFormatBGRA8Unorm) doit être alignée sur 64 octets. être aligné sur 64 octets, trouvé bytesPerRow(4976)
Les deux éléments ci-dessus fonctionnent bien dans un simulateur 8 Plus, un appareil iPhone 6 fonctionnant sous iOS 12.4.1. Fonctionne également sur le simulateur iOS 13.
Cette exception se produit dans mon code source VC ci-dessous. Le crash se produit sur la ligne DispatchQueue.
override func viewWillAppear(_ animated: Bool) {
// to ensure the scroll view starts below navigation bar.
if #available(iOS 11.0, *) {
self.scrollView.contentInsetAdjustmentBehavior = .automatic
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
let spinner = CommonHelper.showActivityIndicatorAndStopInteraction(self.view, style: UIActivityIndicatorView.Style.gray)
DispatchQueue.main.async {
PFUser.current()?.fetchInBackground(block: { (user, error) in
CommonHelper.hideActivityIndicatorAndStartInteraction(spinner)
}
}
Projet établi pour Swift 5 et objectif de déploiement iOS 12.
J'ai effectué une mise à niveau vers XCode 11 aujourd'hui.
je n'ai pas changé le code depuis un an ! !! J'ai essayé de nettoyer le dossier, de redémarrer Xcode aussi mais sans succès.
Le code d'un VC qui montre la carte et la trace de la pile est ci-dessous.
class MapViewController: UIViewController {
@IBOutlet weak var mapView: GMSMapView!
@IBOutlet weak var selectedAddress: UILabel!
var userLattitude: Double = 0
var userLongitude: Double = 0
var selectedCoordinate: CLLocation?
var selectedCity: String?
var selectedname: String?
// to be used on unwind to restore values
var userAddress = ""
let locationManager = CLLocationManager()
@IBOutlet weak var selectAddress: UIBarButtonItem!
@IBOutlet weak var chooseAddressButton: UIButton!
@IBAction func cancel(_ sender: AnyObject) {
dismiss(animated: true, completion: nil)
}
override func shouldPerformSegue(withIdentifier identifier: String?, sender: Any!) -> Bool {
if identifier == "unwindLocation" || identifier == "unwindLocationSelection" || identifier == "backtoprofile" {
return true
} else {
return false
}
}
override func viewDidLoad() {
super.viewDidLoad()
chooseAddressButton.layer.borderColor = UIColor.flatMint().cgColor
chooseAddressButton.layer.cornerRadius = 5
chooseAddressButton.layer.borderWidth = 1
}
override func viewDidAppear(_ animated: Bool) {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
locationManager.distanceFilter = 50
locationManager.requestWhenInUseAuthorization()
mapView.delegate = self
if selectedCoordinate != nil {
logger.debug("selectedCoordinate \((self.selectedCoordinate?.coordinate.latitude)!) : \((self.selectedCoordinate?.coordinate.longitude)!)")
mapView.isMyLocationEnabled = true
// user had a location selected so display
locationManager.stopUpdatingLocation()
//locationManager.stopMonitoringSignificantLocationChanges()
mapView.camera = GMSCameraPosition(target: selectedCoordinate!.coordinate, zoom: 17, bearing: 0, viewingAngle: 0)
}
}
func reverseGeocodeCoordinate(_ coordinate: CLLocationCoordinate2D) {
let geocoder = GMSGeocoder()
self.selectedCoordinate = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
geocoder.reverseGeocodeCoordinate(coordinate) { response, error in
if let address = response?.firstResult() {
let lines = address.lines! as [String]
self.selectedAddress.text = lines[0]
self.selectedCity = address.locality
}
}
}
}
extension MapViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
if selectedCoordinate != nil {
// locationManager.stopMonitoringSignificantLocationChanges()
locationManager.stopUpdatingLocation()
mapView.camera = GMSCameraPosition(target: selectedCoordinate!.coordinate, zoom: 17, bearing: 0, viewingAngle: 0)
} else {
locationManager.startUpdatingLocation()
}
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if selectedCoordinate != nil {
locationManager.stopMonitoringSignificantLocationChanges()
mapView.camera = GMSCameraPosition(target: selectedCoordinate!.coordinate, zoom: 17, bearing: 0, viewingAngle: 0)
} else if let location = locations.first {
mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 17, bearing: 0, viewingAngle: 0)
locationManager.stopMonitoringSignificantLocationChanges()
}
}
}
extension MapViewController: GMSMapViewDelegate {
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
reverseGeocodeCoordinate(position.target)
}
}
Le suivi de pile est le suivant
- 0 : "0 ??? 0x000000010d5d8a0c 0x0 + 4519201292"
- 1 : "1 Lendable 0x000000010101c1bc main + 0"
- 2 : "2 libsystem_c.dylib 0x00000001b0cabea8 abort + 140"
- 3 : "3 libsystem_c.dylib 0x00000001b0c79afc __assert_rtn + 220"
- 4 : "4 Metal 0x00000001b32ee134 MTLReportFailure + 500"
- 5 : "5 MetalTools 0x00000001d67a933c <redacted> + 1184"
- 6 : "6 MetalTools 0x00000001d67a8bb0 <redacted> + 256"
- 7 : "7 AppleMetalGLRenderer 0x00000001d19267b4 <redacted> + 312"
- 8 : "8 AppleMetalGLRenderer 0x00000001d19357d0 gldFlushObject + 96"
- 9 : "9 GLEngine 0x00000001d2813584 <redacted> + 392"
- 10 : "10 GLEngine 0x00000001d27933cc <redacted> + 496"
- 11 : "11 GLEngine 0x00000001d2842e28 gliBindViewES + 308"
- 12 : "12 OpenGLES 0x00000001b43c19ac <redacted> + 500"
- 13 : "13 MyApp 0x000000010125fec4 _ZN7gmscore8renderer3ios19GLLayerRenderTarget17DeleteFramebufferEv + 164"
- 14 : "14 MyApp 0x000000010125ff3c _ZN7gmscore8renderer3ios19GLLayerRenderTarget20DidStopUsingResourceEv + 20"
- 15 : "15 MyApp 0x00000001012f5f58 __30-[GMSPhoenixRenderer tearDown]_block_invoke + 112"
- 16 : "16 Foundation 0x00000001b1b49ec0 <redacted> + 972"
- 17 : "17 Foundation 0x00000001b1b4bcf0 <redacted> + 128"
- 18 : "18 MyApp 0x00000001012f5ec4 -[GMSPhoenixRenderer tearDown] + 116"
- 19 : "19 MyApp 0x00000001012d7488 -[GMSEntityRendererView tearDownRenderer] + 116"
- 20 : "20 MyApp 0x00000001012d601c -[GMSEntityRendererView dealloc] + 64"
- 21 : "21 MyApp 0x0000000101326978 -[GMSVectorMapView dealloc] + 316"
- 22 : "22 MyApp 0x000000010107fa30 -[GMSMapView .cxx_destruct] + 692"
- 23 : "23 libobjc.A.dylib 0x00000001b038e7cc <redacted> + 148"
- 24 : "24 libobjc.A.dylib 0x00000001b039e6b8 objc_destructInstance + 68"
- 25 : "25 libobjc.A.dylib 0x00000001b039e720 object_dispose + 16"
- 26 : "26 UIKitCore 0x00000001ddc71de8 <redacted> + 152"
- 27 : "27 UIKitCore 0x00000001de0b2c64 <redacted> + 984"
- 28 : "28 MyApp 0x00000001010788f8 -[GMSMapView dealloc] + 264"
- 29 : "29 libobjc.A.dylib 0x00000001b03a9b9c <redacted> + 672"
- 30 : "30 CoreFoundation 0x00000001b11c43b0 _CFAutoreleasePoolPop + 28"
- 31 : "31 UIKitCore 0x00000001ddc4188c <redacted> + 132"
- 32 : "32 UIKitCore 0x00000001ddc6eac4 <redacted> + 204"
- 33 : "33 CoreFoundation 0x00000001b1147d08 <redacted> + 32"
- 34 : "34 CoreFoundation 0x00000001b1142a30 <redacted> + 412"
- 35 : "35 CoreFoundation 0x00000001b1142fac <redacted> + 1228"
- 36 : "36 CoreFoundation 0x00000001b11427c0 CFRunLoopRunSpecific + 436"
- 37 : "37 GraphicsServices 0x00000001b334379c GSEventRunModal + 104"
- 38 : "38 UIKitCore 0x00000001ddc47c38 UIApplicationMain + 212"
- 39 : "39 MyApp 0x000000010101c208 main + 76"
- 40 : "40 libdyld.dylib 0x00000001b0c068e0 <redacted> + 4"