Skip to content

Tiles will not load after usage without a network #576

Closed

Description

@ristiisa

When the connectivity was lost and is restored the tiles that failed to load when the connectivity was lost will continue to fail to load:
SocketException: Failed host lookup: 'a.tile.openstreetmap.org' (OS Error: No address associated with hostname, errno = 7)

Video of the issue:
https://streamable.com/9kaguw

Some time after the connectivity is restored an exception is caught:
image

Tested with ac52f28
Flutter version 1.15.17
Framework revision 2294d75bfa (5 weeks ago), 2020-03-07 00:28:38 +0900
Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)

Activity

  1. maRci002 commented on Apr 7, 2020

    @maRci002
    Contributor

    This seems serious bug however I tested this against 0.8.2 release and it behaves same way.
    git checkout 031fa41544f34a91acf69d0c3b758514f1ea2f5c or if you are using it as dependency flutter_map: 0.8.2 (not ^0.8.2) then flutter pub upgrade.

    Here is a fast 0.8.2 preview:
    0 8 2 release

    I think I know how to fix this issue, give me some time and I will make a new PR, the main problem is within flutter because it caches the failed Image, see:

    /// Fetches the given URL from the network, associating it with the given scale.
    ///
    /// The image will be cached regardless of cache headers from the server.
    ///
    /// When a network image is used on the Web platform, the [cacheWidth] and
    /// [cacheHeight] parameters of the [DecoderCallback] are ignored as the Web
    /// engine delegates image decoding of network images to the Web, which does
    /// not support custom decode sizes.
    ///
    /// See also:
    ///
    ///  * [Image.network] for a shorthand of an [Image] widget backed by [NetworkImage].
    // TODO(ianh): Find some way to honor cache headers to the extent that when the
    // last reference to an image is released, we proactively evict the image from
    // our cache if the headers describe the image as having expired at that point.
    abstract class NetworkImage extends ImageProvider<NetworkImage> {
    
  2. maRci002 commented on Apr 7, 2020

    @maRci002
    Contributor

    @ristiisa take a test ride with #577 don't forget to provide evictErrorTiles flag to TileLayerOptions since error tiles will become active they will be retained too, however _pruneTiles will have chance to evict error tiles if they are not retained anymore.

  3. maRci002 commented on Apr 7, 2020

    @maRci002
    Contributor

    Some time after the connectivity is restored an exception is caught: it was because they were not retained anymore and phone wanted to refetch the Image, forinstance this happens if an error happened on zoom lvl 5 and you changed zoom to lvl 7 or if overpanning the default 2 tiles margin.

  4. ristiisa commented on Apr 9, 2020

    @ristiisa
    Author

    @ristiisa take a test ride with #577 don't forget to provide evictErrorTiles flag to TileLayerOptions since error tiles will become active they will be retained too, however _pruneTiles will have chance to evict error tiles if they are not retained anymore.

    I'm not sure if I'm seeing any changes in the behavior.

    image

  5. maRci002 commented on Apr 9, 2020

    @maRci002
    Contributor

    It's because _pruneTiles / _abortLoading wasn't called, I have seen your video and map was moved by a MapController which took small steps and error tiles was still retained. I think I can make evictErrorTiles even stricter forinstance if error Tile is not in viewport / not on same zoom lvl as mapState.zoom then evict an error tile may seem fair enough. So I think evictErrorTiles will be better evictErrorTilesStrategy enum which will support/allow this behaviour.

      // If a Tile was loaded with error and if this flag is true, then TileProvider
      // will be asked to evict Image during _pruneTiles / _abortLoading calls
      // (see #576 - even Error Images are cached in flutter)
      final bool evictErrorTiles;
    

    Anyway if you are moving map by a controller then #579 contains some fix.

  6. maRci002 commented on Apr 10, 2020

    @maRci002
    Contributor

    @ristiisa I updated the PR with more strategy like EvictErrorTileStrategy.notVisible.

    evict not visible

  7. eis6aer commented on Aug 22, 2020

    @eis6aer

    Is there any workaround that you can think of for the moment? Until the real fix is implemented ?

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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions