Repository navigation
Conversation
| map.setOnGroundOverlayClickListener(null) | ||
| map.setOnPolygonClickListener(null) | ||
| map.setOnPolylineClickListener(null) | ||
| map.setOnMarkerClickListener(null) |
| map.setOnPolygonClickListener(null) | ||
| map.setOnPolylineClickListener(null) | ||
| map.setOnMarkerClickListener(null) | ||
| map.setOnInfoWindowClickListener(null) |
| map.setOnMarkerClickListener(null) | ||
| map.setOnInfoWindowClickListener(null) | ||
| map.setOnInfoWindowCloseListener(null) | ||
| map.setOnInfoWindowLongClickListener(null) |
| map.setOnInfoWindowClickListener(null) | ||
| map.setOnInfoWindowCloseListener(null) | ||
| map.setOnInfoWindowLongClickListener(null) | ||
| map.setOnMarkerDragListener(null) |
| map.setOnInfoWindowCloseListener(null) | ||
| map.setOnInfoWindowLongClickListener(null) | ||
| map.setOnMarkerDragListener(null) | ||
| map.setInfoWindowAdapter(null) |
Coverage (unit tests)Compared against
Line and branch coverage from unit test reports. History is recorded on the |
dkhawk
marked this pull request as ready for review
October 13, 2026 23:58
Contributor
Coverage (instrumentation tests)
Files
|
…ing/hiding map Ensure MapApplier, MapPropertiesNode, and TileOverlayNode detach all GoogleMap listeners, InfoWindowAdapter, LocationSource, and state references when cleared or removed. Dispose the map subcomposition synchronously in AndroidView's onReset and onRelease callbacks before destroying the MapView, clean up view tree owners and attach-state listeners, and guard against rapid show/hide cycles where MapView is released before awaitMap() completes. Fixes #581
dkhawk
force-pushed
the
fix/581-oom-showing-hiding-map
branch
from
October 14, 2026 17:25
e1c2594 to
3b093fd
Compare
This branch has not been 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.
Summary
Fixes memory retention and teardown ordering issues when
GoogleMapis repeatedly shown/hidden (if (showMap) { GoogleMap(...) }) or deactivated/reused viaReusableContentHost/LazyColumn:GoogleMapListeners andInfoWindowAdapteron Clear:MapApplier.attachClickListeners()registers 9 click/drag listeners andComposeInfoWindowAdapter(mapView, ...)onGoogleMap(wrapped in Binder stubs that hold strong references toMapApplierandMapView), butMapApplier.onClear()never detached them. AddedMapApplier.detachClickListeners()and invoked it fromonClear().MapPropertiesNode.onRemoved()andonCleared()now clear the 4 camera listeners (setOnCameraIdleListener(null),setOnCameraMoveCanceledListener(null),setOnCameraMoveStartedListener(null),setOnCameraMoveListener(null)) andsetLocationSource(null)in addition tocameraPositionState.setMap(null).TileOverlayNode.onRemoved()andonCleared()now cleartileOverlayState.tileOverlay = null.MapViewTeardown:subcompositionJobandsubcomposition(Composition) toMapTagDataon theMapViewinstance soonResetandonReleasedispose the map subcomposition synchronously beforelifecycleObserver.moveToDestroyedState()(mapView.onDestroy()) is invoked, and soupdatecleanly re-launches the subcomposition when a deactivatedMapViewis reused.launchSubcompositiontoDispatchers.Main.immediateand guarded aftermapView.awaitMap()(if (!isActive || mapView.tagDataOrNull !== tagData) return@launch) so rapid show/hide cycles whereonReleaseruns beforegetMapAsynccompletes do not throw aNullPointerExceptiononmapView.tagor create an orphanedComposition.removeOnAttachStateChangeListener, lifecycle observer registration,setViewTreeLifecycleOwner(null),setViewTreeSavedStateRegistryOwner(null), andremoveAllViews()inonRelease.Testing
MapApplierCleanupTestverifying thatMapApplier.onClear(),MapPropertiesNode,TileOverlayNode, andMarkerNodedetach all listeners,InfoWindowAdapter,LocationSource, and state references.testShowingHidingMapRepeatedlyReleasesMapViewsandtestReusableContentHostResetAndReuseinGoogleMapViewTests.hprof) analysis across 30 show/hide cycles that 0GoogleMap/MapApplier/ComposeInfoWindowAdapterinstances remain in the heap.Fixes #581