Repository navigation
Fix watch crash when changing pages - #2631
Merged
Merged
Conversation
ExtensionDelegate.shared() looked up WKApplication.shared().delegate, which is nil under the SwiftUI app lifecycle, so it trapped. The usage recording added in #2629 calls it from SwiftUI views, so swiping between pages, or opening carbs, bolus or presets, crashed the watch app. The delegate now records itself when it is created.
ps2
marked this pull request as ready for review
October 31, 2026 19:50
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.
On next-dev, the watch app crashes as soon as you swipe between pages.
ExtensionDelegate.shared()looked upWKApplication.shared().delegate. Under the SwiftUI app lifecycle (@WKApplicationDelegateAdaptor) that property is nil, so the implicitly unwrapped accessor trapped. The usage recording added in #2629 callsshared()from SwiftUI views: page changes inContentView, and the carbs, bolus, presets and carb list buttons. Each of those crashed the watch app.The delegate now stores itself in
init, andshared()returns that instance.Testing
EXC_BREAKPOINTinExtensionDelegate.shared()(ExtensionDelegate.swift:29), called fromContentView.swift:56.screenCounts(actions: 1, chart: 2).LoopWatchApp. That edit is not part of this PR.