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

Offline raster tiles does not use correct zoom level #9563

Closed

Description

@halset

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.)

Activity

  1. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

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

  2. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

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

  3. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

    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.

  4. added
    iOS
    on Jul 20, 2017
  5. jfirebaugh commented on Jul 20, 2017

    @jfirebaugh
    Contributor

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

  6. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

    I bisected this to 9a9408e. cc @kkaefer.

  7. jfirebaugh commented on Jul 20, 2017

    @jfirebaugh
    Contributor

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

  8. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

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

  9. jfirebaugh commented on Jul 20, 2017

    @jfirebaugh
    Contributor

    Ok, reopening so we can investigate.

  10. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

    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?

  11. halset commented on Jul 20, 2017

    @halset
    ContributorAuthor

    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.

  12. tmpsantos commented on Jul 24, 2017

    @tmpsantos
    Contributor

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

  13. namannik commented on Aug 14, 2017

    @namannik
    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.
    
  14. namannik commented on Aug 14, 2017

    @namannik
    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.

  15. halset commented on Aug 14, 2017

    @halset
    ContributorAuthor

    @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?

  16. kkaefer commented on Aug 14, 2017

    @kkaefer
    Member

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

  17. namannik commented on Aug 14, 2017

    @namannik
    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.

  18. halset commented on Aug 14, 2017

    @halset
    ContributorAuthor

    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.

  19. kkaefer commented on Sep 16, 2017

    @kkaefer
    Member

    @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?

  20. halset commented on Sep 25, 2017

    @halset
    ContributorAuthor

    @kkaefer It is working very well. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugiOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions