Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

« Nine month till Europ… | Home | XDC Schedule Now Avai… »

JPEG rendering in MacOS Mojave


We got a problem reported by am user about PDFKit RenderPage function (PDFKit.GetPDFPageImage in FileMaker Plugin and PDFPageMBS.Render in Xojo Plugin) in our plugin skipping some content in a PDF file. Precisely a server with MacOS failed to render a PDF completely as one of the images inside was missing.

The PDF itself seems to open fine in Preview.app on that Mac. But when you extract the JPEG, it fails to render
When you open that jpeg on the server in Apple's Preview.app, the app freezes. The stack trace looks like this:

+ 2669 CGImageProviderCopyImageBlockSetWithOptions (in CoreGraphics) + 137 [0x7fff367b16e0]
+  2669 IIOImageProviderInfo::CopyImageBlockSetWithOptions(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) (in ImageIO) + 650 [0x7fff38ead344]
+   2669 IIOImageProviderInfo::copyImageBlockSetWithOptions(CGImageProvider*, CGRect, CGSize, __CFDictionary const*) (in ImageIO) + 509 [0x7fff38ead5b1]
+     2669 IIO_Reader::CopyImageBlockSetProc(void*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) (in ImageIO) + 101 [0x7fff38ead71d]
+      2669 AppleJPEGReadPlugin::copyImageBlockSet(InfoRec*, CGImageProvider*, CGRect, CGSize, __CFDictionary const*) (in ImageIO) + 1708 [0x7fff38eae880]
+       2669 AppleJPEGReadPlugin::createImageBlockSetWithHardwareDecode(InfoRec*, CGImageProvider*, CGSize, bool*) (in ImageIO) + 85 [0x7fff38f77397]
+         2669 AppleJPEGReadPlugin::createImageBlockSetWithHardware_intel(InfoRec*, CGImageProvider*, __CFData const*, CGSize, bool*) (in ImageIO) + 343 [0x7fff38f16b1b]
+          2669 AppleJPEGReadPlugin::createIOSurfaceWithHardware_intel(CGImageProvider*, __CFData const*, unsigned int, VPA_HWJPEGDecodeSession*, __IOSurface**) (in ImageIO) + 74 [0x7fff38f15d9a]
+           2669 AppleJPEGReadPlugin::acquireSession() (in ImageIO) + 24 [0x7fff38f15816]
+             2669 _pthread_mutex_firstfit_lock_slow (in libsystem_pthread.dylib) + 226 [0x7fff637944b7]
+              2669 _pthread_mutex_firstfit_lock_wait (in libsystem_pthread.dylib) + 96 [0x7fff63796d6c]
+               2669 __psynch_mutexwait (in libsystem_kernel.dylib) + 10 [0x7fff636dee76]


So JPEG rendering is done via Intel hardware in Mojave and the server in VMWare has no access to that hardware. But the same file in other places like Finder Icon preview works as that seems to use a different code path!?

Looks like the PDFKit code we use is different from the one Preview.app uses. With PDFKit drawing PDF into memory buffer to create image, it tries to do the hardware. That fails, but it doesn't wait endless, but returns quickly without rendering the JPEG image. Images not embedded in JPEG format render correctly.

Alternative way is to render would be via DynaPDF which brings its own code libraries.

PS: Also happens on a FileMaker Server on MacOS (Without VM) running without display. So if graphics card is deactivated, this seems to fail for PDFKit rendering, too. Reported to Apple with radar 47544376.
25 01 19 - 10:59
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.