Skip to content

Hand over states added to a mutableStateListOf in place - #22

Merged
wf9a5m75 merged 1 commit into
developfrom
fix/markers-in-place-list
Nov 21, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
fix/markers-in-place-list

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

What

Markers(states), Circles(states), Polylines(states) and Polygons(states) re-ran their hand-over only when given a different list (LaunchedEffect(states)). A mutableStateListOf the app adds to is the same list, so the added states never reached the map.

Found running the Studio's "drop a pin where you tap" sample on an emulator: logcat printed markers: 1, markers: 2, and no pin was drawn.

Change

  • listVersions(list): the list now and, for a SnapshotStateList, again after each in-place change (snapshotFlow, a copy taken on the main thread). Other lists behave exactly as before (one emission per list).
  • The four collection composables collect it inside their existing LaunchedEffect(states).
  • Side effect: the Dispatchers.Default work now reads a copy, never the live SnapshotStateList the app may be changing.

Verified

  • New InPlaceListTest: add/remove on mutableStateListOf for all four kinds reaches the collectors. Fails on develop, passes here.
  • :android-sdk-compose:testDebugUnitTest, apiCheck (no public API change), assembleRelease in the aggregate build. ktlint: no new findings in changed/added files.

Markers, Circles, Polylines and Polygons handed their list to the map
again only when given a different list. A mutableStateListOf that the
app adds to stays the same list, so a pin-per-tap screen logged one more
marker per tap and drew none. Each now also follows in-place changes to
a SnapshotStateList, copying it on the main thread so the work on
Dispatchers.Default never reads it while the app changes it.
@wf9a5m75
wf9a5m75 merged commit 112e6a9 into develop Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant