Skip to content

Crash: NSInternalInconsistencyException in updateMaximumRect during crop pan gesture #282

Description

@ohlulu

What happened

App crashes when dragging the bottom edge of the crop guide. CGRect.intersection() in updateMaximumRect() returns CGRect.null (all coordinates are inf), and those get set as NSLayoutConstraint.constant — which throws NSInternalInconsistencyException.

Stack trace (key frames)

Fatal Exception: NSInternalInconsistencyException

3  CoreAutoLayout  -[NSLayoutConstraint _setSymbolicConstant:constant:symbolicConstantMultiplier:]
4  CoreAutoLayout  -[NSLayoutConstraint setConstant:]
5  Pikgeon         CropView._InteractiveCropGuideView.onGestureTrackingChanged() + 372
6  Pikgeon         CropView._InteractiveCropGuideView.handlePanGestureInBottom(gesture:) + 947

Where

CropView._InteractiveCropGuideView.swift, updateMaximumRect():

let r = self.frame
    .inset(by: reversedInsets)
    .intersection(containerView.bounds.inset(by: insetOfGuideFlexibility))

maximumRect = r

leftMaxConstraint?.constant = r.minX          // inf when r is .null
rightMaxConstraint?.constant = maximumRect!.maxX - superview!.bounds.maxX
topMaxConstraint?.constant = r.minY
bottomMaxConstraint?.constant = maximumRect!.maxY - superview!.bounds.maxY

When the expanded guide frame and the container bounds don't overlap (can happen during fast panning), intersection() returns CGRect.null. Its coordinates are all inf, and Auto Layout rejects infinite constraint constants.

The four activate*MaxConstraint() methods also force-unwrap maximumRect! and superview!, which would crash if maximumRect is still nil (e.g. null intersection on the very first .began call).

Reproduce

Hard to reproduce on demand — it happens during fast/aggressive dragging of the crop guide edge. Showed up in Crashlytics from a real user session.

Environment

  • Brightroom 3.2.0
  • iOS 18
  • iPhone (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions