Custom PDFPage is „skipped“ on a specific page after the first rendering

I have a custom page renderer, aka a subclass of PDFPage, which has a custom draw method.
Code Block
class KilibeePDFPage:PDFPage {
    override func draw(with box: PDFDisplayBox, to context: CGContext) {
super.draw(with: box, to: context)
//Some Additional drawing
}
}

My PDFDocumentDelegate returns this class, and is set up correctly
Code Block
public func classForPage() -> AnyClass {
return KilibeePDFPage.self
}


In general, this works just fine (in several hundreds of PDF documents, many of them with a few hundred pages and up to 400 MB of size).

Now, I encountered one specific document (rather normal… 48 MB, 158 pages), which – for the lack of a better word – „looses“ my custom KilibeePDFPage on a specific page (33) after the first couple of PDF tiles, at latest after the first redraw.

I have set a logging breakpoint and confirmed that my custom draw method is used for the very first drawing, but is not entered at all as soon as I redraw this specific page, i.e. by zooming in.

It looks like the PDFView suddenly draws using the original PDFPage, not the one that it should use according to the Delegate.

As soon as I change the page to another one, everything works fine.

It looks that there is something on that specific page, which seems to interfere with page rendering, and leads to some kind of fallback.

Does that ring a bell? I'm really lost by now, and have no ideas what I could do to address the issue. Any ideas are greatly appreciated!


Custom PDFPage is „skipped“ on a specific page after the first rendering
 
 
Q