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

bug(linux): Backspacing and reordering is not working well in Firefox, Terminal #1489

Closed
mcdurdin opened this issue Jan 4, 2019 · 20 comments · Fixed by #7079
Closed

bug(linux): Backspacing and reordering is not working well in Firefox, Terminal #1489

mcdurdin opened this issue Jan 4, 2019 · 20 comments · Fixed by #7079
Labels
bug compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output linux/
Milestone

Comments

@mcdurdin
Copy link
Member

mcdurdin commented Jan 4, 2019

Keyman does not appear to be working correctly in Firefox, Terminal: reordering, e.g. with Khmer Angkor, xEjmr is not​ producing ខ្មែរ (normally typed xjmEr).

@mcdurdin mcdurdin added bug compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output linux/ labels Jan 4, 2019
@mcdurdin mcdurdin added this to the 11.0 milestone Jan 4, 2019
@glasseyes
Copy link
Contributor

glasseyes commented Jan 4, 2019

I can't replicate the problem in Firefox. What are you doing in Firefox that exhibits the problem

I've confirmed looking at it that the same underlying text going to Terminal and text editor (gedit/pluma). The text editor uses pango and reorders and shapes.
The terminal appears to display each individual unicode character separately. The same lack of reordering occurs if you copy the text from somewhere else and paste it into the terminal. So this looks like a limitation in any virtual terminal. I've confirmed that the same thing happens in git bash on windows.

@mcdurdin
Copy link
Member Author

mcdurdin commented Jan 4, 2019

For the khmer_angkor keyboard, I'll give baseline results with gedit, then Terminal and Firefox. It's important to understand that when I type xEjm, the khmer_angkor keyboard reorders the output at the time the m key is pressed, to give the equivalent of xjmE. The r is extraneous (but forms part of the complete word)...

  • Ubuntu 18.04
  • Firefox 63.0.3 64-bit

Baseline, gedit.

This is what is expected (and what I consistently see in gedit).

Correct order key Correct order result vs Alternate keying order Alternate order result
x U+1781 x U+1781
xj U+1781 U+17D2 xE U+1781 U+17C2
xjm U+1781 U+17D2 U+1798 xEj U+1781 U+17C2 U+17D2
xjmE U+1781 U+17D2 U+1798 U+17C2 xEjm U+1781 U+17D2 U+1798 U+17C2
xjmEr U+1781 U+17D2 U+1798 U+17C2 U+179A xEjmr U+1781 U+17D2 U+1798 U+17C2 U+179A

Terminal

Correct order key Correct order result vs Alternate keying order Alternate order result
x U+1781 x U+1781
xj U+1781 U+17D2 xE U+1781 U+17C2
xjm U+1781 U+17D2 U+1798 xEj U+1781 U+17C2 U+17D2
xjmE U+1781 U+17D2 U+1798 U+17C2 xEjm U+17D2 U+1798 U+17C2 *
xjmEr U+1781 U+17D2 U+1798 U+17C2 U+179A xEjmr U+17D2 U+1798 U+17C2 U+179A *

Firefox

On Firefox, the replacement sometimes works -- this looks like a race condition on backspacing. I can observe failure on my VM 4 times out of 5.

Correct order key Correct order result vs Alternate keying order Alternate order result
x U+1781 x U+1781
xj U+1781 U+17D2 xE U+1781 U+17C2
xjm U+1781 U+17D2 U+1798 xEj U+1781 U+17C2 U+17D2
xjmE U+1781 U+17D2 U+1798 U+17C2 xEjm U+1781 U+17C2 U+17D2 U+17D2 *
xjmEr U+1781 U+17D2 U+1798 U+17C2 U+179A xEjmr U+1781 U+17C2 U+17D2 U+17D2 U+179A *

* These are incorrect results

@glasseyes
Copy link
Contributor

For the khmer_angkor keyboard, I'll give baseline results with gedit, then Terminal and Firefox. It's important to understand that when I type xEjm, the khmer_angkor keyboard reorders the output at the time the m key is pressed, to give the equivalent of xjmE. The r is extraneous (but forms part of the complete word)...

