Skip to content

Report when a tiler takes a list or draws tiles - #58

Merged
wf9a5m75 merged 3 commits into
developfrom
feat/tile-activity-progress
Nov 21, 2026
Merged

wf9a5m75 merged 3 commits into
developfrom
feat/tile-activity-progress

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

Stacked on #57 (on #56, on #54). Merge those first; this one then retargets.

Pairs with MapConductor/android-sdk-compose, which uses this to call onAddStart / onAddEnd while tiles are being drawn.

Why

A collection's onAddEnd came when its new states' tiles were handed to the map. The slow part comes after that: drawing the tiles. A filter that only hides states, or a camera move to undrawn tiles, called nothing at all, so an app could not show that the map was still drawing.

What

  • TileActivity: a counter that is busy while a ShapeTiler routes a list, or its ShapeTileRenderer draws a tile. It exposes active: StateFlow<Boolean>.
  • ShapeTileSet, CircleTiler, PolylineTiler and PolygonTiler hold it (internal). PolygonTiler keeps its tile set for this.
  • BaseMapViewController.overlayTileActivity(kind) lists those flows for circles, polylines or polygons.

No public API change. The extension is @InternalMapConductorApi and the members are internal, so apiCheck passes. 451 tests pass.

listenToWrittenStates looked every id of the new map up in the old one
and every id of the old map up in the new one: about 1.7 s on the main
thread for the 576k/724k circles of the antenna sample on a Pixel 5a.

The collector now listens through a PassToken replaced at every pass. A
state in the new map is moved to the current token; a state of the old
map still on an older token of this collector was not in the new one,
and stops. One read per state, no lookups; an id is still looked up for
a state not yet listening here, to stop what held that id before.

The pass is now 1.2-1.3 s. Of that, merely iterating the
PersistentOrderedMapBuilder is about 0.44 s per 576k entries (it looks
the next key up at each step), which only a different hand-over can
avoid.
A collector's membership is a MutableMap, and for a bulk collection that
map was a PersistentOrderedMap of every state: building it took about
1.8 s per hand-over for the antenna sample's 576k circles on a Pixel 5a,
and merely iterating it about 0.44 s per pass (it looks the next key up
at each step), on the collector's pass and the overlay's toList.

OverlayStateList is a MutableMap over the list a collection was given:
iterating it walks the list, and only a key lookup builds an index. The
collector's listener pass and CircleOverlay walk the list; the overlay
hands the list itself to the controller, and the added-tracker gets the
ids lazily. A write from the latest pass's token is known to be from a
member without a lookup.

A published map is still not to be written to; one that is follows its
index. The ids must be distinct (the compose Circles hands a list over
only when they are).
Adds TileActivity, counted across the tile threads: ShapeTileRenderer is
busy while it draws a tile, and ShapeTiler adds its route. Circle,
polyline and polygon tilers expose it internally, and
BaseMapViewController.overlayTileActivity(kind) (@InternalMapConductorApi)
lists a map's tilers of one kind, for the compose collections'
onAddStart / onAddEnd to wait for the tiles.
@wf9a5m75
wf9a5m75 changed the base branch from perf/overlay-state-list to develop November 21, 2026 09:31
@wf9a5m75
wf9a5m75 merged commit b876581 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