Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiles will not load after usage without a network #576

Closed
ristiisa opened this issue Apr 7, 2020 · 7 comments · Fixed by #577 or #841
Closed

Tiles will not load after usage without a network #576

ristiisa opened this issue Apr 7, 2020 · 7 comments · Fixed by #577 or #841

Comments

@ristiisa
Copy link

ristiisa commented Apr 7, 2020

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)

@maRci002
Copy link
Contributor

maRci002 commented Apr 7, 2020

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> {

@maRci002
Copy link
Contributor

maRci002 commented Apr 7, 2020

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

@maRci002
Copy link
Contributor

maRci002 commented Apr 7, 2020

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.

@ristiisa
Copy link
Author

ristiisa commented Apr 9, 2020

@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

@maRci002
Copy link
Contributor

maRci002 commented Apr 9, 2020

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.

@maRci002
Copy link
Contributor

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

evict not visible

@eis6aer
Copy link

eis6aer commented Aug 22, 2020

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

Successfully merging a pull request may close this issue.

3 participants