PDFKit Page Rerender

I'm experiencing an issue with PDFKit where page.removeAnnotation(annotation) successfully removes the annotation from the page's data structure, but the PDFView no longer updates automatically to reflect the change visually. Issue Details:

The annotation is removed (verified by checking page.annotations.count) The PDFView display doesn't refresh to show the removal This code was working correctly before and suddenly stopped working No code changes were made on my end

Answered by DTS Engineer in 862824022

Thanks for mentioning this problem. I have seen other reports of this as well.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Thanks for mentioning this problem. I have seen other reports of this as well.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

The issue occurs because PDFView doesn’t automatically refresh its rendering when annotations are removed or added dynamically. It treats annotation changes as part of the page content, so the UI may not update correctly for images or custom annotations. I solved it by forcing PDFView to reload the affected page:

func pdfEditor(_ pdfEditor: PDFEditor, didUpdateAnnotationsOn page: PDFPage) { guard let pdfView = self as? PDFView, let document = pdfView.document else { return }

let pageIndex = document.index(for: page)

// Remove and re-insert the page to trigger a full redraw
document.removePage(at: pageIndex)
document.insert(page, at: pageIndex)

pdfView.setNeedsDisplay(pdfView.bounds)

}

This forces the PDFView to completely redraw the page, ensuring added or removed annotations appear correctly. It updates only the affected page, keeping it memory-efficient and smooth.

Hi @muhammadharoon. Thanks for the details. It sounds like you may have a reproducible case. I recommend packaging that up into a bug report so engineering can consider adding further investigation into their work schedule. Capturing this information in a forums post is interesting, but it is not the sort of thing our engineering teams use for scheduling work. Won't you please consider filing a feedback report about this question.

I’m seeing a related problem and have filed FB25449998 with a small sample project.

On macOS 15.8.2, after calling PDFPage.addAnnotation(_:) on a visible page, the annotation doesn’t reliably appear in PDFView until the page scrolls off screen and back (the page needs to scroll way off for it to work). The annotation is present in page.annotations. The same action in my app shows the annotation right away on iPadOS.

None of these refresh it reliably: annotationsChanged(on:), layoutDocumentView(), needsDisplay on the view or its documentView, a small zoom change, or removing and reinserting the page.

The only reliable workaround I’ve found is setting pdfView.document = nil, setting the document back and restoring the position, or creating a new PDFView. Both cause a visible flash.

Thanks for filing FB25449998 with a sample project. It builds its own PDF and has buttons for most of the refreshes you tried, so it was quick to run. Your report remains open and under investigation.

I ran your sample on a Mac with macOS 27.0.1 (26A434). Besides adding a log line, I changed only where the Add Annotation button places each box, so new boxes don't cover earlier ones. Every annotation appeared as soon as I added it, without scrolling: three in the "1 PDFView" mode and six in the "2 PDFViews" mode. In my own test app on the same Mac, annotations removed with removeAnnotation(_:) also disappeared right away. I don't have a Mac with macOS 15.8.2, so I couldn't test the release you're using.

When you can, please add to FB25449998 whether your sample shows the problem in macOS 27. Please continue to test your software in release and pre-release versions of system software made available to you through your developer.apple.com account. When you do, add details about that into your bug report to keep it up to date. Please see developer.apple.com/download.