Repository navigation
fix(calendar): stop re-checking access every minute without a grant - #1922
Merged
Merged
Conversation
reload() set lastReloadAt only after the access guard, so with Calendar on but no full access, reloadIfStale saw a nil stamp on every MeetingClock tick and re-ran EKEventStore.authorizationStatus. Each call opened and cancelled XPC connections to remindd and CalendarAgent and logged 'XPC connection was invalidated' once a minute. Stamp it before the guard, so a missing grant is re-checked on the stale interval and on each summon.
|
Thanks for the PR! A maintainer will review it soon. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change addresses repeated Calendar authorization checks while preserving the existing refresh triggers.
No open issues 🎉
What changed in this PR
This PR prevents Calendar access checks and EventKit/XPC activity from recurring every minute when Calendar access has not been granted, while preserving existing refresh triggers.
Changes:
- Records
lastReloadAtbefore the authorization guard. - Preserves retries on the stale interval, day rollover, wake, and palette summon.
- Avoids repeated denied-access checks without changing granted-access behavior.
| File | Description |
|---|---|
| Tinycast/Features/Calendar/Service/CalendarStore.swift | Records reload attempts before checking Calendar authorization to prevent repeated minute-by-minute access checks without a grant. |
Review effort: Lite
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.
Related issue
Closes #1927
Why this is needed
It is for users who have Calendar on in Settings but no Calendar grant from macOS. Every user who upgraded from a
com.tinycast.appbuild with Calendar on is in this state, because the grant stays with the old bundle id. For them, Tinycast wakes every minute, calls two system daemons andtccd, and writes an error to the system log, with no result. This change stops that work and makes the "Nothing polls" invariant indocs/features/calendar.mdtrue again.What it could break
lastReloadAtwas already set on each granted reload, and the stamp now comes a few lines earlier in the same synchronous call.span.didSetnow also re-runsreload()after a denied reload. That re-checks access and publishes an empty list, which is correct.What changed
Calendar is on, but macOS has not granted full Calendar access. In this state, Tinycast checks access again on every minute tick. The unified log shows this pattern on the minute, every minute (246 times in 2 days on one Mac):
For each tick,
tccdalso answers fourkTCCServiceCalendar/kTCCServiceReminderspreflight requests.Cause:
CalendarStore.reload()setlastReloadAtonly after the access guard. Without a grant, the stamp staysnil. SoreloadIfStale(now:)callsreload()on everyMeetingClocktick, andreload()callsEKEventStore.authorizationStatus(for:)again. This breaks the "Nothing polls" invariant indocs/features/calendar.md.Fix: set
lastReloadAtbefore the guard. A missing grant is still checked again on the 10-minute stale interval, at the day rollover, on wake, and on every palette summon (paletteDidShowcallsreload()). So a grant made later in System Settings is still found.span.didSetandstop()work as before.How a Mac gets into this state: the
com.tinycast.apptocom.abueammar.tinycastmove carriescalendarEnabled = trueover in preferences, but TCC grants stay with the old bundle id. The new id has no TCC record, so it does not show in System Settings › Privacy › Calendars, and nothing prompts until the user toggles Calendar in Settings.Memory footprint
Tinycast Dev, fixed build,
footprint:Leak-tested: no. The change adds no allocation.
Drawbacks
See "What it could break". The one tradeoff is the up-to-10-minute delay before a new grant shows while the palette stays closed.
Tests & validation
On
Tinycast Dev(no Calendar grant) withcalendarEnabled = trueandcalendarMenuBarDisplay = 2, I watched the unified log:Checks:
./Scripts/run-tests.sh: 113 of 114 pass.FileSearchTestsfails at "undeclared waits on bytes" because an installed Adobe app declarescom.adobe.jsxon this Mac. That harness compiles onlyFeatures/FileSearch/Model, so this change does not affect it../Scripts/lint.sh: clean.Features/*/Model/import grep: no output.