Skip to content

fix: Stabilize PDF preview cell lifecycle - #2068

Merged
adrien-coye merged 5 commits into
masterfrom
fix/preview-kaput
Nov 6, 2026
Merged

adrien-coye merged 5 commits into
masterfrom
fix/preview-kaput

Conversation

@adrien-coye

@adrien-coye adrien-coye commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Defer PDF document activation until the preview cell is displayed, and cancel pending activation when it leaves display or is reused.
  • Pass file identity and page counts directly to the preview controller instead of looking up cells from PDF callbacks.
  • Add regression coverage for deferred activation, cancellation on reuse, page counts, and stale callbacks.

Context

PDFKit document activation during cell provisioning is the leading suspected re-entry path. The exact production crash has not been reproduced locally; device validation and beta monitoring are still needed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The unreproduced production crash depends on UIKit/PDFKit callback timing, so confirming that deferred activation prevents re-entry requires device lifecycle/stress testing and beta crash monitoring beyond static review.

No open issues 🎉

What changed in this PR

Stabilizes PDF preview cell lifecycle handling by deferring PDFKit activation until display and preventing stale callbacks from updating navigation. The suspected production crash still requires device validation and beta monitoring.

Changes:

  • Defer document activation and cancel pending work when cells leave display or are reused.
  • Pass file identity and page counts directly to the preview controller.
  • Add regression tests for activation, reuse cancellation, page counts, and stale callbacks.
File Description
kDriveTests/​kDrive/​UTPdfPreviewCollectionViewCell.swift Adds PDF lifecycle and callback regression coverage.
kDrive/​UI/​View/​Files/​Preview/​PdfPreviewCollectionViewCell.swift Defers activation, cancels pending work, and guards page updates.
kDrive/​UI/​Controller/​Files/​Preview/​PreviewViewController.swift Receives page updates directly and checks the current file.

Review effort: Balanced

@adrien-coye
adrien-coye requested a review from Lnamw November 3, 2026 10:32
@adrien-coye adrien-coye added the bug Something isn't working label Nov 4, 2026
@adrien-coye
adrien-coye marked this pull request as ready for review November 4, 2026 08:27
@adrien-coye
adrien-coye requested a review from Muuushuuu November 4, 2026 09:28
@adrien-coye
adrien-coye disabled auto-merge November 5, 2026 20:57
@adrien-coye
adrien-coye enabled auto-merge November 5, 2026 20:58
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@adrien-coye
adrien-coye merged commit c7aae4a into master Nov 6, 2026
13 of 14 checks passed
@adrien-coye
adrien-coye deleted the fix/preview-kaput branch November 6, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants