Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

validateNewTexture:89: failed assertion `BytesPerRow of a buffer-backed texture

I have two view controllers presented as modals. One shows Google Maps and returns a selected location using unwind segue and second simply shows map.

The crash when i dismiss the modal VC on 8 Plus device running’s 12.4.1. The exception is this.

validateNewTexture:89: failed assertion `BytesPerRow of a buffer-backed texture with pixelFormat(MTLPixelFormatBGRA8Unorm) must be aligned to 64 bytes, found bytesPerRow(4976)

Both above are working fine in 8 Plus simulator, iPhone 6 device both running iOS 12.4.1. Works on iOS 13 simulator also.

This exception happens in my source VC code below. The crash happen on DispatchQueue line.

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)


    }
}

Project set for Swift 5 and deployment target iOS 12.

I have upgraded to XCode 11 today.

i have not changed the code since one year !! Tried clean folder, Xcode restart also but no success.

Code of one VC that shows map and stacktrace is below.

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)

    }

 }

The stacktrace is as below

- 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"
like image 202
ashishn Avatar asked Jan 01 '23 15:01

ashishn


1 Answers

Weirdly enough, I fix it by disable Metal API Validation. Go to your Scheme -> Run -> Options -> In Metal API Validation, select Disabled in the drop down menu

enter image description here

like image 139
hientrq Avatar answered Feb 05 '23 20:02

hientrq