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

Selection glitch in SuperTextField when IME is used #905

Closed
miguelcmedeiros opened this issue Jan 2, 2023 · 10 comments · Fixed by #910 or #919
Closed

Selection glitch in SuperTextField when IME is used #905

miguelcmedeiros opened this issue Jan 2, 2023 · 10 comments · Fixed by #910 or #919

Comments

@miguelcmedeiros
Copy link
Collaborator

miguelcmedeiros commented Jan 2, 2023

The selection in SuperTextField jumps between old and current selection as shown in this recording:

Screen.Recording.2023-01-02.at.13.07.27.mov

This is reproducible in demo app ("SuperTextField" -> "Interactive demo"). If TextInputSource.keyboard is used instead, then the issue is not reproducible.

@miguelcmedeiros
Copy link
Collaborator Author

Cc @angelosilvestre

@angelosilvestre
Copy link
Collaborator

@miguelcmedeiros Could you enable the imeTextFieldLog logger and attach the output? This doesn't seem to be happening on windows.

@miguelcmedeiros
Copy link
Collaborator Author

@angelosilvestre
The log looks likes this:

flutter: Initializing logger: ime
flutter: (58.962) textfield.ime > FINE: Is attached to input client? true
flutter: (58.976) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.977) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.978) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.979) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.979) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.979) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.980) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.980) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.980) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.989) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.989) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.989) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.992) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.992) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.992) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.994) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.994) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.994) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (58.997) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (58.997) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (58.997) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (59.001) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (59.001) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (59.001) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (59.015) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (59.015) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (59.015) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (59.016) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (59.016) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
flutter: (59.017) textfield.ime > FINE: Sending TextEditingValue to platform: TextEditingValue(text: ┤Super Editor is an open source text editor for Flutter projects.├, selection: TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: (59.018) textfield.ime > FINE: Received text editing deltas from platform...
flutter: (59.018) textfield.ime > FINE: Processing selection/composing change:
 - oldText:Super Editor is an open source text editor for Flutter projects.
 - selection:TextSelection.collapsed(offset: 23, affinity: TextAffinity.downstream, isDirectional: false)
 - composing:TextRange(start: -1, end: -1)
.
.
.

This is only a small portion of the log. It seems that super_editor is sending TextEditingValue delta to the platform, then receives the same delta and then sends it again in a infinite loop.

@miguelcmedeiros
Copy link
Collaborator Author

Cc @matthew-carroll

@angelosilvestre
Copy link
Collaborator

@miguelcmedeiros Could you also attach editorImeLog logs ?

@matthew-carroll
Copy link
Contributor

@miguelcmedeiros I'll investigate those logs tonight. Don't worry about it.

@matthew-carroll
Copy link
Contributor

I'm starting to investigate this.

One thing I'm noticing is that, on my end, placing the caret in SuperEditor doesn't seem to trigger the problem. Also, dragging across multiple characters, very slowly, doesn't seem to trigger the problem either.

What does trigger the problem is a rapid selection across characters. I'm wondering if the problem might be due to frame scheduling on our end. We run various things, like selection changes, in post-frame callbacks.

I'll continue digging.

@matthew-carroll
Copy link
Contributor

matthew-carroll commented Jan 8, 2023

Experimentally, I found that #876 seems to fix the SuperEditor selection problem. The SuperTextField selection problem still exists in that PR, because that PR only makes changes to SuperEditor IME behavior. I'll check on SuperTextField.

After taking inventory of #876 the following seem like possible candidates for why it fixed this problem:

matthew-carroll added a commit that referenced this issue Jan 8, 2023
@matthew-carroll
Copy link
Contributor

The root cause of the issue in SuperTextField seems to be that every time we received a value or delta from the IME, we would resend that value to the IME. Apparently the Mac IME automatically sends the value back to us whenever we send it to the IME. This created an infinite loop of IME communication.

@miguelcmedeiros
Copy link
Collaborator Author

miguelcmedeiros commented Jan 10, 2023

@matthew-carroll, when using the latest commit from stable (cd8f719), we still have this issue in Superlist.

In the demo app (SuperTextField demo), it also show the same issue if the implementation is changed to use SuperTextField instead of SuperDesktopTextField:

Screen.Recording.2023-01-10.at.11.47.16.mov

This infinite-caret-jumping now happens when the content changes.

angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
angelosilvestre added a commit to angelosilvestre/super_editor that referenced this issue Jan 12, 2023
raulmabe-labhouse pushed a commit to LabhouseMobile/super_editor that referenced this issue Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment