Skip to content

Commit 0a4b176

Browse files
perf: cull polylines via cached projected bounding boxes & chore: prepare for v8.3.1 release (#2212)
Co-authored-by: Luka Stillingfleet <github@jaffaketchup.dev>
1 parent 35eb283 commit 0a4b176

9 files changed

Lines changed: 63 additions & 33 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ Please consider [donating](https://github.com/sponsors/fleaflet) or [contributin
44

55
This CHANGELOG does not include every commit and/or PR - it is a hand picked selection of the ones that have an effect on most users. For a full list of changes, please check the GitHub repository releases/tags. We also release highlights for some releases on the docs site.
66

7+
## [8.3.1] - 2026/07/xx
8+
9+
Contains the following user-affecting bug fixes:
10+
11+
- Revert [#2182](https://github.com/fleaflet/flutter_map/pull/2182) to fix multiple internal errors - [#2218](https://github.com/fleaflet/flutter_map/pull/2218) for [#2199](https://github.com/fleaflet/flutter_map/issues/2199)
12+
- Prevent memory leak and crash when `Marker`s with NaN coordinates provided - [#2213](https://github.com/fleaflet/flutter_map/pull/2213) for [#2178](https://github.com/fleaflet/flutter_map/issues/2178)
13+
14+
Contains the following user-affecting performance improvements:
15+
16+
- Improve `MarkerLayer` performance by caching projections - [#2213](https://github.com/fleaflet/flutter_map/pull/2213)
17+
- Improve `PolygonLayer` performance, particularly for polygons with holes - [#2211](https://github.com/fleaflet/flutter_map/pull/2211)
18+
- Improve `PolylineLayer` performance by improving culling algorithm - [#2212](https://github.com/fleaflet/flutter_map/pull/2212)
19+
20+
Contains the following other notable changes:
21+
22+
- Support 'pkg:latlong2' v0.10.x dependency - [#2207](https://github.com/fleaflet/flutter_map/pull/2207)
23+
24+
Many thanks to these contributors (in no particular order):
25+
26+
- @ThexXTURBOXx
27+
- @ben-milanko
28+
- ... and all the maintainers
29+
730
## [8.3.0] - 2026/04/14
831

932
Contains the following user-affecting changes:

‎CONTRIBUTING.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ We rely on a standardized process and procedure to ensure top-quality releases.
1717

1818
* **Use a clear (preferably [Conventional](https://www.conventionalcommits.org/)) PR title.**
1919
This makes it easier for us to group commits for release and write correct CHANGELOGs.
20+
21+
* **Using AI?**
22+
If you're using AI in any way to write code or otherwise assist you, please let us know in the PR description.
23+
If the code is of insufficient quality, it will be rejected. Human submitters take all responsibility for their code.

‎example/lib/misc/tile_providers.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ final httpClient = RetryClient(Client());
77
// TODO: This causes unneccessary rebuilding
88
TileLayer get openStreetMapTileLayer => TileLayer(
99
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
10-
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
10+
userAgentPackageName: 'dev.fleaflet.flutter_map.demo',
1111
tileProvider: NetworkTileProvider(httpClient: httpClient),
1212
);

‎example/pubspec.lock‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ packages:
2929
dependency: transitive
3030
description:
3131
name: characters
32-
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
32+
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
3333
url: "https://pub.dev"
3434
source: hosted
35-
version: "1.4.0"
35+
version: "1.4.1"
3636
clock:
3737
dependency: transitive
3838
description:
@@ -124,7 +124,7 @@ packages:
124124
path: ".."
125125
relative: true
126126
source: path
127-
version: "8.2.2"
127+
version: "8.3.0"
128128
flutter_test:
129129
dependency: "direct dev"
130130
description: flutter
@@ -207,22 +207,14 @@ packages:
207207
url: "https://pub.dev"
208208
source: hosted
209209
version: "6.0.0"
210-
logger:
211-
dependency: transitive
212-
description:
213-
name: logger
214-
sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c"
215-
url: "https://pub.dev"
216-
source: hosted
217-
version: "2.6.1"
218210
matcher:
219211
dependency: transitive
220212
description:
221213
name: matcher
222-
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
214+
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
223215
url: "https://pub.dev"
224216
source: hosted
225-
version: "0.12.18"
217+
version: "0.12.20"
226218
material_color_utilities:
227219
dependency: transitive
228220
description:
@@ -235,10 +227,10 @@ packages:
235227
dependency: transitive
236228
description:
237229
name: meta
238-
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
230+
sha256: c82594181e3312f3d0695fc95aaaf7758d75b8d4ae2bbecf223b9fd5109a059d
239231
url: "https://pub.dev"
240232
source: hosted
241-
version: "1.17.0"
233+
version: "1.18.3"
242234
mgrs_dart:
243235
dependency: transitive
244236
description:
@@ -456,10 +448,10 @@ packages:
456448
dependency: transitive
457449
description:
458450
name: test_api
459-
sha256: "19a78f63e83d3a61f00826d09bc2f60e191bf3504183c001262be6ac75589fb8"
451+
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
460452
url: "https://pub.dev"
461453
source: hosted
462-
version: "0.7.8"
454+
version: "0.7.12"
463455
typed_data:
464456
dependency: transitive
465457
description:
@@ -552,10 +544,10 @@ packages:
552544
dependency: transitive
553545
description:
554546
name: vector_math
555-
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
547+
sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188"
556548
url: "https://pub.dev"
557549
source: hosted
558-
version: "2.2.0"
550+
version: "2.4.0"
559551
vm_service:
560552
dependency: transitive
561553
description:
@@ -589,5 +581,5 @@ packages:
589581
source: hosted
590582
version: "1.1.0"
591583
sdks:
592-
dart: ">=3.9.0 <4.0.0"
584+
dart: ">=3.10.0 <4.0.0"
593585
flutter: ">=3.35.0"

‎example/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_map_example
22
description: Example application for 'flutter_map' package
33
publish_to: "none"
4-
version: 8.3.0
4+
version: 8.3.1
55

66
environment:
77
sdk: ">=3.6.0 <4.0.0"

‎lib/src/layer/polyline_layer/polyline_layer.dart‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,11 @@ class _PolylineLayerState<R extends Object> extends State<PolylineLayer<R>>
208208
continue;
209209
}
210210

211+
final projectedBounds = projectedPolyline.boundingBox;
212+
211213
/// Returns true if the points stretch on different versions of the world.
212-
bool stretchesBeyondTheLimits() {
213-
for (final point in projectedPolyline.points) {
214-
if (point.dx > xEast || point.dx < xWest) {
215-
return true;
216-
}
217-
}
218-
return false;
219-
}
214+
bool stretchesBeyondTheLimits() =>
215+
projectedBounds.right > xEast || projectedBounds.left < xWest;
220216

221217
// TODO: think about how to cull polylines that go beyond -180/180.
222218
// As the notions of projected west/east as min/max are not reliable.
@@ -235,6 +231,16 @@ class _PolylineLayerState<R extends Object> extends State<PolylineLayer<R>>
235231
// when none of the line is visible. Here, focusing on longitudes.
236232
if (!isOverlappingLongitude()) continue;
237233

234+
// Fast path: when the whole polyline is visible there is nothing to
235+
// cull, so skip the per-segment scan (and its sublist allocations).
236+
if (projBounds.left <= projectedBounds.left &&
237+
projBounds.top <= projectedBounds.top &&
238+
projBounds.right >= projectedBounds.right &&
239+
projBounds.bottom >= projectedBounds.bottom) {
240+
yield projectedPolyline;
241+
continue;
242+
}
243+
238244
// pointer that indicates the start of the visible polyline segment
239245
int start = -1;
240246
bool containsSegment = false;

‎lib/src/layer/polyline_layer/projected_polyline.dart‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ class _ProjectedPolyline<R extends Object> with HitDetectableElement<R> {
55
final Polyline<R> polyline;
66
final List<Offset> points;
77

8+
/// Bounding box of [points], in projected space (cached)
9+
///
10+
/// Computed lazily: culled fragments never use it.
11+
late final Rect boundingBox = RectExtension.containing(points);
12+
813
@override
914
R? get hitValue => polyline.hitValue;
1015

11-
const _ProjectedPolyline._({
16+
_ProjectedPolyline._({
1217
required this.polyline,
1318
required this.points,
1419
});

‎pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_map
22
description: "Flutter's №1 non-commercially aimed map client: it's easy-to-use, versatile, vendor-free, fully cross-platform, and 100% pure-Flutter"
3-
version: 8.3.0
3+
version: 8.3.1
44

55
repository: https://github.com/fleaflet/flutter_map
66
issue_tracker: https://github.com/fleaflet/flutter_map/issues

‎windowsApplicationInstallerSetup.iss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "flutter_map Demo"
5-
#define MyAppVersion "for 8.3.0"
5+
#define MyAppVersion "for 8.3.1"
66
#define MyAppPublisher "fleaflet"
77
#define MyAppURL "https://github.com/fleaflet/flutter_map"
88
#define MyAppSupportURL "https://github.com/fleaflet/flutter_map/issues"

0 commit comments

Comments
 (0)