Posts

Post not yet marked as solved
8 Replies
900 Views
I stumbled upon a really peculiar issue while running my application that features both a functionality to create image and video attachments from the user's photos and videos using the PHPicker* API and previewing said attachments using the QuickLook API: Whenever I tap to open a photo (e.g. a JPEG) or a video (e.g. a MP4) using the QuickLook API, on an iPhone 13 15.4 simulator device on Xcode 13.3 on a M1 Macbook Pro host machine, I get a crash with the following call stack: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]' terminating with uncaught exception of type NSException *** First throw call stack: ( 0 CoreFoundation 0x000000011003bd44 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x000000010cd1ea65 objc_exception_throw + 48 2 CoreFoundation 0x00000001100bcf47 _CFThrowFormattedException + 200 3 CoreFoundation 0x00000001100c7417 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.5 + 0 4 CoreFoundation 0x00000001100aa827 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 243 5 CoreFoundation 0x000000011003a998 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49 6 QuickLook 0x0000000110f37636 __49+[QLItem(PreviewInfo) contentTypesToPreviewTypes]_block_invoke + 484 7 libdispatch.dylib 0x000000011b0f5a5b _dispatch_client_callout + 8 8 libdispatch.dylib 0x000000011b0f6f24 _dispatch_once_callout + 66 9 QuickLook 0x0000000110f37450 +[QLItem(PreviewInfo) contentTypesToPreviewTypes] + 46 10 QuickLook 0x0000000110f37d91 -[QLItem(PreviewInfo) _uncachedPreviewItemTypeForContentType:] + 117 11 QuickLook 0x0000000110f382fe -[QLItem(PreviewInfo) _previewItemTypeForType:] + 150 12 QuickLook 0x0000000110f38104 -[QLItem(PreviewInfo) _getPreviewItemType] + 61 13 QuickLook 0x0000000110fbf4d2 -[QLItem previewItemType] + 59 14 QuickLook 0x0000000110f6ed15 +[QLItemFetcherFactory fetcherForPreviewItem:] + 90 15 QuickLook 0x0000000110fbeb9b -[QLItem fetcher] + 44 16 QuickLook 0x0000000110f22880 -[QLPreviewController previewItemAtIndex:withCompletionHandler:] + 153 17 QuickLook 0x0000000110f587a8 __63-[QLPreviewItemStore previewItemAtIndex:withCompletionHandler:]_block_invoke + 262 18 QuickLook 0x0000000110f8c621 QLRunInMainThread + 51 19 QuickLook 0x0000000110f58673 -[QLPreviewItemStore previewItemAtIndex:withCompletionHandler:] + 181 20 QuickLook 0x0000000110f1c89f -[QLPreviewController internalCurrentPreviewItem] + 222 21 QuickLook 0x0000000110f9c140 -[QLPreviewController(Overlay) _actionButton] + 344 22 QuickLook 0x0000000110f9c81c -[QLPreviewController(Overlay) _toolBarButtonsWithTraitCollection:] + 1147 23 QuickLook 0x0000000110f9a2ff -[QLPreviewController(Overlay) _updateOverlayButtonsIfNeededWithTraitCollection:animated:updatedToolbarButtons:] + 129 24 QuickLook 0x0000000110f999a2 -[QLPreviewController(Overlay) updateOverlayAnimated:animatedButtons:forceRefresh:withTraitCollection:] + 152 25 QuickLook 0x0000000110f1c707 -[QLPreviewController _setCurrentPreviewItemIndex:updatePreview:animated:] + 230 26 QuickLook 0x0000000110f22416 -[QLPreviewController reloadData] + 418 27 <MYAPP> 0x0000000102a03293 __53-[MyPreviewController downloadAttachment]_block_invoke_2 + 611 28 libdispatch.dylib 0x000000011b0f4816 _dispatch_call_block_and_release + 12 29 libdispatch.dylib 0x000000011b0f5a5b _dispatch_client_callout + 8 30 libdispatch.dylib 0x000000011b104325 _dispatch_main_queue_drain + 1169 31 libdispatch.dylib 0x000000011b103e86 _dispatch_main_queue_callback_4CF + 31 32 CoreFoundation 0x000000010ffa8261 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 33 CoreFoundation 0x000000010ffa2a56 __CFRunLoopRun + 2761 34 CoreFoundation 0x000000010ffa1a90 CFRunLoopRunSpecific + 562 35 GraphicsServices 0x00000001209c8c8e GSEventRunModal + 139 36 UIKitCore 0x000000013499c90e -[UIApplication _run] + 928 37 UIKitCore 0x00000001349a1569 UIApplicationMain + 101 38 <MYAPP> 0x0000000102970669 main + 233 39 dyld 0x000000010c6c4f21 start_sim + 10 40 ??? 0x00000002041ad51e 0x0 + 8658801950 41 ??? 0x0000000000000003 0x0 + 3 I tried also selecting a photo or a video using the PHPicker* APIs, and although I get back the file, if I try to query the UTType from the file extension using the [UTType typeWithFilenameExtension:] method, I get back a nil result if the extension passed is either a "jpeg" or a "mp4". The above do not happen if I run the same simulator (iPhone 13 15.4 / Xcode 13.3) on an Intel Macbook Pro host machine, or on a real device. Any ideas?
Posted Last updated
.