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

Unhandled exception when fast scroll map very far away #580

Closed
andreystavitsky opened this issue Apr 9, 2020 · 3 comments
Closed

Unhandled exception when fast scroll map very far away #580

andreystavitsky opened this issue Apr 9, 2020 · 3 comments

Comments

@andreystavitsky
Copy link

andreystavitsky commented Apr 9, 2020

Fast scrolling map really far sometimes cause following unhandled exception:
"type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'"

Call stack:

Response.fromStream (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\src\response.dart:64)
<asynchronous gap> (Unknown Source:0)
BaseClient._sendUnstreamed (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\src\base_client.dart:176)
<asynchronous gap> (Unknown Source:0)
BaseClient.get (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\src\base_client.dart:35)
get.<anonymous closure> (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\http.dart:46)
_Closure.call (dart:core-patch/function.dart:0)
_withClient (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\http.dart:166)
get (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\http-0.12.0+4\lib\http.dart:46)
WebHelper._defaultHttpGetter (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:86)
WebHelper._defaultHttpGetter (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:0)
_Closure.call (dart:core-patch/function.dart:0)
WebHelper._fileFetcher (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:0)
WebHelper._downloadRemoteFile (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:69)
<asynchronous gap> (Unknown Source:0)
WebHelper.downloadFile.<anonymous closure> (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:36)
_Closure.call (dart:core-patch/function.dart:0)
WebHelper.downloadFile (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\web_helper.dart:43)
BaseCacheManager.getSingleFile (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_cache_manager-1.1.3\lib\src\cache_manager.dart:96)
<asynchronous gap> (Unknown Source:0)
CachedNetworkImageProvider._loadAsync (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\cached_network_image-2.0.0\lib\src\cached_network_image_provider.dart:59)
CachedNetworkImageProvider.load (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\cached_network_image-2.0.0\lib\src\cached_network_image_provider.dart:45)
ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (e:\Projects\_Flutter\packages\flutter\lib\src\painting\image_provider.dart:327)
_Closure.call (dart:core-patch/function.dart:0)
ImageCache.putIfAbsent (e:\Projects\_Flutter\packages\flutter\lib\src\painting\image_cache.dart:160)
ImageProvider.resolve.<anonymous closure>.<anonymous closure> (e:\Projects\_Flutter\packages\flutter\lib\src\painting\image_provider.dart:325)
_Closure.call (dart:core-patch/function.dart:0)
SynchronousFuture.then (e:\Projects\_Flutter\packages\flutter\lib\src\foundation\synchronous_future.dart:38)
ImageProvider.resolve.<anonymous closure> (e:\Projects\_Flutter\packages\flutter\lib\src\painting\image_provider.dart:323)
_rootRun (dart:async/zone.dart:1126)
_rootRun (dart:async/zone.dart:0)
_CustomZone.run (dart:async/zone.dart:1023)
_CustomZone.runGuarded (dart:async/zone.dart:925)
ImageProvider.resolve (e:\Projects\_Flutter\packages\flutter\lib\src\painting\image_provider.dart:315)
new Tile (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_map-0.9.0\lib\src\layer\tile_layer.dart:933)
_TileLayerState._addTile (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_map-0.9.0\lib\src\layer\tile_layer.dart:808)
_TileLayerState._update (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_map-0.9.0\lib\src\layer\tile_layer.dart:762)
_TileLayerState._update (e:\Projects\_Flutter\.pub-cache\hosted\pub.dartlang.org\flutter_map-0.9.0\lib\src\layer\tile_layer.dart:0)
_rootRunUnary (dart:async/zone.dart:1134)
_rootRunUnary (dart:async/zone.dart:0)

flutter_map 0.9.0

@andreystavitsky andreystavitsky changed the title Error when fast scroll map very far away Unhandled exception when fast scroll map very far away Apr 9, 2020
@maRci002
Copy link
Contributor

maRci002 commented Apr 9, 2020

Does the app crash?

I think this exception is handled since error is just printed:
"type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'"

Maybe your IDE is configured to stop at All Dart excpetion (not at Uncaught Exception).

I see the ImageProvider.resolve on stackTrace which is guarded with extra care (maybe this try{} catch{} shouldn't happen in the constructor 😮 but this isn't a problem)

What is your configured minZoom / maxZoom on MapOptions?

@andreystavitsky
Copy link
Author

andreystavitsky commented Apr 9, 2020

Does the app crash?

Nope, app still working, but tiles wont display or load after that exception.

Maybe your IDE is configured to stop at All Dart excpetion

My IDE is configured to stop only on Uncaught exceptions.

What is your configured minZoom / maxZoom on MapOptions?

default values

@maRci002
Copy link
Contributor

maRci002 commented Apr 9, 2020

We cannot fix this at this level we attached an onError listener and wrapped the whole thing with try catch however this is too deep in flutter itself where Response.fromStream didn't propogate up the exception to our onError listener.

CachedNetworkImageProvider._loadAsync from this point try{} catch{} cannot do anything because next method calls will run on other event loops.
Just try to run this:

void main() {
  try {
    Future.delayed(
      const Duration(microseconds: 500),
      () => throw Exception('Hello'),
    );
  } catch (e) {
    print(e);
  }
}

You may create a new issue to flutter team like this.

I think the problem is your phone opens too many connections because you scroll through the entire map. There is a updateInterval settings in TileLayerOptions which may help if you increase it because now it search after new Tiles to download at every 200ms while scrolling. If this is the problem then _abortLoading() should handle it and ask TileProvider to drop connections if a Tile is still in loading phase and when dispose is called, however there no way to ask CachedNetworkImageProvider / NetworkImage to abort downloading this may be the second issue to flutter team 😃.

Nope, app still working, but tiles wont display or load after that exception.

Error tile images are also cached by NetworkImage / CachedNetworkImageProvider so there is no way to redownload error tiles, #577 tries to eliminate this, see #576 for more info.

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

No branches or pull requests

2 participants