Medwe
Medwe

Reputation: 328

Error: "connection to service named com.apple.MapKit.SnapshotService" when starting MKMapSnapshotter

I try to create a snapshot of my map view to display later so I don't have another map view wasting memory.

Most of the time it works just fine, but recently I tried creating a snapshot of Paris and got the Error: "connection to service named com.apple.MapKit.SnapshotService".

I know it looks like a cut a part but no, it seems this is the whole error description.

Full Error:

Error Domain=MKErrorDomain Code=1 "(null)" UserInfo=. {NSUnderlyingError=0x284562610 {Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.MapKit.SnapshotService" UserInfo={NSDebugDescription=connection to service named com.apple.MapKit.SnapshotService}}}

I've tried multiple times, but it seems when taking a snapshot of Paris it just won't ever work out as it does for other cities. I've really got no clue where I could start solving the problem as I didn't find any information on the origin of my error.

EDIT: The behaviour actually does appear seemingly random in other cities too.

In viewDidLoad I initialize my options object like so:

snapShotOptions.size = mapView.frame.size
snapShotOptions.scale = UIScreen.main.scale
snapShotOptions.showsBuildings = false

When the user now decides to go on, I initialize & start the snapshotter and handle data accordingly, before that I also set the region for the snapshot:

snapShotOptions.region = mapView.region
snapShotter = MKMapSnapshotter(options: snapShotOptions)

// Take a snapshot.
snapShotter.start { (snapshot, error) -> Void in
    if error == nil {
        completionHandler(snapshot?.image ?? UIImage())
    } else {
        print(error!)
    }
}

I hope someone can help me out here or at least give me a clue as to what the error actually means!

Upvotes: 10

Views: 629

Answers (1)

BB-8
BB-8

Reputation: 111

Recently, I encountered the same phenomenon. In my case, it happens when I take a snapshot in a situation where a memory warning is occurring.

If this issue has already been resolved, I would be grateful if you could provide information.

Upvotes: 0

Related Questions