Skip to content

fix(handwriting): plugin fails after re-open, panel closes after first word, false download prompt - #854

Merged
LeanBitLab merged 3 commits into
mainfrom
fix/handwriting-reopen-and-autocaps
Nov 16, 2026
Merged

LeanBitLab merged 3 commits into
mainfrom
fix/handwriting-reopen-and-autocaps

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

Fixes #851

Problems

  1. Plugin dead after keyboard re-open ([Bug]: Plugins fail on every keyboard re-open: UnsatisfiedLinkError (duplicate ClassLoader) in HandwritingLoader #851). Closing the keyboard releases the recognizer; the next open built a new PluginClassLoader and tried to load libdigitalink.so again. ART allows only one ClassLoader per native library, so it failed with UnsatisfiedLinkError: ... already opened by ClassLoader until a forced restart.
  2. Panel switched to ABC after the first word. Committing the first word turns auto-caps off; KeyboardState.setShifted(UNSHIFT) reloaded the alphabet keyboard, which hid the handwriting panel.
  3. "Tap to download model" with the model installed. The plugin's isLanguageReady() waits about 1s for ML Kit's model manager and reports a timeout on cold start as "not downloaded".

Changes

  • HandwritingLoader: cache the PluginClassLoader per plugin APK (same approach as OcrPluginLoader), shared by getRecognizer() and importPlugin(); cleared on failed import and on removal.
  • KeyboardSwitcher.requestUpdatingShiftState(): skip while handwriting is showing. HandwritingView.exitToAlphabet() applies the current auto-caps state when leaving handwriting (ABC key, long-press clear).
  • HandwritingView: check imported models first, then retry the ML Kit readiness check up to 3 times before showing the download prompt.

Notes

  • The shift guard only applies while the handwriting panel is visible. Its bottom row has no letter or shift keys, so the normal-keyboard shift fixes (Multiple capitalized letters when typing too fast #598, Capital letters bug on beginning of typing in (new) app #743) are unaffected, and caps lock is already ignored by updateAlphabetShiftState.
  • The model-readiness retry is an app-side workaround; the proper fix is in the plugin (don't treat a timeout as "not downloaded").
  • CjkPluginLoader creates a new ClassLoader on every load after release(); not checked whether it hits the same native-library issue.

Testing

…851)

Closing the keyboard releases the recognizer, and the next open created a
new PluginClassLoader that tried to load libdigitalink.so again. ART only
allows one ClassLoader per native library, so it failed with
UnsatisfiedLinkError until a forced restart. Cache the loader per plugin
APK (as OcrPluginLoader does) and share it with importPlugin().
…word

Committing the first handwritten word turns auto-caps off, and the shift
update reloaded the alphabet keyboard, which hid the handwriting panel.
Skip shift updates while handwriting is showing and apply the current
auto-caps state when leaving handwriting.
The plugin's isLanguageReady() waits about 1s for ML Kit's model manager
and reports a timeout as "not downloaded", so an installed model showed
"Tap to download" right after the keyboard started. Check imported models
first and retry the ML Kit check before showing the download prompt.
@LeanBitLab
LeanBitLab merged commit d8384f8 into main Nov 16, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the fix/handwriting-reopen-and-autocaps branch November 16, 2026 17:33
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

Successfully merging this pull request may close these issues.

[Bug]: Plugins fail on every keyboard re-open: UnsatisfiedLinkError (duplicate ClassLoader) in HandwritingLoader

1 participant