Search code examples
swiftxcodecrashnslayoutconstraintios14

iOS 14: App freezes without crash report on updating constraint constant


I have a strange issue on updating a NSLayoutConstraint constant value.

I have a view controller with a custom UIView (which acts as a bottom sheet / card). Inside my UIView class I am updating the views height constraint based on the attached UIPanGestureRecognizer. This works perfectly. As soon as the gesture ends, I am animating the height constraint to a particular value. At this POINT, the app completely freezes without a crash report. What's even strange is that it freezes on particular devices only: eg iPhone Pro 11 Max / Pro, iPhone X. It is working seamlessly on an iPhone SE or iPad.

The app becomes unresponsive and the memory continually increases and rapidly.

Anybody has ANY clue what's going on?


Solution

  • After hours of debugging. Hope this helps someone:

    My UIView used a UIScrollView inside. The following line fixed the crash:

    scrollView.contentInsetAdjustmentBehavior = .always