* Ubuntu 18.04

* Firefox 63.0.3 64-bit

Baseline, gedit.

This is what is expected (and what I consistently see in gedit).
Correct order key Correct order result vs Alternate keying order Alternate order result
x U+1781 x U+1781
xj U+1781 U+17D2 xE U+1781 U+17C2
xjm U+1781 U+17D2 U+1798 xEj U+1781 U+17C2 U+17D2
xjmE U+1781 U+17D2 U+1798 U+17C2 xEjm U+1781 U+17D2 U+1798 U+17C2
xjmEr U+1781 U+17D2 U+1798 U+17C2 U+179A xEjmr U+1781 U+17D2 U+1798 U+17C2 U+179A

Terminal

Correct order key Correct order result vs Alternate keying order Alternate order result
x U+1781 x U+1781
xj U+1781 U+17D2 xE U+1781 U+17C2
xjm U+1781 U+17D2 U+1798 xEj U+1781 U+17C2 U+17D2
xjmE U+1781 U+17D2 U+1798 U+17C2 xEjm U+17D2 U+1798 U+17C2 *
xjmEr U+1781 U+17D2 U+1798 U+17C2 U+179A xEjmr U+17D2 U+1798 U+17C2 U+179A *

  • These are incorrect results

Thanks for the fuller explanation.
The issue in Terminal is how it handles the coeng and backspace.
'm' generates U+1798 U+17D2 U+1798 U+17C2
The first deletes the U+1798
The second doesn't just delete the expected U+17D2 but deletes U+17C2 as well
Then the third back deletes U+1781 erroneously

Can you try a virtual terminal emulator on windows and see if that is general cross-platform virtual terminal behaviour and not just a problem on linux?

@glasseyes
Copy link
Contributor

For Firefox and other apps such as Chrome/Chromium where ibus can't get the surrounding context:

I can confirm that it is a race condition on backspaces. I can't find a way to do a backspace in series with the text commit so there are no guarantees about when they'll happen

I don't like it at all but I can't find a way to speed up the backspace and the only way I've found to slow down the text commit enough to reliably[1] enter that text is to sleep for a realisticish keypress of 1/100s after each forward_backspace press and send a backspace key release after that.

[1] saying that, there is another race problem if you start typing too soon after starting ibus or switching to a keyman keyboard, at least on a slower computer

@mcdurdin
Copy link
Member Author

