scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.6k stars 508 forks source link

App crashes when attempting to input text in a UIHostingViewController that is added in a floating panel #651

Open andreim-am opened 1 week ago

andreim-am commented 1 week ago

Description The FloatingPanel does not recalculate its height when the keyboard appears. This leads to conflicting constraints and causes the application to become unresponsive until it crashes due to memory issues.

Expected behavior The FloatingPanel should dynamically adjust its height when the keyboard appears and invalidateLayout() is called.

Actual behavior When a text field becomes focused, the layout is invalidated, and the panel attempts to recalculate its height. However, it fails to detect the keyboard height, resulting in conflicting constraints that cause the panel to become stuck. If a hardcoded height is provided before invalidating the layout, it functions correctly without memory issues/freeze.

Steps to reproduce Present the FloatingPanel with a swiftui view that has a text field inside. Focus on the text field to trigger the keyboard. Observe that the FloatingPanel does not adjust its height appropriately and eventually the app crashes.

How do you display panel(s)? self.present()

How many panels do you display? 1

Environment Library version: 2.8.3

Installation method: Swift Package Manager

iOS version(s): 17.5

Xcode version: 15

andreim-am commented 1 week ago

Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x2890ccff0 'FloatingPanel-static-height' FloatingPanelSurfaceView:0x109f33cf0.height == 0 (active)>", "<NSLayoutConstraint:0x281025860 'FloatingPanel-surface-content' FloatingPanelSurfaceView:0x109f33cf0.height >= 1 (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x281025860 'FloatingPanel-surface-content' FloatingPanelSurfaceView:0x109f33cf0.height >= 1 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.