Repository navigation
Let marker controllers hear writes without a Combine subscription each - #51
Merged
Merged
Conversation
MarkerState.onChange calls a closure on the main queue after each write, through the state's StateMutationSignal. Switching the provider on the street trees page (144,183 markers) held the main thread for 6.5 s on an iPad Pro: 3.5 s subscribing the new map's controller to every marker's asFlow(), 2 s cancelling the old one's. With onChange, 0.15 s and 0.17 s. Ingestion no longer reads and converts the icon of a marker that is tiled; only a native marker uses it.
This was referenced Nov 21, 2026
Merged
Merged
Merged
Merged
Merged
Merged
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.
Switching the provider on the street trees page (144,183 markers) froze the screen for 6.4–6.5 s on an iPad Pro. Each provider's marker controller subscribed to every marker's
asFlow()on the main thread. That took 3.5 s for the new map, and the old map took 1.8–2.0 s to cancel its subscriptions.What
MarkerState.onChange(_:)(@_spi(MapConductorDriver)) calls a closure on the main queue after each write to the marker. It goes through the state'sStateMutationSignal, the same wayOverlayCollectorhears writes for circles, polylines and polygons. It costs one allocation per marker.asFlow().dropFirst().OverlayCollectordoes, and the newest listener hears the writes. Cancelling a token whose listener has since been replaced leaves the newer one alone. A provider switch relies on this, because the old map is taken down after the new one has listened.MarkerIngestionEngineno longer reads and converts the icon of a marker that is tiled; only a native marker uses it.3 tests added; all 582 pass. The replaced-listener test fails if cancelling clears the listener unconditionally.
The provider controllers move to
onChangein PRs of the same branch name in the 10 provider repos.Checked
On an iPad Pro 11-inch, Release build, street trees page, switching MapLibre ⇄ Google:
Marker writes still reach the map after a switch. At zoom 16 and above the page writes label icons onto markers. Screenshots show the following: