Stop NavDataLoaderViewModel polling once nav data is loaded#10
Merged
Conversation
`statePollingTask` ran a 0.5s `while`/`sleep` loop for the entire app session, fetching the airport and NASR-cycle state twice a second on a background `ModelContext`. Because every context on the shared `ModelContainer` serializes on one persistent store coordinator, that perpetual poll contended with the main context's SwiftData faults — the dominant contributor to the launch-time `performBlockAndWait` main-thread hangs (SF50-TOLD-26/-20), which remain active on 3.5.6. Resolve the loader state once at launch and keep polling only while the loader is still needed (no data yet, or a download in progress). Once data is present and current the loader is dismissed and the poll stops, so a returning user — the common case — does zero background SwiftData work after launch. The existing schema-version observer continues to revive state when a reload becomes necessary. Refs SF50-TOLD-26, SF50-TOLD-20. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RISCfuture
added a commit
that referenced
this pull request
Jun 30, 2026
Reduce the main-actor SwiftData contention behind the launch-time performBlockAndWait hangs (SF50-TOLD-26/-20), and quiet transient Sentry noise: - Stop NavDataLoaderViewModel's perpetual 0.5s state poll once nav data is loaded, so a returning user does zero background SwiftData work after launch (#10). - Observe runway NOTAM changes with withObservationTracking instead of a 500ms main-actor poll for the lifetime of the takeoff/landing screen (#11). - Treat TLS handshake failures (secureConnectionFailed) as transient and stop double-reporting weather-fetch network errors to Sentry (#9). Refs SF50-TOLD-26, SF50-TOLD-20, SF50-TOLD-2D, SF50-TOLD-21. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Removes a perpetual background poll that contends with the main context for SwiftData's persistent store coordinator — the dominant contributor to the launch-time app hangs SF50-TOLD-26 / SF50-TOLD-20, which are still occurring on the current 3.5.6 build (19
App Hang Fully Blockedevents on 3.5.6+47, durations 2.4s–42s).Background
The reported hangs share one signature: a Swift concurrency job on the main executor blocked in
-[NSManagedObjectContext performBlockAndWait:], waiting for persistent-store-coordinator ownership. The launch path was already moved off the main context in prior releases, butNavDataLoaderViewModel.statePollingTaskkept awhile/sleep(0.5)loop running for the entire app session (the view model is held for the lifetime ofContentView), doing two fetches per tick on a backgroundModelContext. Every context on the sharedModelContainerserializes on a single coordinator, so this twice-a-second poll repeatedly contended with the main thread's faults.Change
showLoader == true: no data yet, or a download in progress).load()completion still drives dismissal.Testing
swift format lint --strictandswiftlint --strictclean.SF50 TOLDscheme for the iOS 26.5 iPhone 16 simulator — succeeds.The hang reduction itself is a production/contention effect not reproducible on the simulator; this PR is verified by code review plus regression checks of both loader paths.
🤖 Generated with Claude Code