Repository navigation
Destroy the Android MapView when its map leaves the composition - #1179
Merged
Merged
Conversation
maplibre-compose 0.13 drives the MapView from LocalLifecycleOwner and only destroys it on that lifecycle's ON_DESTROY; leaving the composition just stops observing. Home stays on the back stack, so every time another screen was opened over it, its map was dropped without MapView.onDestroy, the only thing that frees MapLibre's native map. On a Samsung A52s each return to Home leaked about 2.7 MB of native heap, and the test farm's phones with the map on reached up to 2 GB. The map now gets a lifecycle of its own that follows the screen's and is destroyed when the map leaves the composition, while maplibre-compose is still observing it. Over 40 returns to Home the native heap grew 6 MB instead of 74 MB, and every map was destroyed with its observer attached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ex6Fdp5ftuhE1ZEyhZb7WQ
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
maplibre-compose 0.13 drives the MapView from LocalLifecycleOwner and only destroys it on that lifecycle's ON_DESTROY; leaving the composition just stops observing. Home stays on the back stack, so every time another screen was opened over it, its map was dropped without MapView.onDestroy, the only thing that frees MapLibre's native map. On a Samsung A52s each return to Home leaked about 2.7 MB of native heap, and the test farm's phones with the map on reached up to 2 GB.
The map now gets a lifecycle of its own that follows the screen's and is destroyed when the map leaves the composition, while maplibre-compose is still observing it. Over 40 returns to Home the native heap grew 6 MB instead of 74 MB, and every map was destroyed with its observer attached.
Claude-Session: https://claude.ai/code/session_01Ex6Fdp5ftuhE1ZEyhZb7WQ