fix: provide fallback for recurrentAuthorizationStatus to prevent Settings page from blocking#1338
Open
kiyoakii wants to merge 1 commit intoovertake:masterfrom
Open
Conversation
…t Settings from blocking
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.
Problem
If
UNUserNotificationCenter.getNotificationSettings(completionHandler:)fails to call its completion handler for any reason (daemon unavailable, notification permission not yet requested, corrupted notification database state), the entire Settings page becomes permanently blank with no error indication.Cause
AccountViewControllerrenders the Settings list through a 13-signalcombineLatest(line 1076). Signal 7 (of 13),recurrentAuthorizationStatus, chains throughkeyWindowUpdaterintogetNotificationSettings. If the completion handler never fires, this signal never emits, andcombineLatestblocks all other 12 ready signals from rendering.The search bar in Settings works fine because
SearchSettingsControlleruses an independent pipeline without this dependency.Fix
Add
.single(.authorized)as an immediate default before thekeyWindowUpdaterchain, so Settings renders immediately. IfgetNotificationSettingseventually responds, the UI updates with the real status. If it never responds, Settings still works normally; in that edge case, the Notifications row may briefly lack its red warning icon for users who have denied permission, until the real status arrives. If it never arrives, the icon simply won't show.Why only this signal?
The other 12 signals in the
combineLatestalready have initial values or are backed by local data (cached preferences, database queries, etc.) that emit synchronously.recurrentAuthorizationStatusis the only one that depends entirely on an async system API call with no fallback. Ideally all signals feeding into a UI-criticalcombineLatestshould have defaults, but this PR targets the one confirmed to cause issues in practice.Verification
This bug affected my machine for months, persisting across app reinstalls, macOS upgrades, and complete data wipes. The Settings page was blank but search within Settings worked normally, which pointed to a data pipeline issue rather than a rendering bug.
Diagnosed via runtime injection (
dlopen+ ObjC method swizzling) into a running Telegram process:heaptool to find theAtomic<SignalCombineState>tracking thiscombineLatest, confirmed 12/13 signals emitted, index 7 missinggetNotificationSettingsWithCompletionHandler:onUNUserNotificationCenter, confirmed the completion handler was never calledUNNotificationSettingswith.authorizedstatus as a workaround, Settings populated immediatelyThe root cause on my machine was
usernotificationsdstuck in a crash loop (LastExitStatus = -9), making all notification APIs unresponsive. After manually restarting the daemon and granting notification permission, the issue was resolved. However, this fix ensures Settings remains functional regardless of the notification subsystem's health.