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

Error when MGLOfflineStorageDelegate redirects a resource URL to a local file URL #16427

Closed
1ec5 opened this issue Apr 24, 2020 · 1 comment · Fixed by #16428
Closed

Error when MGLOfflineStorageDelegate redirects a resource URL to a local file URL #16427

1ec5 opened this issue Apr 24, 2020 · 1 comment · Fixed by #16428
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Comments

@1ec5
Copy link
Contributor

1ec5 commented Apr 24, 2020

If you implement -[MGLOfflineStorageDelegate offlineStorage:URLForResourceOfKind:] to redirect a resource URL to a local file URL, such as the URL of a resource bundled with the application, the request fails because the URL response doesn’t come over HTTP:

// This should never happen.
response.error = std::make_unique<Error>(Error::Reason::Other,
"Response class is not NSHTTPURLResponse");

To reproduce this issue, set MGLOfflineStorage.delegate to a class that implements -[MGLOfflineStorageDelegate offlineStorage:URLForResourceOfKind:] like so:

- (NSURL *)offlineStorage:(MGLOfflineStorage *)storage URLForResourceOfKind:(MGLResourceKind)kind withURL:(NSURL *)url {
    if (kind == MGLResourceKindImage && [url.scheme isEqualToString:@"boxmap"]) {
        return [[NSBundle bundleForClass:[self class]] URLForResource:@"glyphs" withExtension:@"png"];
    }
    return url;
}

/cc @mapbox/maps-ios

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Apr 24, 2020
@1ec5 1ec5 self-assigned this Apr 24, 2020
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 24, 2020

#16428 fixes this particular error in a tightly scoped way, which I think is valid. However, I think it’s worth investigating whether local file URLs returned by the delegate should end up going through mbgl::LocalFileSource instead of mbgl::HTTPFileSource, just as they would when loading a style from a file URL.

/cc @mapbox/gl-native

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant