fix: prevent map viewport race on tab switch with no location#627
Merged
torlando-tech merged 1 commit intomainfrom Mar 8, 2026
Merged
fix: prevent map viewport race on tab switch with no location#627torlando-tech merged 1 commit intomainfrom
torlando-tech merged 1 commit intomainfrom
Conversation
…aunchedEffect When no GNSS and no offline map are available, the map falls back to (0,0) at zoom 2.0. The onCameraIdle listener would save this as a "real" viewport, causing it to persist across tab switches. Additionally, when switching tabs repeatedly, a fresh MapView's default viewport (zoom ~0, full world) could overwrite the saved position before the positioning LaunchedEffect ran. Add isInitialPositionSet guard to gate onCameraIdle saving until the positioning LaunchedEffect has intentionally placed the camera. Clear stale (0,0) fallback from ViewModel state so it doesn't block future GPS or default-region centering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Greptile SummaryThis PR fixes a critical race condition in the map viewport handling where repeatedly switching tabs with no GNSS or offline map caused the viewport to jump from (0,0) zoom 2.0 to a full-world default view. The fix prevents the Key changes:
Testing: The fix correctly handles tab switches, config changes, GNSS availability transitions, and offline map region changes without regressing the viewport behavior. Confidence Score: 5/5
Last reviewed commit: ef405a1 |
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
onCameraIdlelistener was saving a fresh MapView's default viewport before the positioningLaunchedEffectcould run, overwriting the saved camera positionChanges
isInitialPositionSetguard that gatesonCameraIdlesaving until positioning is intentionally set; reset on MapView recreation; clear stale (0,0) from ViewModelclearCameraPosition()to null out the fallback position so it doesn't persistTest plan
🤖 Generated with Claude Code