-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOSTextInputPlugin] bypass UIKit floating cursor coordinates clamping #26486
[iOSTextInputPlugin] bypass UIKit floating cursor coordinates clamping #26486
Conversation
ea93e35
to
3a10d3f
Compare
3a10d3f
to
39e8eaa
Compare
// This makes sure UITextSelectionView.interactionAssistant is not nil so | ||
// UITextSelectionView has access to this view (and its bounds). Otherwise | ||
// floating cursor breaks: https://github.com/flutter/flutter/issues/70267. | ||
if (@available(iOS 13.0, *)) { |
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.
I tested on an iOS 12 simulator and couldn't reproduce the issue.
@@ -79,7 +79,6 @@ - (void)setUp { | |||
} | |||
|
|||
- (void)tearDown { | |||
[engine stopMocking]; |
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 line caused all the tests in the file to fail. Did we upgrade ocmock or something?
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.
Nope we didn't. You shouldn't remove this line. The tests are running as part of CI so we know this works before the changes here. Let me know what errors you are getting and I can try to help.
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.
I put it back it starts failing again: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8845604182114825824/+/u/Host_Tests_for_ios_debug_sim/stdout
/opt/s/w/ir/cache/builder/src/out/ios_debug_sim/../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm:1211: error: -[FlutterTextInputPluginTest testPasswordAutofillHack] : failed: caught "NSInternalInconsistencyException", "** Cannot use mock object OCClassMockObject(FlutterEngine) at 0x600002eabb60. This error usually occurs when a mock object is used after stopMocking has been called on it. In most cases it is not necessary to call stopMocking. If you know you have to, please make sure that the mock object is not used afterwards."
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 means you are leaking an object beyond your test that is talking to the mock engine, probably a view controller. Let me look at your test code to see if I can spot it. (this can cause other tests to fail beyond yours)
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.
Looks like your test is fine. One of 2 things are happening:
- Your test is messing up the timing and surfacing an issue that was already present where we weren't correctly synchronizing some asynchronous operations (like NSNotifications)
- You've introduced a leak that is causing view controllers not to be deallocated, which causes them to leak into other tests and break them.
Here's an example where I had to fix similar issues:
27bf114#diff-9df3e6878a0f23383e1f2de991386935e435c5b77c863de75bd67a4ced38591dR136
I'd try running that test / writing one similar to make sure that the view controller is being deleted. If you run that one test and it fails, you'll know you introduced a leak. Otherwise tracking down the timing issue will take a bit more work.
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.
Turns out UIKit is keeping some of the input views alive and modifying the content of these views even they're removed from the view hierarchy. #26547
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.
Code looks good. We just have to fix your tests so you don't call stopMocking.
@gaaclarke Looks like you review comments were addressed. Another pass? |
@chinmaygarde I chose to address a problem in a different PR: #26547. It's currently being reviewed and I think we'll come back to this PR once that problem is fixed. |
459fd32
to
fa1e498
Compare
2e3485a
to
659e74a
Compare
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!
// not have access to its FlutterTextInputDelegate any more. | ||
- (void)decommision { | ||
- (void)decommission { |
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.
😁
Fixes flutter/flutter#70267.
The current implementation "works" only because UIKit doesn't properly handle "nil" somewhere: flutter/flutter#70267 (comment), and it breaks once the keyboard adds marked text to the input field.
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.