mcdurdin commented Jan 6, 2019

  1. Does the same race condition problem arise with (original) KMFL? I am assuming it does?
  2. I don't think timing- or delay-based solutions are going to be robust. They will fail on loaded systems, and they also cause trouble for rapid input.
  3. Therefore, I suspect the solution for the race will be similar to the one we engineered for Windows (https://blog.keyman.com/2018/10/the-keyman-keyboard-input-pipeline/).
  4. I am not so worried about the race condition on switching input methods at this time. That's something we can live with.

@mcdurdin
Copy link
Member Author

mcdurdin commented Jan 6, 2019

Can you try a virtual terminal emulator on windows and see if that is general cross-platform virtual terminal behaviour and not just a problem on linux?

Yes, this problem arises with Mintty on Windows (BKSP on U+1798 U+17D2 deletes both).

@glasseyes
Copy link
Contributor

Can you try a virtual terminal emulator on windows and see if that is general cross-platform virtual terminal behaviour and not just a problem on linux?

Yes, this problem arises with Mintty on Windows (BKSP on U+1798 U+17D2 deletes both).

Good, as expected then so we can't do anything more about terminals.

@glasseyes
Copy link
Contributor

1. Does the same race condition problem arise with (original) KMFL? I am assuming it does?

I haven't replicated it but the code path to forward the backspace is the same so I would expect it to.

2. I don't think timing- or delay-based solutions are going to be robust. They will fail on loaded systems, and they also cause trouble for rapid input.

I agree.

3. Therefore, I suspect the solution for the race will be similar to the one we engineered for Windows (https://blog.keyman.com/2018/10/the-keyman-keyboard-input-pipeline/).

Unfortunately I can't see a way to do something similar here. SendInput can send unicode in the generated key event but all I can do is send a virtual keycode, either forwarded back to ibus-keyman or generate a new one via the accessibility system.
ibus-keyman has no access to the Application window so it cannot send text itself, but tells ibus to send it.

4. I am not so worried about the race condition on switching input methods at this time. That's something we can live with.

OK

@mcdurdin
Copy link
Member Author

After discussion, we will postpone this to v12 given it will require significant architectural design and perhaps upstream changes to ibus. This is not ideal but the same problems are present in KMFL and other ibus-based systems so it is a known limitation.

@mcdurdin mcdurdin modified the milestones: 11.0, Future Jan 14, 2019
@nikita-moor
Copy link

nikita-moor commented Feb 7, 2019

A similar problem with Anki (Qt-based) and EuroLatin (SIL):

  1. Start Anki
  2. Press Add to add a new flashcard
  3. Type xxxx in any field
  4. Put the cursor in the middle of the string (xx|xx)
  5. Start typing -a for "ā"

The result is xx-xā rather then expected xxāxx. Both engines, ibus-kmfl and ibus-keyman, produce this error. However, direct typing as xx-axx is correct (xxāxx).

P.S. Notepadqq is Qt-based but has no this problem.

@darcywong00 darcywong00 changed the title [Linux] Backspacing and reordering is not working well in Firefox, Terminal [linux] Backspacing and reordering is not working well in Firefox, Terminal Feb 18, 2019
@mcdurdin mcdurdin modified the milestones: Future, B14S2 Nov 16, 2020
@mcdurdin mcdurdin modified the milestones: B14S2, B14S3 Dec 27, 2020
@mcdurdin mcdurdin modified the milestones: B14S3, B14S4 Jan 12, 2021
@mcdurdin mcdurdin modified the milestones: B14S4, B14S5 Jan 22, 2021
@darcywong00 darcywong00 modified the milestones: B14S5, B14S6 Feb 8, 2021
@ermshiperete
Copy link
Contributor

See also the Firefox part in #4429.

@ermshiperete ermshiperete removed their assignment Mar 5, 2021
@ermshiperete ermshiperete changed the title [linux] Backspacing and reordering is not working well in Firefox, Terminal bug(linux): Backspacing and reordering is not working well in Firefox, Terminal Mar 5, 2021
@ermshiperete
Copy link
Contributor

I was able to reproduce this problem pretty consistently in a Bionic VM. A good site to test in Firefox might be https://www.editpad.org/.

ermshiperete added a commit that referenced this issue Dec 14, 2021
ermshiperete added a commit that referenced this issue Dec 16, 2021
This change requires a change in ibus as a prerequisite.

Fixes #1489.
ermshiperete added a commit that referenced this issue Dec 16, 2021
This change requires a change in ibus as a prerequisite.

Fixes #1489.
@darcywong00 darcywong00 modified the milestones: Future, 17.0 Feb 24, 2022
@darcywong00
Copy link
Contributor

Also likely relates to serializing input for #4029, #4030, #5154

ermshiperete added a commit that referenced this issue Aug 15, 2022
This change requires a change in ibus as a prerequisite.

Fixes #1489.
ermshiperete added a commit that referenced this issue Aug 17, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit that referenced this issue Aug 17, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit that referenced this issue Aug 29, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit that referenced this issue Aug 29, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit that referenced this issue Sep 2, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit to ermshiperete/keyman that referenced this issue Oct 4, 2022
This change requires a change in ibus as a prerequisite.

Fixes keymanapp#1489.
ermshiperete added a commit that referenced this issue Oct 6, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
ermshiperete added a commit that referenced this issue Oct 11, 2022
This change implements a commit queue which allows to control the
order of the output. This ensures that any backspace we generate
will be processed before the character we're adding.

Requires changes in ibus (surrounding text fix (see #7072) and
prefilter change)

Fixes #1489, #4028, #4029, #4030, #4505, #5510, #6639
@mcdurdin mcdurdin modified the milestones: 17.0, A16S12 Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output linux/
5 participants