bug(android): missing handling for keystrokes dropped due to missing IME->app connection
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
Sentry Issue: [KEYMAN-ANDROID-4KA](https://keyman.sentry.io/issues/4768137606/?referrer=github_integration)
```
insertText failed: InputConnection is null
```
```
at com.keyman.engine.KMKeyboardJSHandler$1.run(KMKeyboardJSHandler.java:118)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
```
Corresponds to the following block:
https://github.com/keymanapp/keyman/blob/b068f94537e6bf8703068143473aec7d30ff584c/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboardJSHandler.java#L116-L120
This is early on during the process of applying an incoming keystroke. The internal Web engine has already processed it and is actively attempting to synchronize the host-app's context. However, the `inputConnection` necessary for this... is `null`. (We currently aren't given an indication as to why.)
Naturally, this will result in a temporary context desync due to the dropped keystroke. Perhaps we could 'store' the keystroke and attempt to apply it again on receiving new input? Or... does this occur during scenarios where the keyboard should no longer be producing output due to being disconnected after the triggering events were received? In the latter case, dropping them does seem reasonable. Sadly... we currently don't know which of the two cases this error is arising from - and that's assuming that it only comes from one or the other.
As an extra note, if we do allow the keystrokes to be dropped in certain scenarios... we probably need to run `resetContext()` when we make that decision. That will re-synchronize the hosted Web engine's version of the context with what the app has, after all.
Contributor guide
Assessment
This issue has not been assessed yet.