iOS 26: "Memory exhaustion. Attempted to allocate storage for 4294967296 bits" crash in -[UIPrintPreviewPageCell layoutSubviews] (UIPrintInteractionController)

We see a recurring crash in production inside the system print panel while it lays out the page preview thumbnails. None of our code is on the crashing stack.

Environment

  • iOS / iPadOS 26.0.1 through 26.7.2, on iPhone and iPad
  • So far no occurrences on iOS 27.0.0, 27.0.1, 27.2.0 or 27.2.1, but we can't tell whether that means it was fixed
  • Volume is low but steady every week

How we present the print panel
We hand a finished PDF file to the shared controller. This is presented from a SwiftUI view shown in a sheet:

let printInfo = UIPrintInfo(dictionary: nil)
printInfo.outputType = .general
printInfo.jobName = "Print Job"

let controller = UIPrintInteractionController.shared
controller.printInfo = printInfo
controller.printingItem = pdfFileURL
controller.present(animated: true) { _, completed, error in
    // ...
}

Crash

NSInternalInconsistencyException: Memory exhaustion. Attempted to allocate storage for 4294967296 bits.
_NSBitSetResize.cold.1
_NSBitSetResize
NSBitSetAddIndex
NSISLinExpEnumerateVars
_row_setHead
-[NSISEngine tryAddingDirectly:]
-[NSISEngine _tryToAddConstraintWithMarkerEngineVar:row:mutuallyExclusiveConstraints:]
-[NSISEngine tryToAddConstraintWithMarker:expression:mutuallyExclusiveConstraints:]
-[NSLayoutConstraint _addLoweredExpression:toEngine:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:]
-[NSLayoutConstraint _addToEngine:mutuallyExclusiveConstraints:]
-[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]
-[UIView _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]
-[UIView(UIConstraintBasedLayout) nsli_addConstraint:]
__55+[NSLayoutConstraint _addOrRemoveConstraints:activate:]_block_invoke
-[NSISEngine withBehaviors:performModifications:]
+[NSLayoutConstraint _addOrRemoveConstraints:activate:]
-[UIPrintPreviewPageCell layoutSubviews]
-[UIView(CALayerDelegate) layoutSublayersOfLayer:]
CA::Layer::perform_update_(...)
...

We also see the same _NSBitSetResize.cold.1 failure reached through other preview-collection-view paths:

  • UICollectionView batch updates → _updateContentSizeConstraints
  • -[UIPrintPreviewPageCell updatePageLabelAndImageViewWithIndex:] via reconfigureItemsAtIndexPaths:

What we observed

  • The requested size is always exactly 4294967296 bits (2^32), on devices with very different amounts of free memory. So it doesn't look like gradual memory growth; it looks more like a bad internal index in the layout engine.
  • The crash happens while the print panel is on screen, usually a few seconds after it appears. In many sessions the user had just opened the printer list and switched printers.
  • We already prevent the print panel from being presented twice in a row. That didn't change the crash rate.

Questions

  1. Is this a known issue in iOS 26's print preview, and was it fixed in iOS 27?
  2. Is there a recommended way to avoid it while still showing the system print panel with its preview?

Feedback: FB25738588