-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
[FEATURE] Cancel unnecessary tile requests #1430
Comments
It's not quite clear how you are integrating with mapbox, just tiles, or using their api or what. May be worth including some example code or how you are using it at least. |
Where is the queue though ? I'm not an http person, so just thinking out loud here...isn't it too late at this point, i.e the request has been made (at least as far as flutter_map is concerned, because at the time that was requested) ? |
Are you see video to the end? |
You can easily reproduce this experience. Get token on MapBox (it's free) , put to example project, build, change zoom 10 times on home page and waiting few minutes for end of all requests. |
I don't dispute the experience...I'm just a little uncertain what you want to happen. How do you want to interrupt them ? (I can certainly understand wanting to throttle requests, but it doesn't sound like that's what you are after). |
I want that map interrupt all request for images is not target at that time. For what clients will waiting loading images which they don't see? I was expect that on any change map position or zoom map makes new, only needed requests and closed previous requests. Also FYI browser has connection limits for HTTP 1.1. Max Number of default simultaneous persistent connections per server/proxy:
*info from stackoverflow HTTP 2 don't have similar limits(it has one TCP connection by client may create a very big number of parallel connections inside, limits only by banwidth of internet connection). Version of used HTTP type determine by server side, not on client. So the map must has optimal internal workflow for both type of HTTP types for maximum interactive behaviour with user. And problem feels better by big display or minimal scale of conent on page - many tiles on screen). |
Hi @ibrierley , technically you can abort the request in the FMNetworkImageProvider if you use |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm a bit late to this issue but think that it's a reasonable feature to have. This affects all platforms (while it has only a visible effect on web).
Sadly, the http package has no build in feature to cancel requests. There are some community packages that try to solve this by implementing an cancellation token. |
I've implemented a basic framework which uses a Note that dart-lang/http#424 might be interesting, along with https://github.com/SamJakob/dart-http/tree/feat/cancellation. |
Sounds nice! It's not completely clean to me what the benefits of a Completer are, haven't used them so far. 😧I like the idea to trigger some kind of callback in the _remove method. I stumbled accross some issues about Future cancellation too but they had always no prority by the dart dev team. Hopefully that pr has a chance, it looks promising! Nethertheless it's worth to add this functionality to flutter_map. More enhanched http clients like dio support request cancelation out of the box. |
Completers are a relatively power-user feature but extremely useful for one-shot 'signals' - they wrap awaitable futures, but also allow checking of whether the future is complete. I'd say they're halfway between a standard future and a stream in terms of flexibility. I wouldn't hold out hope for that PR! It's a breaking change unfortunately. |
Sounds like a great feature! Oh I see, yeah they probably won't add a breaking change to http any day soon. |
Personally, I would not like to involve dio. It is a large package, IMO intended for direct usage in apps, not in packages. It might be possible to implement a custom |
Fair point. It's funny how Dart/ Flutter have these major hidden stumbling blocks like the http package or the non-UI isolate performance issue (vector tiles) holding back packages. We'll have a go at a |
QQ: does anyone know if this also impacts iOS/ Android tile loading performance? Take Stadia Maps for example - super fast initially, but after a while of moving and zooming, tile loading slows visibly unless you wait for everything to load and start moving around again. No idea how many parallel connections the default |
It probably does impact the performance. It's trying to download and render a large number of images (all on the main thread?). |
Haven't profiled it yet, but you're probably right. In that case though, maybe this issue is higher than P3, since it affects everyone in terms of performance, bandwidth use and as a result, battery drain? :) Here's an idea: we'll try to publish a |
Yep, internal changes would be needed. I'm not sure what the best way would be, but I'd assume calling an internal method when the tile gets pruned (?) and allowing |
Exactly, we just need to add a default method to the abstract Tile Provider that implementing classes can override to get called on pruning. Probably just 5-10 lines of code.
…________________________________
From: Luka S ***@***.***>
Sent: Saturday, August 26, 2023 12:31:44 PM
To: fleaflet/flutter_map ***@***.***>
Cc: mdmm13 ***@***.***>; Comment ***@***.***>
Subject: Re: [fleaflet/flutter_map] [FEATURE] Cancel unnecessary tile requests (Issue #1430)
Yep, internal changes would be needed. I'm not sure what the best way would be, but I'd assume calling an internal method when the tile gets pruned (?) and allowing TileProviders to get a method called when the internals are called.
It's unlikely to happen for v6.
—
Reply to this email directly, view it on GitHub<#1430 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALCXK3GFJCLSM5NZXU2YZVTXXHGBBANCNFSM6AAAAAAT2RRNMA>.
You are receiving this because you commented.Message ID: ***@***.***>
|
The necessary infrastructure now exists to implement a It will be released as part of v6. @mdmm13 Happy to accept a plugin, lmk if you want it added to the list. If you can't be bothered any more, let me know and I'll create one. Also, 'flutter_map_performance' probably isn't a great name (it's very vague), maybe 'flutter_map_cancellable_tile_provider' would be better (if not a bit long-winded). |
Thank you for the quick fix @JaffaKetchup!
As I mentioned, we're currently trying to upgrade from If you or someone on this thread wants to have a go beforehand, we'd also be super happy with that. It's quite simple actually now thanks to @JaffaKetchup's fix. We'd have created a simple Map of tile coordinates/DIO request tokens, kept the map clean with every "finished" request and canceled ongoing ones if pruned. Might add in native_dio to see if it helps. P.S. Fair point on the naming. Was thinking of |
Ok, in that case, I'll see if I can get a plugin ready before then - I've got my fingers crossed to have v6 released by the end of the week, so having a plugin ready to take advantage of the new feature makes sense to me. Who knows if that'll actually go to plan. EDIT: I'll also make it part of the FM org, as I will endorse it in the docs. Most people will want to use it (unless you don't want the extra effort of plugins and Dio).
The
AFAIK (purely going off of the body of dart-lang/http#424), cancelling HTTP requests is only supported on the web anyway, so I'm not sure there's much purpose.
Part of the other reason I'm happy to publish the plugin is that, should cancelling become natively available in Dart, I'm happy to archive my plugin and just add the functionality into FM so that everyone can automatically benefit: that's the aim in the long term. |
Package has been released at https://pub.dev/packages/flutter_map_cancellable_tile_provider. |
What is the bug?
Hello!
I use example WEB app project with openstreetmap as tiles provider (home page) and map work properly, but when i change openstreetmap to mapbox map work very slow.
Main difference between providers - OSM use HTTP 2 and mapBox use HTTP 1.1 (with their pipeline). When i am scrolling on mapBox - map is setting many requests to queue and don't interrupt of them, it load hundreds of useless images when map move before show target place.
How i can interrupt request which out of view?
Thanks!
What is the expected behaviour?
Map will interrupt useless requests
How can we reproduce this issue?
No response
Do you have a potential solution?
No response
Can you provide any other information?
No response
Platforms Affected
Web
Severity
Minimum: Allows normal functioning
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issuesThe text was updated successfully, but these errors were encountered: