{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2198","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2198/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2198/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2198/events","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/2198","id":103762159,"number":2198,"title":"MGLAnnotationImage with scale greater than 1.0 causes crash.","user":{"login":"petrmanek","id":1297382,"avatar_url":"https://avatars.githubusercontent.com/u/1297382?v=3","gravatar_id":"","url":"https://api.github.com/users/petrmanek","html_url":"https://github.com/petrmanek","followers_url":"https://api.github.com/users/petrmanek/followers","following_url":"https://api.github.com/users/petrmanek/following{/other_user}","gists_url":"https://api.github.com/users/petrmanek/gists{/gist_id}","starred_url":"https://api.github.com/users/petrmanek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrmanek/subscriptions","organizations_url":"https://api.github.com/users/petrmanek/orgs","repos_url":"https://api.github.com/users/petrmanek/repos","events_url":"https://api.github.com/users/petrmanek/events{/privacy}","received_events_url":"https://api.github.com/users/petrmanek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/crash","name":"crash","color":"ff00ff"},{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/iOS","name":"iOS","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/13","html_url":"https://github.com/mapbox/mapbox-gl-native/milestones/ios-v2.2.0","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/13/labels","id":1278059,"number":13,"title":"ios-v2.2.0","description":"Changes\r\n- Improved tap-and-hold quick zoom gesture (https://github.com/mapbox/mapbox-gl-native/pull/2153)","creator":{"login":"1ec5","id":1231218,"avatar_url":"https://avatars.githubusercontent.com/u/1231218?v=3","gravatar_id":"","url":"https://api.github.com/users/1ec5","html_url":"https://github.com/1ec5","followers_url":"https://api.github.com/users/1ec5/followers","following_url":"https://api.github.com/users/1ec5/following{/other_user}","gists_url":"https://api.github.com/users/1ec5/gists{/gist_id}","starred_url":"https://api.github.com/users/1ec5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1ec5/subscriptions","organizations_url":"https://api.github.com/users/1ec5/orgs","repos_url":"https://api.github.com/users/1ec5/repos","events_url":"https://api.github.com/users/1ec5/events{/privacy}","received_events_url":"https://api.github.com/users/1ec5/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":1,"state":"open","created_at":"2015-08-28T18:13:23Z","updated_at":"2015-10-01T14:20:56Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2015-08-28T17:34:23Z","updated_at":"2015-10-02T14:06:29Z","closed_at":null,"body":"Hello, I'm using MapboxGL 0.5 in my iOS map. When trying to annotate map with images of markers on retina displays, I got this error:\r\n```\r\nlibc++abi.dylib: terminating with uncaught exception of type mbgl::util::SpriteImageException: Sprite image pixel count mismatch\r\n```\r\n\r\nHere's my setup:\r\n```swift\r\nclass MyViewController: UIViewController, MGLMapViewDelegate {\r\n    var mapView: MGLMapView!\r\n\r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        // Create the map view.\r\n        mapView = MGLMapView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))\r\n        mapView.delegate = self\r\n        view.addSubview(mapView)\r\n\r\n        // Add a single marker.\r\n        let point = MGLPointAnnotation()\r\n        point.coordinate = ...\r\n        mapView.addAnnotation(point)\r\n        mapView.setCenterCoordinate(...)\r\n    }\r\n\r\n    func mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {\r\n        // Memory Efficiency: If a marker is available from the reusable queue, make use of it.\r\n        if let pin = mapView.dequeueReusableAnnotationImageWithIdentifier(\"customPin\") {\r\n            return pin\r\n        }\r\n\r\n        // Scale of the image below is automatically selected based on the display's pixel density.\r\n        // Both @1x and @2x version is available. However, only @2x version causes the crash.\r\n        let image = UIImage(named: \"myCustomImage\")!\r\n        return MGLAnnotationImage(image: image, reuseIdentifier: \"customPin\")\r\n    }\r\n}\r\n```\r\n\r\nAs I said in the comments, the crash occurs only when `image.scale > 1.0`. I've attempted to use the @1x version of the image only but that looks blurry and ugly on the retina display.\r\n\r\nTo confirm that the error isn't caused by a malformed image file, I've also tried several other @2x images. All of them crashed the app.\r\n\r\nI have even managed to prove that this bug is caused explicitly by the scale of the image. The following code works because I've manually tuned down the scale of the @2x image from 2.0 to 1.0. The annotation displays on the map view correctly but has double the size of the original image. You can try and substitute any other scale in the `let scaledUpImage...` line to see my point. If you use scale greater than 1.0, you get a crash.\r\n\r\n```swift\r\n    func mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {\r\n        if let pin = mapView.dequeueReusableAnnotationImageWithIdentifier(\"customPin\") {\r\n            return pin\r\n        }\r\n\r\n        // This image will have scale 2.0 on retina displays.\r\n        let image = UIImage(named: \"myCustomImage\")!\r\n\r\n        // Use it to create a new image with scale 1.0 and double size.\r\n        let scaledUpImage = UIImage(CGImage: image.CGImage, scale: 1.0, orientation: .Up)!\r\n        return MGLAnnotationImage(image: scaledUpImage, reuseIdentifier: \"customPin\")\r\n    }\r\n```\r\n\r\nAre there any workarounds?"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/comments/145031130","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/2198#issuecomment-145031130","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2198","id":145031130,"user":{"login":"clearbrian","id":132359,"avatar_url":"https://avatars.githubusercontent.com/u/132359?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbrian","html_url":"https://github.com/clearbrian","followers_url":"https://api.github.com/users/clearbrian/followers","following_url":"https://api.github.com/users/clearbrian/following{/other_user}","gists_url":"https://api.github.com/users/clearbrian/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbrian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbrian/subscriptions","organizations_url":"https://api.github.com/users/clearbrian/orgs","repos_url":"https://api.github.com/users/clearbrian/repos","events_url":"https://api.github.com/users/clearbrian/events{/privacy}","received_events_url":"https://api.github.com/users/clearbrian/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T14:06:29Z","updated_at":"2015-10-02T14:06:29Z","body":"<img width=\"240\" alt=\"simulatorscreensnapz025\" src=\"https://cloud.githubusercontent.com/assets/132359/10248392/253e5918-6917-11e5-8f70-6bf57fa10e76.png\">\r\n"}}