Skip to content

Prevent All-history photo sync from freezing the map - #74

Merged
CodyBontecou merged 1 commit into
mainfrom
codex/map-all-photo-sync
Oct 25, 2026
Merged

CodyBontecou merged 1 commit into
mainfrom
codex/map-all-photo-sync

Conversation

@CodyBontecou

Copy link
Copy Markdown
Owner

Summary

Selecting All on a large photo library blocks the main thread in per-asset SwiftData fetches and can trigger a watchdog termination.

 syncPhotoMoments
-  fetch existing record for every photo
+  fetch existing records once and index by asset identifier
+  update in batches, allowing input between batches
+  serialize syncs and process the latest pending range

Evidence

  • Before: The iPhone 17 Pro watchdog stack stops in fetchPhotoMoment during photo sync. The 2,000-photo input-responsiveness regression failed (1.98 seconds).
    After: The regression passes (0.16 seconds). All 301 XCTest cases pass. The attached iPhone loads 11,354 matched photos and switches All → Today; the recorded device replay passes and no new crash reports appeared.
  • Existing photo identities and metadata updates are covered, including duplicate assets across batch boundaries. No schema migration.

Merge Danger

Door: two-way

Revert the commit to restore previous behavior.

Blast Radius: Photos

Changes photo metadata sync scheduling and lookup behavior; photo files remain in Photos.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T15:25:03.648772Z 1171f06 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1171f06b92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if index.isMultiple(of: 100) {
// Give the main run loop time for input and lifecycle events;
// SwiftData models remain confined to the main actor.
try await Task.sleep(for: .milliseconds(1))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate an in-flight photo sync when clearing data

If the user confirms Clear All Data while a large photo sync is yielding between batches, clearAllData() can now delete and save the photo records before this loop resumes. The sync then continues inserting the remaining metadata and saves it in performPhotoMomentSync, repopulating the store after the clear—including coordinates inferred from location history that was just deleted. Previously the synchronous upsert could not interleave with the clear action. Invalidate active and pending syncs when clearing data, and check that invalidation after each suspension before applying further mutations.

Useful? React with 👍 / 👎.

@CodyBontecou
CodyBontecou merged commit c90999c into main Oct 25, 2026
1 check passed
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.

1 participant