Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Failed to decode tile" when trying to load a raster map #20

Open
royherma opened this issue Aug 20, 2018 · 10 comments
Open

Getting "Failed to decode tile" when trying to load a raster map #20

royherma opened this issue Aug 20, 2018 · 10 comments

Comments

@royherma
Copy link

royherma commented Aug 20, 2018

When debugging and trying to load a tile of a valid url (we check and it even just displays an image of the tile directly from url), as so:

https://maps.xxxx.com/data/satellite/1/1/1.jpg

However, when loading the tiles in our app we are getting errors and unsuccessfully loading/displaying them in the map view.

Our logic for loading is simple:

/* Satellite Layer */
    NTTileDataSource* satelliteDataSource =
    [[NTHTTPTileDataSource alloc] initWithMinZoom:0 maxZoom:14 baseURL:kSatelliteMapURL];
    NTRasterTileLayer *satelliteLayer = [[NTRasterTileLayer alloc]initWithDataSource:satelliteDataSource];

The errors we are getting in the console log are a variety of these:

HTTPTileDataSource::loadTile: Loading https://maps.xxxx.com/data/satellite/1/1/1.jpg
Aug 20 17:40:31  xxxx[916] <Info>: HTTPTileDataSource::loadTile: Loading https://maps.xxxx.com/data/satellite/1/1/1.jpg
2018-08-20 17:40:32.012338+0300 xxxx[916:212385] Bitmap::loadFromCompressedBytes: Unsupported image format
Aug 20 17:40:32  xxxx[916] <Error>: Bitmap::loadFromCompressedBytes: Unsupported image format
2018-08-20 17:40:32.012542+0300 xxxx[916:212385] RasterTileLayer::FetchTask: Failed to decode tile
Aug 20 17:40:32  xxxx[916] <Error>: RasterTileLayer::FetchTask: Failed to decode tile

We have confirmed that this logic works for our android and web app, but not for ios - with the same link and everything.

Any ideas on why this is happening?

@royherma
Copy link
Author

Furthermore, I should state that the example provided in the Advanced Map demo proj, basemap styles vector/raster map (the bottom leftmost) doesn't load!

@jaakla
Copy link
Contributor

jaakla commented Aug 21, 2018

The given URL https://maps.xxxx.com/data/satellite/1/1/1.jpg does not respond to me, so not sure what can be wrong with it. Maybe your ssl cert has issues?

Bottom left sample is Reverse Geocoding to me, but we have many samples and platforms, a screenshot may give better idea what do you mean here.

@royherma
Copy link
Author

Here is the screenshot of the specific example that isn't working in this repo:

simulator screen shot - iphone 8 - 2018-08-23 at 11 14 53

This is the same problem we are having in our project - unable to load satellite/http tiles, and getting the same error as written in the original post.

The xxxx url I example is an obfuscated on purpose, sorry for not making that clear.

Let me know if anything else is missing so we can get to fixing this ASAP.

@jaakla

jaakla pushed a commit that referenced this issue Aug 23, 2018
@jaakla
Copy link
Contributor

jaakla commented Aug 23, 2018

The error "Unsupported image format" means that SDK gets something not expected from the given URL. Without real URL sample it is impossible to tell what is wrong with it.

The "Voyager raster" basemap URL for Objective-C SAMPLE was not updated, this is fixed now.

@royherma
Copy link
Author

royherma commented Aug 23, 2018

I replaced the url with what you've pushed in the commit, and still facing the same issue:

AdvancedMap.Objective-C[73065] <Info>: HTTPTileDataSource::loadTile: Loading https://maps.gk.com/data/satellite/5/18/11.jpg
2018-08-23 16:44:53.871643+0300 AdvancedMap.Objective-C[73065:15073159] Bitmap::loadFromCompressedBytes: Unsupported image format
Aug 23 16:44:53  AdvancedMap.Objective-C[73065] <Error>: Bitmap::loadFromCompressedBytes: Unsupported image format
2018-08-23 16:44:53.873743+0300 AdvancedMap.Objective-C[73065:15073159] RasterTileLayer::FetchTask: Failed to decode tile
Aug 23 16:44:53  AdvancedMap.Objective-C[73065] <Error>: RasterTileLayer::FetchTask: Failed to decode tile

This is the same issue we're facing in our project. Can you confirm you are able to load the "voyager carto raster" map at all?

@jaakla
Copy link
Contributor

jaakla commented Aug 23, 2018

Voyager raster after the fix works fine for me. The URL you try to use with jpg does not work for me also, and gives same error. This does not look ok, we'll check it. I tried with http://www.maptiler.com/ own URL (...Url = "https://maps.tilehosting.com/data/satellite/{z}/{x}/{y}.jpg?key=redacted";) and satellite from there works fine then. Could you have e.g. a firewall, CDN or something else which modifies SDK HTTP traffic compared to web browser requests?

@royherma
Copy link
Author

royherma commented Aug 23, 2018

The only difference in urls is jpg vs png - perhaps that is the issue?

As you can see, going directly to the URL does work and loads a tile (https://maps.gk.com/data/satellite/5/18/11.jpg)

Also, this url works for Android & Web. Awaiting response from you after checking the issue to see how to proceed.

Thanks @jaakla

@jaakla
Copy link
Contributor

jaakla commented Aug 24, 2018

The working tilehosting.com url has also jpg and I believe server software and data is also same, from Maptiler cloud. The http is slightly different from browsers and apps/sdk.

@jaakla
Copy link
Contributor

jaakla commented Aug 27, 2018

The difference seems to be that globekeeper.com has additional HTTP-level gzip encoding in top of jpg. For example tilehosting.com does not use this, as it is not best idea - it makes extra load to both server and client, and does not reduce jpg encoded images much; it can even increase their size in some cases. So for already compressed images like jpg and also png gzip encoding should not be used.

The server behaviour is also not compatible with HTTP, the response should take into account request header Accept-Encoding, which SDK does not send, so it should not do compression. Even if I tried to force no compression with Accept-Encoding: identity request header (you can set custom HTTP headers within SDK) then the server keeps sending gzip-encoded data, so this looks like broken server config.

Our SDK HTTP client part does not support gzip-encoded raster tile images. Current quick solution is turn off the universial gzip encoding in the server side; in the web server conf or add CDN to your service, these should all have proper compression negotiation with client. We'll update SDK also to be ready for such server responses.

For example for vector tiles gzip encoding compresses data a lot, so it is common, suggested and supported configuration.

@mtehver
Copy link
Contributor

mtehver commented Oct 31, 2018

@royherma SDK 4.1.4 should automatically un-gzip all raster images, so it is worth a try now.

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

No branches or pull requests

3 participants