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

Major rework of input logic, connection handling and state management #1822

Merged
merged 23 commits into from
May 2, 2022

Conversation

patrickgold
Copy link
Member

@patrickgold patrickgold commented Apr 28, 2022

This PR aims to improve the way internal key events are processed, how the text of the editor is cached and how the state of the input logic is managed. A lot of testing and re-evaluation has gone into this rework, and there's still some things to do to fix up bugs and other issues.

Major changes

Minimum API level raised from 23 to 24

(Android 6 --> Android 7)

This step was hard to decide because I had to carefully weigh in the effect of discontinuing support for devices running Android 6. I only have limited data (bug reports and GPlay) for device distribution, but going from that only a tiny tiny fraction of my user base is still on Android 6, so I decided that the benefits outweigh the drawbacks of raising the minimum API level by far.

Why was there even the need to consider this step?

Well simple answer: FlorisBoard now makes use (and will even more in the future) of the android.icu.text platform package, which exposes the system installed ICU module to the app via Java APIs. This allows me to easily analyze complex Unicode strings and find word and character boundaries, something which is really important for correct input behavior and for the upcoming word suggestions. While with most APIs there's a simple workaround by using if..else statements for lower API levels, for android.icu.text however there's sadly no easy way to substitute its feature set on devices prior to Android 7.

Editor caching

To improve input performance, FlorisBoard now caches the input for rich input connections locally (currently 256 characters around the cursor + any selected text) and predicts the new cache state for many user actions. If the selection update callback metadata matches with the prediction it means we do not have to re-fetch the editor text and thus save a lot of IPC-roundtrip time, which, depending on the app, can be massive.

Input event dispatcher changes

The input event dispatcher has been reworked to remove the async channel logic entirely. This logic was a common source of state bugs and other weird state mismatches and has been replaced by a concurrent model for managing active keys and their repeating/long press actions.

Other changes / fixes

Closes #374
Closes #524
Closes #637
Closes #828
Closes #1036
Closes #1037
Closes #1541
Closes #1617
Closes #1712
Closes #1733
Closes #1792

@tsiflimagas
Copy link
Collaborator

Wow, that lag in input seems to have been fixed! Even on debug builds, it works fast even right after installation or force close! That was a pretty major issue, and it feels great that it's now fixed.
Two things to mention about the PR, which you may already be aware of, are:

  • Glide typing should check whether it's the start of the line to not prepend a space.
  • When long pressing the shift key for caps lock, it doesn't get colored until you press another key.

@patrickgold
Copy link
Member Author

Thanks for testing it out! Great to hear that it works more smoothly now, that's one of the major goals of this rework.

Regarding the issues you mentioned:

The last pushed commits have fixed the glide phantom space behavior, on a new line there's now no additional space appended.

However the shift key logic in general is a bit buggy and needs some tweaking, I think though that I will fix this in beta02.

@patrickgold patrickgold merged commit b8133b1 into master May 2, 2022
@patrickgold patrickgold deleted the editor-instance-rework branch May 2, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment