-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Using UIView container as text input superview for textinput plugin #29108
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@zhongwuzw Were you ever able to reproduce this? |
@jmagman I didn't reproduce yet, but according to Apple Doc, |
I'm concerned that this API is deprecated and we may need to instead fall back to the |
|
|
@jmagman Any feedback about this PR? it seems some Flutter users are waiting for Flutter team to fix crash. :) flutter/flutter#87809 |
|
@LongCatIsLooong can you take a look at this? I don't have much context, the comment below this "The application must have a key window since the keyboard client must be part of the responder chain to function" makes me think this isn't the right change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change makes sense to me, although I'm not sure how best to test this as the crash seems to be specific to iOS 15+.
Alternatively, is it possible to pass in and let the text input plugin hold a weak ref to a host UIView to replace the keyWindow usage? Does semantics depend on this specific setup? /cc @cbracken
If it's possible to add new input views as children of the current FlutterViewController instead of as children of the key window we will probably be able to remove the press* methods too, as the key events would be redirected to FlutterViewController.
|
@LongCatIsLooong Using host's |
|
@zhongwuzw thanks for looking into it! Adding the input views to the view controller makes more sense to me, and from looking at the git history I didn't find any indication that adding the input views to the key window would break things. |
|
@LongCatIsLooong I switched to host view. |
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a test. Please refer to the FlutterTextInputPluginTests.mm file for an example.
Also /cc @gaaclarke would you like to take a look?
shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm
Outdated
Show resolved
Hide resolved
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. The objc code looks good. It doesn't have complete test coverage and I'll leave it up to @LongCatIsLooong to make sure it's logically correct wrt the TextInputPlugin.
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for fixing this!
shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm
Show resolved
Hide resolved
|
@LongCatIsLooong I added the test. :) |
afec54e to
5448688
Compare
Fixes flutter/flutter#87809 some cases when
makeKeyAndVisiblenot be called,keyWindowofUIApplicationisnil, we can useAppDelegate'swindowas fallback.Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.