Cull offscreen map markers to keep panning performant#5
Merged
Conversation
Marker is a native View that reprojects every camera frame even when offscreen, so the accumulated set was growing unbounded. Filter to the last-known viewport bounds before rendering; cached pins outside the viewport stay in memory and reappear instantly on pan-back. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
af7dcf9 to
505a772
Compare
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
<Marker>from@maplibre/maplibre-react-nativeis a native View — MapLibre reprojects every marker on every camera frame, with no viewport culling. As the accumulator grew across pans, the offscreen markers were degrading performance.elementsByIdto the last-known viewport bounds before rendering. Cached entries stay in memory, so panning back to a previously-visited area shows pins instantly.Notes
GeoJSONSource+ symbol layer (GPU-rendered, native viewport culling, free clustering) but MapLibre Native pre-rasterizes glyphs server-side and OpenFreeMap's font stack doesn't ship emoji ranges, sotext-field: ['get', 'icon']404s on every emoji codepoint. Twemoji-via-iconImageis a viable future path if marker counts get large enough to matter.Test plan
🤖 Generated with Claude Code