Apple’s Documentation mentions that threading the quartzcore rendering of PDF’s must be manually handled. Has anyone Implemented multi-core PDF rendering or have any idea how one could offload the rendering work to separate threads or separate a document into page chunks and distribute it to separate cores as the documentation suggests? Currently my app loads large PDF’s in about 1.5 seconds, but multi threading could cut that time hugely (haha).
Apple’s Documentation mentions that threading the quartzcore rendering of PDF’s must be manually handled.
Share
As you note, the documentation explicitly says “Distributing individual pages of a PDF document to separate threads is not supported. If you want to use threads, consider creating a separate document for each thread and operating on a block of pages per thread.” Though to adapt this guidance to GCD, what you would do instead is create a serial queue for each “block of pages” (where block size can, of course, be “one page”) and then create and manipulate the individual CGPDFDocumentRef by submitting blocks to the respective queues. Protect your data structures by also making your getter for a given CGPDFDocumentRef use the same queue with a dispatch_sync to get the value, and then it’s just a siple matter of wiring up your UI to render any given page of your document (or the entire document) by striding through the individual chunks such that it still appears to be one large document to the rest of your code.