mapbox / mapbox/mapbox-maps-flutter
PointAnnotationManager uses excessive memory
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
In the demo application, increasing the loop size in the PointAnnotationPage to 10K markers:
for (var i = 0; i < 10000; i++) {
options.add(PointAnnotationOptions(
geometry: createRandomPoint().toJson(), image: list));
}
causes the demo application to crash with the following OOM error:
E/AndroidRuntime( 4299): FATAL EXCEPTION: main
E/AndroidRuntime( 4299): Process: com.mapbox.maps.flutter.example, PID: 4299
E/AndroidRuntime( 4299): java.lang.OutOfMemoryError: Failed to allocate a 26640400 byte allocation with 11372088 free bytes and 10MB until OOM, target footprint 268435456, growth limit 268435456
E/AndroidRuntime( 4299): at java.util.Arrays.copyOf(Arrays.java:3161)
E/AndroidRuntime( 4299): at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
E/AndroidRuntime( 4299): at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
E/AndroidRuntime( 4299): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.writeBytes(StandardMessageCodec.java:196)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:247)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessengerCodec.writeValue(PointAnnotationMessenger.kt:738)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessengerCodec.writeValue(PointAnnotationMessenger.kt:738)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessengerCodec.writeValue(PointAnnotationMessenger.kt:724)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessengerCodec.writeValue(PointAnnotationMessenger.kt:738)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessengerCodec.writeValue(PointAnnotationMessenger.kt:738)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.StandardMessageCodec.encodeMessage(StandardMessageCodec.java:76)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler$1.reply(BasicMessageChannel.java:266)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion$setUp$2$1$1.invoke(PointAnnotationMessenger.kt:843)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion$setUp$2$1$1.invoke(PointAnnotationMessenger.kt:837)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.annotation.PointAnnotationController.createMulti(PointAnnotationController.kt:81)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion.setUp$lambda-3$lambda-2(PointAnnotationMessenger.kt:837)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion.$r8$lambda$SImXOqSBSxtubGcdXZLjwzzH03A(Unknown Source:0)
E/AndroidRuntime( 4299): at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion$$ExternalSyntheticLambda2.onMessage(Unknown Source:2)
E/AndroidRuntime( 4299): at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
E/AndroidRuntime( 4299): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime( 4299): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime( 4299): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime( 4299): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 4299): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4299): at android.os.Looper.loop(Looper.java:233)
E/AndroidRuntime( 4299): at android.app.ActivityThread.main(ActivityThread.java:8063)
E/AndroidRuntime( 4299): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 4299): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
E/AndroidRuntime( 4299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
Expected bahaviour:
The application should be able to cope with tens of thousands of markers, not just a small number. Our production app uses Flutter mapbox_gl and manages in excess of 70K markers simultaneously.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash by increasing the loop in the demo's PointAnnotationPage to 10K markers. Start by tracing the createMulti path in PointAnnotationController.kt and the generated PointAnnotationMessenger codec shown in the stack trace. Done means the demo handles tens of thousands of markers without the reported Android OutOfMemoryError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100