-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS Text Editing Infinite Loop #20160
iOS Text Editing Infinite Loop #20160
Conversation
ee5d2b0
to
630710e
Compare
630710e
to
a979911
Compare
4cbce78
to
44c766a
Compare
@@ -420,6 +420,7 @@ @implementation FlutterTextInputView { | |||
int _textInputClient; | |||
const char* _selectionAffinity; | |||
FlutterTextRange* _selectedTextRange; | |||
NSDictionary* _latestState; |
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.
We reuse FlutterTextInputView
so the cache needs to be erased every time the connection changes/resets. Also this needs to be properly deallocated I think.
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.
Alright got the deallocation in 9949623. For erasing the state each time the connection changes, would that just be in resetAllClientIds?
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.
FlutterTextInputView.setClientId
I think?
Is possible to fix this by holding off the framework -> engine |
@LongCatIsLooong Good thinking. I just tried playing around with that idea and it didn't seem to work, though (messing with the calls around here). The reason it doesn't work seems to be that the problem is more with the engine sending updates to the framework too fast. Here's an example:
Maybe this could be fixed in the framework with a similar sort of batching that is being done in the engine in this PR, or a more sophisticated queue that waits for ack responses from the engine? |
Fixes an infinite loop by eliminating an unnecessary engine/framework message.
Fixes an infinite loop by eliminating an unnecessary engine/framework message.
Description
Programmatically modifying text while it is being input causes an infinite loop on iOS, but not on Android.
For example, this is reproduced when setting an onChanged handler and adding a character to the text. See the linked issue for more details.
The reason why Android doesn't cause an infinite loop is that Android batches text changes that come very quickly. This PR solves the problem on iOS by
performing a similar batching by debouncing.eliminating the ACK response that the engine was sending back to the framework.Related Issues
Closes flutter/flutter#61282
Further work in this area:
#21534
flutter/flutter#66864
Tests
I added the following tests:
Breaking Change
Not a breaking change.