Skip to content

Register historical export task during app launch - #2658

Merged
ps2 merged 1 commit into
LoopKit:next-devfrom
damonbayer:dmb/fix-background-task-registration
Nov 6, 2026
Merged

ps2 merged 1 commit into
LoopKit:next-devfrom
damonbayer:dmb/fix-background-task-registration

Conversation

@damonbayer

Copy link
Copy Markdown
Contributor

Refs #2657.

Changes

  • Register the historical log export task once during application launch.
  • Check export manager readiness on the main queue and run the export on a background queue. Complete the task with a failure if the export cannot start.

Verification

Swift parsing, plist validation, and git diff --check passed. Xcode rejected the workspace before compilation in the local build attempt. The locked-device launch path still needs device verification.

@ps2 ps2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Damon. I checked both paths where the old code could register again: launch() runs from scene(_:willConnectTo:) and again from applicationProtectedDataDidBecomeAvailable when launch was deferred on a locked device. The second call registered the same identifier after launch had finished, and BGTaskScheduler aborts on that. Registering once in didFinishLaunching fixes it. Running the handler on main, so it reads criticalEventLogExportManager on the queue that sets it, and completing the task on failure are both improvements. It builds cleanly with the LoopWorkspace scheme.

One possible follow-up, separate from this PR: when iOS launches Loop in the background only for this task, no scene connects (or protected data isn't available), so the export manager is nil and the task now fails right away. Nothing reschedules it until the next full launch calls scheduleCriticalEventLogHistoricalExportBackgroundTask(). That was already the case before this change.

@ps2
ps2 merged commit 0ee46e3 into LoopKit:next-dev Nov 6, 2026
ps2 added a commit to LoopKit/LoopWorkspace that referenced this pull request Nov 8, 2026
…seKit and MedtrumKit (#574)

* Bump Loop and LoopKit

Loop: two days of carb history on the Carbohydrates screen
(LoopKit/Loop#2654), register the historical export background task at
launch (LoopKit/Loop#2658), brighter app icon (LoopKit/Loop#2656).

LoopKit: extend only an unresumed suspend to the overlay end date
(LoopKit/LoopKit#689, fixes LoopKit/LoopKit#688), VoiceOver for
checkmark lists and unset values (LoopKit/LoopKit#671).

* Bump Loop, G7SensorKit, TidepoolService, OmnipodKit, EversenseKit and MedtrumKit

* Bump EversenseKit for the fixed E3 current glucose test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants