Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[IOS] : Invalid offline region definition (Crashed) #7925

Closed
ThiyagarajanShivSankaran opened this issue Feb 2, 2017 · 8 comments
Closed

Comments

@ThiyagarajanShivSankaran

Hi,

I am getting this warning in console,

[DEBUG] {DefaultFileSource}[Database]: Unable to make space for entry

then the app is crashed with exception,

libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: Invalid offline region definition.

I know there is a seperate issue for [DEBUG] {DefaultFileSource}[Database]: Unable to make space for entry.

But i need some quick fix, please.

Thanks.

@jmkiley jmkiley added crash iOS Mapbox Maps SDK for iOS offline labels Feb 2, 2017
@jfirebaugh
Copy link
Contributor

Can you provide the code that creates the offline region that causes this crash?

@ThiyagarajanShivSankaran
Copy link
Author

Hi @jfirebaugh ,

Here is the method, i am using to download offline pack,

func startOfflinePackDownload() {
    
    let mapBound = MGLCoordinateBoundsMake(CLLocationCoordinate2D(latitude: _latSW, longitude: _lngSW), CLLocationCoordinate2D(latitude: _latNE, longitude: _lngNE))
    
    let region = MGLTilePyramidOfflineRegion(styleURL: mapView.styleURL, bounds: mapBound, fromZoomLevel: mapView.zoomLevel, toZoomLevel: 15)
    
    // Store some data for identification purposes alongside the downloaded resources.
    let userInfo = ["name": "My Offline Pack"]
    let context = NSKeyedArchiver.archivedData(withRootObject: userInfo)
    
    // Create and register an offline pack with the shared offline storage object.
    MGLOfflineStorage.shared().addPack(for: region, withContext: context) { (pack, error) in
        guard error == nil else {
            // The pack couldn’t be created for some reason.
            print("Error")
            return
        }
        
        // Start downloading.
        pack!.resume()
    }
}

And the code is crashing at pack!.resume(). Hey, sorry for the delay @jfirebaugh.

Thanks.

@1ec5
Copy link
Contributor

1ec5 commented Feb 6, 2017

At the time of the crash, what is mapView's zoomLevel set to?

@ThiyagarajanShivSankaran
Copy link
Author

Hi @1ec5,

Initially, self.mapView.zoomLevel = 11. After zooming in to level 15 or 16 and leave the map ideal for some 5 seconds or tapping on a feature it is getting crashed.

And, it is not crashing everytime. One or two times a day.

@1ec5
Copy link
Contributor

1ec5 commented Feb 7, 2017

OK, the reason I ask is that startOfflinePackDownload() creates an MGLTilePyramidOfflineRegion with a minimum zoom level of mapView.zoomLevel and a maximum zoom level of 15. The minimum zoom level must be no greater than the maximum zoom level; otherwise, an exception will be thrown. Can you verify that the minimum zoom level is correct for the offline pack?

@ThiyagarajanShivSankaran
Copy link
Author

ThiyagarajanShivSankaran commented Feb 8, 2017

OK, the reason I ask is that startOfflinePackDownload() creates an MGLTilePyramidOfflineRegion with a minimum zoom level of mapView.zoomLevel and a maximum zoom level of 15. The minimum zoom level must be no greater than the maximum zoom level; otherwise, an exception will be thrown. Can you verify that the minimum zoom level is correct for the offline pack?

Awesome @1ec5. Thanks you, for your reply.

@jfirebaugh
Copy link
Contributor

Closing as a special case of #7890.

@htinc
Copy link

htinc commented Jul 9, 2017

Wee I had the same issue and its just a bad thing now, because if you switch from vector-map to a satellite map, we have to zoom out and in again...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants