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

Characters reappearing sometimes when erasing (backspace) #2679

Closed
SingingFrog7 opened this issue Feb 1, 2021 · 22 comments
Closed

Characters reappearing sometimes when erasing (backspace) #2679

SingingFrog7 opened this issue Feb 1, 2021 · 22 comments
Milestone

Comments

@SingingFrog7
Copy link

Sometimes, when erasing text using the backspace button, some previously erased characters re-appears. I thought the bug might be fixed by now (as the release in the Play Store and F-Droid is a bit old) so I built it from source (master branch), but the problem is the same.

Steps to reproduce

  1. Type a long text
  2. Try to erase it by pressing backspace repetitively
  3. Some erased character sometimes re-appear after the cursor

Expected behaviour

Erasing a character should (obviously) erase it and it shouldn't reappear after the cursor

Actual behaviour

From time to time (I was not able to get a pattern), a previously erased character re-appear after the cursor

Android OS version:
Android 10

Device manufacturer and model:
One Plus 6T

List of installed add-ons (like languages, or themes):
French Language Pack

@menny
Copy link
Member

menny commented Feb 1, 2021

We, indeed, had many fixes around that area, but I assume not everything is fixed.
Can you attach a screencast of the issue? I'm unable to reproduce this.

@SingingFrog7
Copy link
Author

SingingFrog7 commented Feb 2, 2021

Hello,

I was able to finally get it to reproduce. It's very inconsistent. I was able to reproduce it twice in a minute by beeing in "incognito-mode". I don't know if it has any link with the issue as I'm pretty sure it happens in normal typing also

Let me know if I can do anything more to help!

screenrecording-ask.mp4

@menny
Copy link
Member

menny commented Feb 2, 2021

thanks.
Which app are you using there?

@SingingFrog7
Copy link
Author

In this screen recording, I am using Fennec (Firefox build on F-Droid) but it happened in multiple other apps also (Signal, Element, firefox, etc)

I just got it happen again on Signal in "normal" (non-icognito) mode so I don't know if there's any relation to the app/keyboard mode being used

@menny
Copy link
Member

menny commented Feb 2, 2021

Can you disable animations completely? In AnySoftKeyboard settings -> UI -> Keyboard Effect -> Animations. Set yo None.

@SingingFrog7
Copy link
Author

I just disabled it and was able to reproduce the issue.

I used to use the power-saving theme which had no animation and it also did the same.
I tried to get logs from logcat, but there's no output related to typing/erasing. Should I try a debug build?

@menny
Copy link
Member

menny commented Feb 2, 2021

yes, please try a build from the latest master. I added some logs there around that area.

Thank you!

@SingingFrog7
Copy link
Author

I will pull and rebuild my keyboard, for now that's what I had:

Normal erase

02-01 22:03:27.818 12603 12603 D ASK     : onFunctionKey -5
02-01 22:03:27.855 12603 12603 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:03:27.855 12603 12603 D ASK     : shift Setting UI active:false, locked: false
02-01 22:03:27.855 12603 12603 D ASK     : onUpdateSelection: oss=9, ose=9, nss=8, nse=8, cs=0, ce=9
02-01 22:03:27.855 12603 12603 V ASK     : onUpdateSelection: word 'Nsjsjejdd', position 8.
02-01 22:03:27.855 12603 12603 V ASK     : onUpdateSelection: Expected event. Discarding.

Erase when it add a character after:

02-01 22:03:27.426 12603 12603 D ASK     : onFunctionKey -5
02-01 22:03:27.426 12603 12603 D ASK     : handleDeleteLastCharacter will just sendDownUpKeyEvents. Delayed selection update?
02-01 22:03:27.442 12603 12603 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:03:27.442 12603 12603 D ASK     : shift Setting UI active:false, locked: false
02-01 22:03:27.443 12603 12603 D ASK     : onUpdateSelection: oss=11, ose=11, nss=11, nse=11, cs=0, ce=11
02-01 22:03:27.443 12603 12603 V ASK     : onUpdateSelection: word 'Nsjsjejdhhd', position 11.
02-01 22:03:27.443 12603 12603 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 22:03:27.459 12603 12603 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:03:27.459 12603 12603 D ASK     : shift Setting UI active:false, locked: false
02-01 22:03:27.459 12603 12603 D ASK     : onUpdateSelection: oss=11, ose=11, nss=10, nse=10, cs=0, ce=10
02-01 22:03:27.459 12603 12603 V ASK     : onUpdateSelection: word 'Nsjsjejdhhd', position 11.
02-01 22:03:27.459 12603 12603 D ASK     : onUpdateSelection: ok, let's see what can be done
02-01 22:03:27.459 12603 12603 D ASK     : onUpdateSelection: inside the currently typed word to location 10.

I will rebuild and get the logs and will let you know

@SingingFrog7
Copy link
Author

The log I got from the new build is similar, but I found out that it seems to always happen with the last character of a word.

I typed "abcdefghijklmnop " a few times and it always happen with the "p"

log from my "debug" build pulled from master 5 minutes ago:


02-01 22:14:44.624 21696 21696 D ASK     : onFunctionKey -5
02-01 22:14:44.648 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:14:44.648 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 22:14:44.648 21696 21696 D ASK     : onUpdateSelection: oss=136, ose=136, nss=135, nse=135, cs=-1, ce=-1
02-01 22:14:44.648 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 22:14:44.648 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 22:14:44.799 21696 21696 D ASK     : Starting new prediction on word 'abcdefghijklmnop'.
02-01 22:14:44.802 21696 21696 D ASK     : onFunctionKey -5
02-01 22:14:44.802 21696 21696 D ASK     : handleDeleteLastCharacter will just sendDownUpKeyEvents. Delayed selection update?
02-01 22:14:44.822 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:14:44.822 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 22:14:44.822 21696 21696 D ASK     : onUpdateSelection: oss=135, ose=135, nss=135, nse=135, cs=119, ce=135
02-01 22:14:44.822 21696 21696 V ASK     : onUpdateSelection: word 'abcdefghijklmnop', position 16.
02-01 22:14:44.822 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 22:14:44.839 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:14:44.839 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 22:14:44.839 21696 21696 D ASK     : onUpdateSelection: oss=135, ose=135, nss=134, nse=134, cs=119, ce=134
02-01 22:14:44.839 21696 21696 V ASK     : onUpdateSelection: word 'abcdefghijklmnop', position 16.
02-01 22:14:44.839 21696 21696 D ASK     : onUpdateSelection: ok, let's see what can be done
02-01 22:14:44.839 21696 21696 D ASK     : onUpdateSelection: inside the currently typed word to location 15.
02-01 22:14:45.012 21696 21696 D ASK     : onFunctionKey -5
02-01 22:14:45.025 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 22:14:45.025 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 22:14:45.026 21696 21696 D ASK     : onUpdateSelection: oss=134, ose=134, nss=133, nse=133, cs=119, ce=134
02-01 22:14:45.026 21696 21696 V ASK     : onUpdateSelection: word 'abcdefghijklmnp', position 14.
02-01 22:14:45.026 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.

I'll try to dig in the code from my side, but I didn't work on an Android app for a long time. If I can do anything else to help you, let me know!

@menny
Copy link
Member

menny commented Feb 2, 2021

This helps a lot. I'll try to retrace what went wrong.
If you can help out, too, that would be great.

Two things that look wrong:

  1. handleDeleteLastCharacter will just sendDownUpKeyEvents. Delayed selection update? <- I don't think that should ever happen on a fast device.
  2. onUpdateSelection: inside the currently typed word to location 15. <- we're not supposed to be inside typed word, only at the end.

@SingingFrog7
Copy link
Author

SingingFrog7 commented Feb 2, 2021

Here's my observations so far:

  • It has to be related to the prediction/correction part of the code as it seems to stop if I disable suggestions.
  • It seems to happen only if I erase characters at a certain speed (it didn't happen if I hold the erase button, nor did it happen when I'm doing it slowly to see what happens
  • I had the same issue on my Samsung S8+ before, so I don't think it's related to my device itself
  • It happens more often on the last character of a word, but not exclusively. It also probably depends on the word itself, as it depends on prediction
  • This happen when the following "backspace" key is registered before the prediction code is done
  • It happens way more with a debug build than a release one (probably because of the debug logs taking more time)

I redid a test and tried to record+logcat it to watch it slowly.
What I did:

  • I typed "abcd abcd abcd abcd ", erased the first word slowly and then went faster

When that happens:

  • The first word was erased correctly
  • The second word erased correctly also
  • The "backspace" event is registered BEFORE the prediction actually starts for "abcd"
  • The last character of the third word is erased ( abcd| -> abc| ), but there's a longer delay between the keypress and the actual action
    Note also that onUpdateSelection: word 'abcd' is shown when it SHOULD be onUpdateSelection: word 'abc', so the letter d is still in the buffer, but erased from the GUI. The cursor is moved at position 3
  • When the "second last" character (c) is erased, the previous last character reappear after the cursor is moved ( abc| -> ab|d )

The "OnUpdateSelection" parameters seems fine, but the mWord.getTypedWord() and mWord.cursorPosition() looks off (didn't erase the last character because of the following backspace being registered?)

I will dig more, but here's my logs and the slowmotion video:

When prediction start correctly:

02-01 23:12:32.302 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.317 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.317 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.318 21696 21696 D ASK     : onUpdateSelection: oss=83, ose=83, nss=82, nse=82, cs=-1, ce=-1
02-01 23:12:32.318 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:32.318 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.469 21696 21696 D ASK     : Starting new prediction on word 'abcd'.
02-01 23:12:32.480 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.480 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.480 21696 21696 D ASK     : onUpdateSelection: oss=82, ose=82, nss=82, nse=82, cs=78, ce=82
02-01 23:12:32.480 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.
02-01 23:12:32.480 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.481 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.500 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.501 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.501 21696 21696 D ASK     : onUpdateSelection: oss=82, ose=82, nss=81, nse=81, cs=78, ce=81
02-01 23:12:32.501 21696 21696 V ASK     : onUpdateSelection: word 'abc', position 3.
02-01 23:12:32.501 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: editDistance: abc, ABC
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 0:0,1,2,3,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 1:1,0,1,2,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 2:2,1,0,1,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 3:3,2,1,0,

When it doesn't:

02-01 23:12:33.308 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.333 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.333 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.333 21696 21696 D ASK     : onUpdateSelection: oss=77, ose=77, nss=76, nse=76, cs=-1, ce=-1
02-01 23:12:33.333 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:33.333 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.476 21696 21696 D ASK     : Starting new prediction on word 'abcd'.
02-01 23:12:33.479 21696 21696 D ASK     : onFunctionKey -5    <- **********  HAPPENS BEFORE "onUpdateSelection: word 'abcd', position 4."
02-01 23:12:33.479 21696 21696 D ASK     : handleDeleteLastCharacter will just sendDownUpKeyEvents. Delayed selection update?
02-01 23:12:33.498 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.499 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.499 21696 21696 D ASK     : onUpdateSelection: oss=76, ose=76, nss=76, nse=76, cs=72, ce=76
02-01 23:12:33.499 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.
02-01 23:12:33.499 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding. <- ******* THE CODE SEEMS TO BE DONE WITH THE PREDICTION THERE, THEN TRY TO MANAGER THE KEY IT JUST REGISTERED
02-01 23:12:33.516 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.516 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.516 21696 21696 D ASK     : onUpdateSelection: oss=76, ose=76, nss=75, nse=75, cs=72, ce=75 <-   **** THIS SEEMS CORRECT...
02-01 23:12:33.516 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.  <-  ****** SHOULD BE onUpdateSelection: word 'abc', position 3
02-01 23:12:33.516 21696 21696 D ASK     : onUpdateSelection: ok, let's see what can be done
02-01 23:12:33.517 21696 21696 D ASK     : onUpdateSelection: inside the currently typed word to location 3.

Video:

untitled.mp4

Full log (Including the previous word, for comparison)

02-01 23:12:32.302 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.317 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.317 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.318 21696 21696 D ASK     : onUpdateSelection: oss=83, ose=83, nss=82, nse=82, cs=-1, ce=-1
02-01 23:12:32.318 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:32.318 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.469 21696 21696 D ASK     : Starting new prediction on word 'abcd'.
02-01 23:12:32.480 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.480 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.480 21696 21696 D ASK     : onUpdateSelection: oss=82, ose=82, nss=82, nse=82, cs=78, ce=82
02-01 23:12:32.480 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.
02-01 23:12:32.480 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.481 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.500 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.501 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.501 21696 21696 D ASK     : onUpdateSelection: oss=82, ose=82, nss=81, nse=81, cs=78, ce=81
02-01 23:12:32.501 21696 21696 V ASK     : onUpdateSelection: word 'abc', position 3.
02-01 23:12:32.501 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: editDistance: abc, ABC
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 0:0,1,2,3,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 1:1,0,1,2,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 2:2,1,0,1,
02-01 23:12:32.578 21696 21696 D ASKIMEUtils: 3:3,2,1,0,
02-01 23:12:32.631 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.650 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.650 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.651 21696 21696 D ASK     : onUpdateSelection: oss=81, ose=81, nss=80, nse=80, cs=78, ce=80
02-01 23:12:32.651 21696 21696 V ASK     : onUpdateSelection: word 'ab', position 2.
02-01 23:12:32.651 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.799 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:32.815 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:32.815 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:32.816 21696 21696 D ASK     : onUpdateSelection: oss=80, ose=80, nss=79, nse=79, cs=78, ce=79
02-01 23:12:32.816 21696 21696 V ASK     : onUpdateSelection: word 'a', position 1.
02-01 23:12:32.816 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:32.995 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.015 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.015 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.015 21696 21696 D ASK     : onUpdateSelection: oss=79, ose=79, nss=78, nse=78, cs=-1, ce=-1
02-01 23:12:33.016 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:33.016 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.156 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.167 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.167 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.167 21696 21696 D ASK     : onUpdateSelection: oss=78, ose=78, nss=77, nse=77, cs=-1, ce=-1
02-01 23:12:33.168 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:33.168 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.308 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.333 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.333 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.333 21696 21696 D ASK     : onUpdateSelection: oss=77, ose=77, nss=76, nse=76, cs=-1, ce=-1
02-01 23:12:33.333 21696 21696 V ASK     : onUpdateSelection: word '', position 0.
02-01 23:12:33.333 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.476 21696 21696 D ASK     : Starting new prediction on word 'abcd'.
02-01 23:12:33.479 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.479 21696 21696 D ASK     : handleDeleteLastCharacter will just sendDownUpKeyEvents. Delayed selection update?
02-01 23:12:33.498 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.499 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.499 21696 21696 D ASK     : onUpdateSelection: oss=76, ose=76, nss=76, nse=76, cs=72, ce=76
02-01 23:12:33.499 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.
02-01 23:12:33.499 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.516 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.516 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.516 21696 21696 D ASK     : onUpdateSelection: oss=76, ose=76, nss=75, nse=75, cs=72, ce=75
02-01 23:12:33.516 21696 21696 V ASK     : onUpdateSelection: word 'abcd', position 4.
02-01 23:12:33.516 21696 21696 D ASK     : onUpdateSelection: ok, let's see what can be done
02-01 23:12:33.517 21696 21696 D ASK     : onUpdateSelection: inside the currently typed word to location 3.
02-01 23:12:33.647 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.665 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.665 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.665 21696 21696 D ASK     : onUpdateSelection: oss=75, ose=75, nss=74, nse=74, cs=72, ce=75
02-01 23:12:33.665 21696 21696 V ASK     : onUpdateSelection: word 'abd', position 2.
02-01 23:12:33.665 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.814 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.831 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.831 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.831 21696 21696 D ASK     : onUpdateSelection: oss=74, ose=74, nss=73, nse=73, cs=72, ce=74
02-01 23:12:33.831 21696 21696 V ASK     : onUpdateSelection: word 'ad', position 1.
02-01 23:12:33.831 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:33.986 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:33.997 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:33.997 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:33.997 21696 21696 D ASK     : onUpdateSelection: oss=73, ose=73, nss=72, nse=72, cs=72, ce=73
02-01 23:12:33.997 21696 21696 V ASK     : onUpdateSelection: word 'd', position 0.
02-01 23:12:33.997 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.
02-01 23:12:34.182 21696 21696 D ASK     : onFunctionKey -5
02-01 23:12:34.198 21696 21696 D ASK     : shift updateShiftStateNow inputSaysCaps=false
02-01 23:12:34.198 21696 21696 D ASK     : shift Setting UI active:false, locked: false
02-01 23:12:34.198 21696 21696 D ASK     : onUpdateSelection: oss=72, ose=72, nss=71, nse=71, cs=71, ce=72
02-01 23:12:34.198 21696 21696 V ASK     : onUpdateSelection: word 'd', position 0.
02-01 23:12:34.198 21696 21696 V ASK     : onUpdateSelection: Expected event. Discarding.


@SingingFrog7
Copy link
Author

SingingFrog7 commented Feb 2, 2021

I think there's a missing step in the code that handles the "cursorMovedUnexpectedly", because in my case, the cursor moved due to a character being erased

mWord.setCursorPosition(newSelEnd - candidatesStart);

The cursor is moved to the correct position, but mWord isn't updated.
If I replace mWord.setCursorPosition(newSelEnd - candidatesStart); with the following code, it works correctly. (The slight delay due to the key being registered while finishing the step is still there, but the characters are correctly updated):

if ((newSelEnd == oldSelEnd-1)&&(newSelStart == oldSelStart-1)&&(candidatesEnd == newSelEnd)){
    // The cursor is at the end of the word and the selection is one character before the previous one, assume we deleted the last character
    mWord.deleteCodePointAtCurrentPosition();
}
else {
    mWord.setCursorPosition(newSelEnd - candidatesStart);
}

We obviously need to make sure we were removing the character before removing it from mWord, as cursorMovedUnexpectedly can happen for other reasons. I couldn't find a way to check that the last key registered was -5. I'm not used to the Android Framework so you might be able to add that easily!

I'm not sure if my checks makes sens in all cases, so I'll let you manage that.

I hope I provided enough info for you to be able to fix the issue correctly! Let me know if I can help more!

Thanks a lot for your nice work by the way

@menny
Copy link
Member

menny commented Feb 2, 2021

Will your code change delete the last character if you simply hit the left arrow?

@menny
Copy link
Member

menny commented Feb 2, 2021

This is a crazy good analysis! Thank you.

@SingingFrog7
Copy link
Author

SingingFrog7 commented Feb 2, 2021

I am using that fix since then and it didn't happen so far. I guess it could delete a character in other situations (that's why I was willing to check the last typed key) but it would need to trigger a cursorMovedUnexpectedly, have the cursor at the end of a word AND have moved left to happen.

Appart from registering a key while still doing some stuff, I don't know if cursorMovedUnexpectly gets triggered a lot. To be quick enought to trigger it, I have to type the same key quite quickly (having a debug build help to trigger it because of logging) so I don't think it would trigger the delete in other situations, but I don't have a huge understanding of the whole thing.

I guess it doesn't necessarily fix all situations either as you may be deleting from the middle of a word which wouldn't meet candidatesEnd == newSelEnd

I don't know how to handle that in a better way, sadly :(

@menny menny added this to the 1.10-r4 milestone Feb 11, 2021
menny added a commit to menny/AnySoftKeyboard that referenced this issue Feb 11, 2021
@menny
Copy link
Member

menny commented Feb 11, 2021

Could you try the fix at #2696

menny added a commit to menny/AnySoftKeyboard that referenced this issue Feb 11, 2021
@SingingFrog7
Copy link
Author

It works for me so far, I wasn't able to reproduce the bug. I'll use that build for a few days and will update you if there's anything!

Thanks for your time

@menny
Copy link
Member

menny commented Feb 11, 2021

That's good to hear. Please report if you encounter anything new, too

@menny
Copy link
Member

menny commented Feb 12, 2021

Merged the fix to master. Thank you for your thorough analysis

@menny menny closed this as completed Feb 12, 2021
@SingingFrog7
Copy link
Author

Looks like it introduce another bug. If you move your cursor by clicking somewhere else and then start erasing, it doesn't always move the cursor posituon and sometimes erase from where you were before the cursor was moved

I'll try to analysis the logcat debug log tonight as I did with the previous bug to give you as much info as possible.

Should I open a seperate bug?

@menny
Copy link
Member

menny commented Feb 16, 2021

I can ignore that last comment, right? As per that other issue you opened and closed.

@SingingFrog7
Copy link
Author

Yes, sorry for the misunderstanding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants