Post

Replies

Boosts

Views

Activity

Floating crash when presenting UIPrintInteractionController on iOS 16
Starting iOS 16 seeing some crashes related to pdf printing in the crash reporter. It looks like the issue is not so frequent. Also, I'm unable to reproduce the crash. Looks like the app crashes when the print preview dialog is opening. According to crash reports, there are some crashes on different iOS 16 versions: 16.0.0, 16.0.2, and 16.0.3. The printing code itself is trivial: let printInfo = UIPrintInfo.printInfo() printInfo.jobName = "Printing Job Name" self.printViewController = UIPrintInteractionController.shared self.printViewController?.printInfo = printInfo self.printViewController?.printingItem = pdfURL self.printViewController?.present(from: barButtonItem, animated: true) { (controller, completed, error) in     self.printViewController = nil } There is stack trace I got from the Organizer:
0
0
1.2k
Oct ’22
Crash when presenting UIPrintInteractionController on iOS 16
Starting iOS 16 seeing some crashes related to pdf printing in the crash reporter. It looks like the issue is not so frequent. Also, I'm unable to reproduce the crash. Looks like the app crashes when the print preview dialog is opening. According to crash reports, there are some crashes on different iOS 16 versions: 16.0.0, 16.0.2, and 16.0.3. Printing code: let printInfo = UIPrintInfo.printInfo() printInfo.jobName = "Printing Job Name" self.printViewController = UIPrintInteractionController.shared self.printViewController?.printInfo = printInfo self.printViewController?.printingItem = pdfURL self.printViewController?.present(from: barButtonItem, animated: true) { (controller, completed, error) in self.printViewController = nil } Stack trace: compare_key + 4 (CGPDFObject.c:134) bsearch + 68 (bsearch.c:70) CGPDFDictionaryGetUnresolvedObject + 68 (CGPDFDictionary.c:153) CGPDFDictionaryGetObject + 44 (CGPDFDictionary.c:172) CGPDFDictionaryGetDictionary + 44 (CGPDFDictionary.c:284) get_pages_dictionary + 68 (pdf-reader.c:410) pdf_reader_get_number_of_pages + 76 (pdf-reader.c:557) -[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76 (UIPrintPreviewPageFetcher.m:115) -[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32 (UIPrintPreviewViewController.m:482) -[UICollectionViewData _updateItemCounts] + 220 (UICollectionViewData.mm:335) -[UICollectionViewData isIndexPathValid:validateItemCounts:] + 52 (UICollectionViewData.mm:348) -[UICollectionViewData validatedGlobalIndexForItemAtIndexPath:] + 36 (UICollectionViewData.mm:778) -[UICollectionView _cellForItemAtIndexPath:] + 108 (UICollectionView.m:7112) -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 1384 (UICollectionView.m:9357) -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 396 (UICollectionView.m:9104) -[UICollectionView reloadItemsAtIndexPaths:] + 52 (UICollectionView.m:9124) -[UIPrintPreviewViewController reloadVisibleItems:] + 256 (UIPrintPreviewViewController.m:568) __63-[UIPrintPreviewViewController updatePdfURL:options:completed:]_block_invoke_2 + 44 (UIPrintPreviewViewController.m:305) __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545) -[NSBlockOperation main] + 104 (NSOperation.m:1564) __NSOPERATION_IS_INVOKING_MAIN__ + 16 (NSOperation.m:2189) -[NSOperation start] + 708 (NSOperation.m:2206) There is full stack trace I got from the Organizer Thanks!
13
5
4.5k
Oct ’22
Floating NSInternalInconsistencyException crash when printing PDF
I use the following code to print PDF: let printInfo = UIPrintInfo.printInfo() printInfo.outputType = UIPrintInfo.OutputType.general printInfo.jobName = "My Print Job" printInfo.orientation = .portrait let printController = UIPrintInteractionController.shared printController.printInfo = printInfo printController.printingItem = pdfData printController.delegate = self printController.present(animated: true, completionHandler: nil) Everything works fine, but according to the Xcode Organizer, some users experience sporadic crashes after initiating printing. It appears that these crashes may be related to updates in the UI within UIPrintInteractionController. The majority of these crashes occur on iOS 16, with a few also affecting iOS 17. I am unable to reproduce the issue. Stack trace for iOS 16.6.1: Fatal Exception: NSInternalInconsistencyException Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (0), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). Collection view: <UICollectionView: 0x14d9a1a00; frame = (0 0; 235 944); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fe9fb0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x28164e660>; contentOffset: {0, 0}; contentSize: {235, 88}; adjustedContentInset: {0, 0, 0, 0}; layout: <UIPrintPreviewFlowLayout: 0x14b7c1320>; dataSource: <UIPrintPreviewViewController: 0x14d811200>> Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x9cb4 __exceptionPreprocess 1 libobjc.A.dylib 0x183d0 objc_exception_throw 2 Foundation 0x4e154c _userInfoForFileAndLine 3 UIKitCore 0x7024f4 -[UICollectionView _Bug_Detected_In_Client_Of_UICollectionView_Invalid_Number_Of_Items_In_Section:] 4 UIKitCore 0x30d5a8 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] 5 UIKitCore 0x26bd5c -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] 6 UIKitCore 0x26d0e0 -[UICollectionView reloadItemsAtIndexPaths:] 7 PrintKitUI 0x2677c __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke_3 8 UIKitCore 0x30494 +[UIView(Animation) performWithoutAnimation:] 9 PrintKitUI 0x266c8 __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke 10 PrintKitUI 0x57b30 -[UIPrintPreviewPageFetcher resetAllPages:] 11 PrintKitUI 0x26460 -[UIPrintPreviewViewController updatePrintPreviewInfo:] 12 PrintKitUI 0x47b84 -[UIPrintPanelViewController updatePrintPreviewInfo] 13 PrintKitUI 0x45d5c -[UIPrintPanelViewController observeValueForKeyPath:ofObject:change:context:] 14 Foundation 0x3c0d0 NSKeyValueNotifyObserver 15 Foundation 0x52618 NSKeyValueDidChange 16 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] 17 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] 18 Foundation 0x3e1f8 _NSSetLongLongValueAndNotify 19 PrintKitUI 0x52e00 -[UIPrintInColorOption observeValueForKeyPath:ofObject:change:context:] 20 Foundation 0x3c0d0 NSKeyValueNotifyObserver 21 Foundation 0x52618 NSKeyValueDidChange 22 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] 23 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] 24 Foundation 0x3e7dc _NSSetObjectValueAndNotify 25 PrintKitUI 0x496f0 __51-[UIPrintPanelViewController lookupLastUsedPrinter]_block_invoke_2 26 libdispatch.dylib 0x2320 _dispatch_call_block_and_release 27 libdispatch.dylib 0x3eac _dispatch_client_callout ... Stack trace for iOS 17.0.3: Fatal Exception: NSInternalInconsistencyException UITableView dataSource returned a nil cell for row at index path: <NSIndexPath: 0x96b9dd5bd6ad637d> {length = 2, path = 0 - 0}. Table view: <UITableView: 0x108846400; frame = (0 0; 430 542); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fa8ae0>; backgroundColor = <UIDynamicSystemColor: 0x280481bc0; name = systemGroupedBackgroundColor>; layer = <CALayer: 0x2817cbea0>; contentOffset: {0, -56}; contentSize: {430, 332.99999618530273}; adjustedContentInset: {56, 0, 0, 0}; dataSource: <UIPrintOptionsTableViewController: 0x108819600>>, dataSource: <UIPrintOptionsTableViewController: 0x108819600> Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xed5e0 __exceptionPreprocess 1 libobjc.A.dylib 0x2bc00 objc_exception_throw 2 Foundation 0x6bc398 _userInfoForFileAndLine 3 UIKitCore 0x289d74 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] 4 UIKitCore 0x289a70 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] 5 UIKitCore 0x287fbc -[UITableView _updateVisibleCellsNow:] 6 UIKitCore 0xfc45dc -[UITableView _updateAnimationDidStopWithOldVisibleViews:finished:context:] 7 UIKitCore 0x850bc __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ 8 UIKitCore 0x84854 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] 9 UIKitCore 0x83ecc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 10 UIKitCore 0x66498 -[UIViewAnimationState animationDidStop:finished:] 11 QuartzCore 0x7276c run_animation_callbacks(void*) 12 libdispatch.dylib 0x4300 _dispatch_client_callout ... Full exception stacktrace iOS 16 Full exception stacktrace iOS 17 Is anyone experiencing similar issues? Thanks!
2
1
984
Nov ’23