Skip to content

Fix crash from CGRect.null in crop guide constraint updates - #283

Open
ohlulu wants to merge 1 commit into
FluidGroup:mainfrom
AluStudio:fix/crop-guide-null-rect-crash
Open

Fix crash from CGRect.null in crop guide constraint updates#283
ohlulu wants to merge 1 commit into
FluidGroup:mainfrom
AluStudio:fix/crop-guide-null-rect-crash

Conversation

@ohlulu

@ohlulu ohlulu commented Apr 2, 2026

Copy link
Copy Markdown

Fixes #282

CGRect.intersection() returns .null (infinite coords) when the crop guide frame and container bounds don't overlap during a fast pan gesture. Setting inf as a constraint constant crashes with NSInternalInconsistencyException.

Changes

updateMaximumRect() — bail out when intersection is null; keep the previous maximumRect so constraints stay on the last valid values until the next good frame.

activate{Left,Right,Top,Bottom}MaxConstraint() — replace maximumRect! / superview! force-unwraps with guard let so a nil maximumRect (if the first intersection on .began is somehow null) skips constraint activation instead of crashing.

CGRect.intersection() returns CGRect.null (infinite coordinates) when
the crop guide frame and container bounds don't overlap during a pan
gesture. Setting infinite values as NSLayoutConstraint constants
triggers NSInternalInconsistencyException.

Two layers of defense:

1. updateMaximumRect(): skip update when intersection is null, keeping
   the previous valid maximumRect so constraints use stale-but-safe
   values until the next valid frame.

2. activate{Left,Right,Top,Bottom}MaxConstraint(): guard maximumRect
   and superview instead of force-unwrapping, so a nil maximumRect
   (e.g. null intersection on gesture begin) gracefully skips
   constraint activation instead of crashing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash: NSInternalInconsistencyException in updateMaximumRect during crop pan gesture

1 participant