mapbox / mapbox/mapbox-maps-flutter

Exponential memory usage until crash with PolylineAnnotationManager.createMulti

オープン
#492 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Dart
スター
380
フォーク
204
PR マージ指標
30日以内にマージされた PR はありません

説明

Using PolylineAnnotationManager.createMulti the memory usage increases with each iteration.

image

With a slower iteration speed the increase is less dramatic.

image

```dart
import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';

List polylines = [];

void main() async {
WidgetsFlutterBinding.ensureInitialized();
MapboxOptions.setAccessToken("");

var data = json.decode(await rootBundle.loadString("path.json")) as List;
for(var n = 0; n < 10; n++) polylines.addAll(data.map((e) => PolylineAnnotationOptions(
geometry: e,
lineWidth: 5.0,
lineColor: Colors.red.value,
lineJoin: LineJoin.ROUND,
)).toList());

runApp(MaterialApp(home: MapSample()));
}

class MapSample extends StatefulWidget {
@override
State createState() => _MapSampleState();
}

class _MapSampleState extends State {
final locationSettings = LocationComponentSettings(
enabled: true,
showAccuracyRing: true,
pulsingEnabled: false,
puckBearingEnabled: true,
puckBearing: PuckBearing.HEADING
);

Stream? location;

PolylineAnnotationManager? polylineAnnotationManager;

@override
initState() {
super.initState();
}

@override
Widget build(BuildContext context) => Scaffold(
body: MapWidget(
key: ValueKey("map"),
cameraOptions: CameraOptions(center: Point(coordinates: Position(-122.04160728, 37.33676622)), zoom: 12, pitch: 0.0),
onMapCreated: (mapboxMap) async {
await Future.wait([
mapboxMap.scaleBar.updateSettings(ScaleBarSettings(enabled: false)),
mapboxMap.gestures.updateSettings(GesturesSettings(rotateEnabled: false)),
mapboxMap.attribution.updateSettings(AttributionSettings(clickable: false, iconColor: 1)),
mapboxMap.location.updateSettings(locationSettings),
]);
polylineAnnotationManager ??= await mapboxMap.annotations.createPolylineAnnotationManager();

Timer.periodic(const Duration(milliseconds: 100), (_) async {
polylineAnnotationManager!.deleteAll();
await polylineAnnotationManager!.createMulti(polylines!);
});
}
)
);
}
```

https://github.com/ristiisa/mbmemleak/tree/annotations

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Start with the PolylineAnnotationManager.createMulti and deleteAll calls in the provided Dart reproduction, especially the Timer.periodic loop. Run the mbmemleak/annotations reproduction and monitor memory while repeating the loop; done means repeated deletion and creation no longer causes unbounded memory growth or a crash.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
dart, flutter
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。