MKTileOverlay custom tiles constantly reloaded

We have an iOS app that switches between different sets of custom map tiles depending on users' needs. Most are standard third-party sources (OpenStreetMap, NOAA marine charts), but we have a new set using image files we've created.


On the iPad these tiles are flickering on and off as iOS keeps asking for them again and again. (With other tile sets each unique tile is only requested once.) After the first request (which we get from our server) these files are in our local cache, and we deliver their data from there, but iOS keeps replacing them with its own tiles and then requesting/redisplaying ours.


The same tiles display just fine on the iPhone, so it doesn't appear to be an issue with the tile image files themselves. Comparing them to a tile set that does work as expected (NOAA's tileservice.charts.noaa.gov) there are differences, but nothing that would seem to explain this behavior.


Both sets are 8-bit RGB, 256 x 256 PNG images, non-interlaced. The NOAA tiles are 72 pixels/inch while ours are 96, and ours have an alpha channel.


Any suggestions as to what might be causing this, and how we might fix it?


Thanks,

Accepted Reply

How big is the data for your tiles, in bytes, right before providing them to the system? You should optimze the data size to be as small as possible. If you don't need the alpha channel, a different data format other than PNG may produce a smaller data size.

Replies

How big is the data for your tiles, in bytes, right before providing them to the system? You should optimze the data size to be as small as possible. If you don't need the alpha channel, a different data format other than PNG may produce a smaller data size.

The problem tiles are considerably larger; in a typical sample they range from 37KB to 130KB while the 'good' tiles (NOAA) range from 2KB to 27KB. I can talk to my client about reducing these image files; what range of sizes should they be aiming for?


With some further testing I find this issue does not occur with iOS 10 (10.3.1 on Simulator iPad Pro 9.7-inch) but does with iOS 11 (11.3 on same simulator and on an iPad Air 2 device). Does that help you understand what might be happening here?

Yes, this seems to be the answer. Saving my sample of these PNG tile files down to JPEG gives me files about 15% to 20% the original sizes, and the flickering has disappeared.


I'll test some more, but this looks like the fix I was seeking.

Another format to consider is HEIF, which can result in image files smaller than JPG in many cases. There were multiple sessions at WWDC 2017 about this format and its benefits - here's a good one to start with.


There isn't specific guidance on the target size to optimize for, as each app's needs are different - a simple tile overlay of basic street data is going to have different size characteristics than detailed satellite images, as an example. The main point to take away is to consider what your actual needs are, and use an appropiate image format that will serve those needs with the smallest data size per map tile.

Hi all,


Just my opinion and feedback on that topic.


I've also an app with MKTileOverlay with PNG 8bit 256*256 tiles. The tiles are offline so stored on the iPad.


With iPad Pro 12.9' the tiles are reload constantly. The tiles sizes are between 1 to 49KB, average is about 17~19KB.


For few years now we work with MapKit and MKTileOverlay and I'm quite scared with the fact that the only workaround is to switch to another format.


Perhaps, open a bug report..?