cyclestreets / ios

iPhone app
https://www.cyclestreets.net/mobile/iphone/
178 stars 149 forks source link

Map tiles showing wrongly on iOS 13 on larger screen sizes #118

Open mvl22 opened 5 years ago

mvl22 commented 5 years ago

"Since latest iOS update I am getting multiple images on the map on my iPhone 8 Plus. No problem with other smaller iPhones. Reinstalling hasn’t helped."

si-the-pie commented 5 years ago

IMG_399AC533EFBF-1

The image shows tiles repeating themselves across the page. Happens on these route map styles:

However this style does work fine (and so is the recommended work-around):

This style doesn't work, only some of the street text and road numbers appear but the rest is blank:

As experienced on iPhone 7 Plus 13.1.2

mvl22 commented 5 years ago

cyclestreets111500

mvl22 commented 5 years ago

I can confirm this isn't a problem on iOS13 on an iPhone6S device.

So perhaps this is specific to particular larger screen sizes, i.e. later devices.

mvl22 commented 5 years ago

Simon's phone requests tiles at 3x size as:

/opencyclemap/16/32794/21588@3x.png

from the tileserver.

mvl22 commented 5 years ago

I suspect the problem relates to the fact that 3x tiles are being requested (which are 768x768px), but the retina tile renderer has references only to sizes 256 and 512:

https://github.com/cyclestreets/ios/blob/master/src/maps/CSRetinaTileRenderer.m

On the request side, this code I suspect is receiving 3 for %i:

https://github.com/cyclestreets/ios/blob/master/src/maps/CSOpenCycleMapSource.m#L71-L79 https://github.com/cyclestreets/ios/blob/master/src/maps/CSMapSource.m#L272-L288 https://github.com/cyclestreets/ios/blob/master/src/maps/CSRetinaTileRenderer.m#L98

Looks like MKTileOverlayPath receives the contentScaleFactor parameter from MapKit, i.e. the OS. The MapKit documentation states:

"This value is typically either 1.0 (for standard resolution displays) or 2.0 (for Retina displays)."

but perhaps there has been a change in iOS13 to supply 3.0 rather than 2.0 but this documentation not updated.

mvl22 commented 5 years ago

The following server-side fix is now installed on the tileserver/cache config as a workaround, targetting the CycleStreets/428 release when scale is 3, downgrading it to 2, which is confirmed as fixing the issue in the app:

# Workaround bug in iOS app on iOS13; see: https://github.com/cyclestreets/ios/issues/118
if (substr_count ($_SERVER['HTTP_USER_AGENT'], 'CycleStreets/428')) {
    if (isSet ($_GET['scale']) && ($_GET['scale'] == '3')) {
        $_GET['scale'] = '2';
    }
}

However, the problem still needs to be fixed properly in the iOS codebase.

si-the-pie commented 5 years ago

Can we tell users that the problem is now fixed?

The immediate problem is that cached tiles will still appear and so they will think the app is still broken.

Searches suggest that the only way of clearing the app cache is to remove the app and re-install it, which is obviously a bit of a faff. Do we know how long the app keeps the tiles? The response header has Expires after 24 hours. So maybe just wait until tomoz.