Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andreim-am opened this issue Oct 24, 2024 · 2 comments

Comments

@andreim-am
Copy link

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
Copy link
Author

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.

@scenee
Copy link
Owner

scenee commented Nov 3, 2024

I think this issue can be resolved using UIHostingController+ignoreKeyboard extension and setting ignoresKeyboard to true. This is because Maps-SwiftUI does not crash showing a keyboard by the search bar. And I'm happy to send me a reproducer(a sample code) for this issue :)

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

No branches or pull requests

2 participants