change(android): use webview asset loader 🍒 🏠 - #16628
Merged
mcdurdin merged 14 commits intoSep 22, 2026
Merged
Conversation
This change moves to using `WebViewAssetLoader` for loading files from the device instead of using file:// URLs. This fixes the blank keyboard problem reported in #16096 for Android. Also make `KMKeyboard.getKeyboardRoot()` private, and rename public `Keyboard.getKeyboardPath()` to private `Keyboard.getKeyboardUrl()`. Part-of: #16096
Co-authored-by: Marc Durdin <marc@durdin.net>
Also fix `assertEquals` in that test file - the parameter ordering is `expected, actual` but we had it the other way round which gives a confusing message if the test fails.
On Windows the tests failed because the AppData directory doesn't yet exist under an allowed app internal storage path. This change creates the directory first when running tests.
Fixes: FV-ANDROID-20E Build-bot: release:android
The default fonts (DejaVueSans.ttf and keymanweb-osk.ttf) are located in the root directory, not the package directory. This fixes the KeyboardHarness test app. Also some improvements with variable and function names to better match what they do.
Cherry-pick-of: #16146 We use SIL EuroLatin as fallback keyboard. If that is not installed, previously we output an error which showed up as a toast for the user. This change now outputs a warning instead of the error for the default keyboard. Also changed the KeyboardHarness test app to set a different keyoard as default.
User Test ResultsTest specification and instructions Test Artifacts |
Fixes: #16183 Test-bot: skip
PR #16146 introduced a problem with selecting a different font as display font so that we always ended up with not setting the font. This was caused by the font filenames now being a URL (which is necessary because they get processed by the web engine). However, the Android code checks for the existence of the font in order to create the typeface, which only works for local paths. This PR modifies and simplifies `KMKeyboard.getFontFilename` to return the full path, renames `KMKeyboard.txtFont` and `KMKeyboard.oskFont` to make it clearer that they contain a path and not a URL. Also initialize `KMKeyboard.oskFontPath` with empty string instead of `null`. This makes it consistent with` txtFontPath` and with the documented behavior of `KMManager.getKeyboardOskFontFilename()` (which returns `KMKeyboard.oskFontPath`). Follows: #16146 Fixes: #16187 Build-bot: release:android
Co-authored-by: Marc Durdin <marc@durdin.net> Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
This addresses a code review comment.
Co-authored-by: Marc Durdin <marc@durdin.net>
Member
Test Results
|
Contributor
Test Specs
Test Results
|
mcdurdin
approved these changes
Sep 22, 2026
mcdurdin
deleted the
change/android/cherrypick/use-webview-asset-loader
branch
September 22, 2026 07:42
Collaborator
|
Changes in this pull request will be available for download in Keyman version 18.0.252 |
This was referenced Sep 22, 2026
Member
|
One event received in 18.0.252 last night, which appears unrelated but was bundled under the same issue in Sentry: Unclear if the error is arising from nrc.en.mtnt or from another model they have installed on their device (the error message could list the model name!) |
pull Bot
pushed a commit
to soitun/keyman
that referenced
this pull request
Sep 24, 2026
Some error messages do not include the URL, so it can be hard to disambiguate them. Will not back-port to 18.0, because the errors are currently rare. See-also: keymanapp#16628 Test-bot: skip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick-of: #16146
Cherry-pick-of: #16188
Cherry-pick-of: #16184
Relates-to: #13862
Follows: #16604
Fixes: KEYMAN-WEB-RB
Fixes: KEYMAN-WEB-Z8
Fixes: KEYMAN-WEB-MD
Fixes: KEYMAN-WEB-YV
Fixes: KEYMAN-WEB-YW
Fixes: KEYMAN-WEB-YX
Use
WebViewAssetLoaderin order to stop usingfile://URLs for loading all assets in the keyboardWebView. In this case, for lexical models, as an attempt to resolve (sample) error:Error occurred when attempting to load dictionary NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'file:///data/user/0/com.tavultesoft.kmapro/app_data/models/nrc.en.mtnt/nrc.en.mtnt.model.js' failed to load.While we originally made the change to using
WebViewAssetLoaderin order to support use of thewindow.fetch()API for keyboard loading in version 19, we hope that the same solution will address the crash report when loading of predictive-text models on Android in Chrome 152.0 and later versions. This error was sporadically happening with earlier versions of Chrome (20 per month or so) but is frequent now -- we've been getting nearly 10,000 error reports daily.Per MDN reference,
NetworkErroris received when an incorrect MIME type is used. While this error does not seem to be happening on our test devices or any device we have access to, we theorize that there could be some environmental cause for file:/// based URLs (for lexical models) being labelled with incorrect MIME-type info (another app with bogus registered MIME type for .js? something like that?).Using an asset-loader scheme would provide an https://-like URL and a "server" that would provide proper MIME-info, resolving what we now hope to be the underlying cause of the frequent error report. It's hard to know for sure at present due to our current inability to reproduce the issue.
Build-bot: skip release:android
User Testing
TEST_SMOKE: Verify that the Android app loads properly and that it properly swaps among installed keyboards and lexical models without issue. If a keyboard that should have an associated model does not display predictive text, FAIL this test. Verify that the correct font is used in the OSK and the input area in the Keyman app (e.g. try with the 'Lakeside' keyboard).
TEST_FIRSTVOICES: install FirstVoices Keyboards for Android apk. Try different keyboards, verify that the OSK and displayed text look correct. For SENCOTEN, verify that predictive text is working.