CartoDB / mobile-ios-samples

iOS mobile app with CARTO Mobile SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

royherma opened this issue · comments

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?

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!

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.

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

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.

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?

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?

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

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.

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.

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