mapbox-maps-flutter
mapbox-maps-flutter copied to clipboard
Memory Leak in Map Display Component on iOS 17.1
Environment
- Device: iPhone
- OS: iOS 17.1
- Package: mapbox-maps-flutter
Issue Description
I've encountered a significant memory leak issue when using the map display component of mapbox-maps-flutter
on an iPhone running iOS 17.1. This problem seems to be specific to this iOS version, as I did not observe similar issues on earlier versions.
Steps to Reproduce
- Integrate
mapbox-maps-flutter
into a Flutter application. - Run the application on an iPhone with iOS 17.1.
- Observe the application's memory usage over time.
Expected Behavior
The memory usage should remain stable over time when the map is displayed.
Actual Behavior
The memory usage consistently increases, indicating a potential memory leak.
Additional Information
- This issue is reproducible in both debug and release modes.
- No such issue was observed on devices running earlier versions of iOS.
Please look into this matter, as it affects the performance and reliability of applications using mapbox-maps-flutter
on the latest iOS version. Thank you!
We also experience a memory leak on iOS.
Once we display a mapWidget, the Ram consumption increases by 100+ MB.
The problem is especially prominent, if we render multiple mapWidgets in a ListView. A screen that contains 6 mapWidgets increased the RAM usage by 300MB. Just a couple of clicks are able to crash the app completely because the RAM usage exceeds 2GB.
Widget we display:
MapWidget(
key: key,
resourceOptions: ResourceOptions(
accessToken:
"....",
),
cameraOptions: CameraOptions(
center: Point(coordinates: position + Position(-0.9 * (pow(6.5 - zoom, 2) + 1), 0)).toJson(),
zoom: zoom,
),
styleUri: "mapbox://styles/.....",
// Disable taps
onTapListener: (_) {},
onMapCreated: (map) => map
..scaleBar.updateSettings(ScaleBarSettings(enabled: false))
..compass.updateSettings(CompassSettings(enabled: false))
..gestures.updateSettings(GesturesSettings(
quickZoomEnabled: false,
rotateEnabled: false,
scrollEnabled: false,
pitchEnabled: false,
pinchToZoomEnabled: false,
doubleTapToZoomInEnabled: false,
doubleTouchToZoomOutEnabled: false,
pinchPanEnabled: false,
pinchToZoomDecelerationEnabled: false,
rotateDecelerationEnabled: false,
scrollDecelerationEnabled: false,
simultaneousRotateAndPinchToZoomEnabled: false,
))
..logo.updateSettings(LogoSettings(
marginBottom: 10,
marginLeft: 10,
))
..attribution.updateSettings(AttributionSettings(
position: OrnamentPosition.TOP_RIGHT,
iconColor: Palette.textSwatch.shade300.value,
marginTop: 16,
marginRight: 16,
clickable: true,
)),
);
System details:
Tested on iOS 17.2.1 mapbox_maps_flutter: ^0.5.1 flutter doctor -v:
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/user/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.3
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.84.2) • VS Code at /Users/user/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.54.0
[✓] Connected device (2 available) • iPhone of user (mobile) • ............... • ios • iOS 17.2.1 21C66 • macOS (desktop) • macos • darwin-arm64 • macOS 14.1.2 23B92 darwin-arm64
[✓] Network resources • All expected network resources are available.
! Doctor found issues in 1 category.
@shihanjun19, @MeintrupStefan This issue should be addressed by https://github.com/mapbox/mapbox-maps-flutter/pull/383, could you try it out?