Hi, @webd . The workaround you described works like a charm. After implementing it, there have been almost no crashes on iOS 16.* related to PDF printing. Thanks a lot!
Post
Replies
Boosts
Views
Activity
Hi, @moonkake. I'm still unable to resolve this crash. The crash seems to be quite common based on the crash statistics for my app. Here is all the information I have regarding these crashes:
The crash is sporadic and I have not been able to reproduce it manually.
It only occurs on devices running iOS 16.*.
The crash can happen on both iPhones and iPads.
It doesn't seem to be related to low memory.
Stack traces can vary, there are the three most common ones:
pdf_xref_get_trailer
Crashed: com.apple.main-thread
0 CoreGraphics 0x619a0 pdf_xref_get_trailer + 16
1 CoreGraphics 0x5e1f4 get_pages_dictionary + 24
2 CoreGraphics 0x61528 pdf_reader_get_number_of_pages + 80
3 PrintKitUI 0x562cc -[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76
4 PrintKitUI 0x27178 -[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32
5 UIKitCore 0xa409c -[UICollectionViewData _updateItemCounts] + 228
6 UIKitCore 0x459948 -[UICollectionViewData numberOfSections] + 40
7 UIKitCore 0x61b78 -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 500
8 UIKitCore 0x6191c -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 248
9 UIKitCore 0x75d80 -[UICollectionViewFlowLayout prepareLayout] + 192
10 UIKitCore 0x74044 -[UICollectionViewData _prepareToLoadData] + 192
11 UIKitCore 0x43d12c -[UICollectionViewData validateLayoutInRect:] + 96
12 UIKitCore 0x28f4c -[UICollectionView layoutSubviews] + 220
13 UIKitCore 0x4be0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1992
14 QuartzCore 0xa074 CA::Layer::layout_if_needed(CA::Transaction*) + 500
15 QuartzCore 0x1d5f0 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
16 QuartzCore 0x2ea1c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444
17 QuartzCore 0x5dff4 CA::Transaction::commit() + 648
18 QuartzCore 0x47f3c CA::Transaction::flush_as_runloop_observer(bool) + 88
19 UIKitCore 0x4fdc04 _UIApplicationFlushCATransaction + 52
20 UIKitCore 0x64e4b0 _UIUpdateSequenceRun + 84
21 UIKitCore 0xcb2c8c schedulerStepScheduledMainSection + 144
22 UIKitCore 0xcb21e8 runloopSourceCallback + 92
23 CoreFoundation 0xd3128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
24 CoreFoundation 0xdf7b4 __CFRunLoopDoSource0 + 176
25 CoreFoundation 0x645e8 __CFRunLoopDoSources0 + 244
26 CoreFoundation 0x7a0d4 __CFRunLoopRun + 828
27 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612
28 GraphicsServices 0x135c GSEventRunModal + 164
29 UIKitCore 0x39d6e8 -[UIApplication _run] + 888
30 UIKitCore 0x39d34c UIApplicationMain + 340
...
pdf_reader_get_number_of_pages
Crashed: com.apple.main-thread
0 CoreGraphics 0x69aac pdf_reader_get_number_of_pages + 28
1 PrintKitUI 0x562b8 -[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76
2 PrintKitUI 0x27100 -[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32
3 UIKitCore 0xa6be4 -[UICollectionViewData _updateItemCounts] + 220
4 UIKitCore 0x1305c -[UICollectionViewData isIndexPathValid:validateItemCounts:] + 52
5 UIKitCore 0x113c4 -[UICollectionViewData validatedGlobalIndexForItemAtIndexPath:] + 36
6 UIKitCore 0x66f50 -[UICollectionView _cellForItemAtIndexPath:] + 108
7 UIKitCore 0x31019c -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 1384
8 UIKitCore 0x270b54 -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 396
9 UIKitCore 0x271ed0 -[UICollectionView reloadItemsAtIndexPaths:] + 52
10 PrintKitUI 0x277b8 -[UIPrintPreviewViewController reloadVisibleItems:] + 256
11 PrintKitUI 0x262b0 __63-[UIPrintPreviewViewController updatePdfURL:options:completed:]_block_invoke_2 + 44
12 Foundation 0xa7060 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24
13 Foundation 0x7b1b0 -[NSBlockOperation main] + 104
14 Foundation 0x7b140 __NSOPERATION_IS_INVOKING_MAIN__ + 16
15 Foundation 0x3c4f4 -[NSOperation start] + 708
16 Foundation 0x3c228 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16
17 Foundation 0x41940 __NSOQSchedule_f + 172
18 libdispatch.dylib 0x13114 _dispatch_block_async_invoke2 + 148
19 libdispatch.dylib 0x3f88 _dispatch_client_callout + 20
20 libdispatch.dylib 0x127f4 _dispatch_main_queue_drain + 928
21 libdispatch.dylib 0x12444 _dispatch_main_queue_callback_4CF + 44
22 CoreFoundation 0x9a6c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
23 CoreFoundation 0x7c02c __CFRunLoopRun + 2036
24 CoreFoundation 0x80eb0 CFRunLoopRunSpecific + 612
25 GraphicsServices 0x1368 GSEventRunModal + 164
26 UIKitCore 0x3a1668 -[UIApplication _run] + 888
27 UIKitCore 0x3a12cc UIApplicationMain + 340
...
getPageImageForPage the same as @a.protska posted above.
I am planning to submit a TSI request to Apple.