louisdh / panelkit

A UI framework that enables panels on iOS.
MIT License
3.79k stars 160 forks source link

Crash with non-finite constraint multiplier (dividing by zero) #18

Open ian-mcdowell opened 6 years ago

ian-mcdowell commented 6 years ago

I triggered a crash in OpenTerm while trying to dock a panel to the side.

I believe this is caused by PanelManager+AutoLayout:updateFrame(for:to:keyboardShown) dividing by zero. Not sure the circumstances that caused this, or if this is something misconfigured in OpenTerm, but there should be a check to handle this case in PanelKit.

Crash is below:

Assertion failure in -[NSLayoutConstraint _setMultiplier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1444.12/Layout.subproj/NSLayoutConstraint.m:196
2018-02-06 16:45:07.837694-0800 OpenTerm[38697:2877706] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Multiplier is not finite!  That's illegal.  multiplier:inf'
ian-mcdowell commented 6 years ago

Turns out the PanelManager was missing a panel in the panels array. A better error should be thrown if a panel is presented that is not part of the panels array.