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

Offline raster tiles does not use correct zoom level #9563

Closed
halset opened this issue Jul 20, 2017 · 19 comments
Closed

Offline raster tiles does not use correct zoom level #9563

halset opened this issue Jul 20, 2017 · 19 comments
Labels
bug iOS Mapbox Maps SDK for iOS

Comments

@halset
Copy link
Contributor

halset commented Jul 20, 2017

Platform: iOS
Mapbox SDK version: master as of f19c36a

Steps to trigger behavior

  1. Load raster tiles for offline use. Extra zoom levels for tiles intersecting certain interesting areas.
  2. Go offline.
  3. Zoom in on one of those interesting areas with extra zoom levels.

Expected behavior

The best tiles available at any place are shown.

Actual behavior

When zooming in, first the best tiles are shown. Then the map gets more and more blury as the view shifts to showing less and less detailed tiles.

In the console, lots of messages like this are shown:

[ERROR] {}[Style]: Failed to load tile 10/527/295=>10 for source 

rasterzoom

(The above gif show wifi and cell coverage dots, but those are turned on by QuickTime. This is really offline mode.)

@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

This is not related to offline packs. I do not use offline packs. The tiles got into the database without using offline packs.

@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

Looks like I have a similar, but less visible problem with vector tiles.

@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

This might be a duplicate of #9493, but that one is closed as a dup of som offline pack case. I do not use offline packs.

@fabian-guerra fabian-guerra added bug iOS Mapbox Maps SDK for iOS labels Jul 20, 2017
@jfirebaugh
Copy link
Contributor

My guess is it's caused by #7741. cc @tmpsantos

@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

I bisected this to 9a9408e. cc @kkaefer.

@jfirebaugh
Copy link
Contributor

Great, thanks for bisecting. That means this is a duplicate of #8678 and will be fixed by #9415 / #9468.

@jfirebaugh jfirebaugh marked this as a duplicate of #8678 Jul 20, 2017
@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

Tried now. The current state of #9468 does not fix this problem. Hopefully it will in the future.

@jfirebaugh
Copy link
Contributor

Ok, reopening so we can investigate.

@jfirebaugh jfirebaugh reopened this Jul 20, 2017
@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

In this case, it looks like my offline tiles are expired. So it first draw the old one, then tries to fetch a fresh tile and then when the network is down the download failes and it jumps to z-1. It should probably use the tile in the database in this case even when it has expired. Does this make sense?

@halset
Copy link
Contributor Author

halset commented Jul 20, 2017

I worked around this issue by making sure that the offline tiles that I insert into the database has a expire value in the future. That seem to prevent mapbox from attempting to refetch the expired tiles in offline mode and then failing resulting in jumping to z-1.

@tmpsantos
Copy link
Contributor

We had something like this before, but it was fixed by e962b79

@namannik
Copy link
Contributor

I seem to be experiencing this issue also. Here's a video of what I'm seeing:

https://www.dropbox.com/s/p89hb976d9qha5g/offline-raster-map-issue.mov?dl=0

This video shows the following:

Timestamp Description
0:00 - 0:19 Normal behavior when internet connection is available
0:35 - 1:04 Unexpected behavior when internet connection is not available (The green rectangle seen at 0:35 indicates the area that has been downloaded for offline use.)

As you can see in the video, it appears that the offline tiles load correctly for a brief moment, and then the map cycles through tiles from lower zoom levels until it just renders blank tiles.

I'm not sure if this matters, but I'm hosting raster tiles on my own server, with the following style. (Note that the listing below omits the full tile URL.)

{
    "version": 8,
    "name": "Forest Maps",
    "sources": {
        "BaseMap": {
            "type": "raster",
            "tiles": [
                "https://------/tiles/{z}/{x}/{y}.png"
            ],
            "tileSize": 128
        }
    },
    "layers": [
        {
            "id": "BaseMap",
            "type": "raster",
            "source": "BaseMap",
            "minzoom": 3,
            "layout": {
                "visibility": "visible"
            }
        }
    ]
}

As mentioned by @halset, the log is outputting a lot of messages like this:

Failed to load tile 11/393/823=>11 for source BaseMap: The Internet connection appears to be offline.

@namannik
Copy link
Contributor

I tried previous versions of the iOS SDK and found that this issue does not occur when using v3.5.4, but does occur starting with v3.6.0-alpha.1.

@halset
Copy link
Contributor Author

halset commented Aug 14, 2017

@namannik Could it be that your tile provider does not have an Expires http header? And that the tiles are inserted in the tiles-table with null value in the expires column? Are you able to change the tile provider so that an Expires-header are included with the tiles?

@kkaefer
Copy link
Contributor

kkaefer commented Aug 14, 2017

@namannik @halset I was able to reproduce this error; but the fix will take a little.

@namannik
Copy link
Contributor

Thanks, @kkaefer. I've rolled back the SDK used in my app to v3.5.4, so I'll be good for now.

@halset The server hosting the tiles is one that I set up, and I didn't set it to provide an "Expires" http header. (I wasn't aware this was necessary.) I can give that a try. As for how the tiles are inserted into the tiles table, I'm using Mapbox's built-in MGLOfflineStorage, so I don't know that I have direct visibility to the contents of the table.

@halset
Copy link
Contributor Author

halset commented Aug 14, 2017

Looking forward to the fix, @kkaefer 👍 Thanks!

@namannik The Expires http header should not be required. During tile fetching, some of the http headers are stored with the tiles. When offline, the tile is first fetched from the database. As the tile has expired (Expires is missing), it is refetched in the background. And when that failes, it jump to the z-1 tile and so it goes. So setting the Expires header can be a workaround for this issue. This is at least how it looks for me.

@kkaefer
Copy link
Contributor

kkaefer commented Sep 16, 2017

@halset fix is in #10011 / #10012 (for the current release branch).

I verified that this fixes flickering raster tiles when tiles are expired in offline mode. Can you confirm that this fixes the issue for you as well?

@halset
Copy link
Contributor Author

halset commented Sep 25, 2017

@kkaefer It is working very well. Thank you!

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
Projects
None yet
Development

No branches or pull requests

6 participants