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

fix(web): properly support workerless use of Web engine #13290

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented Feb 20, 2025

Fixes: #13262
Fixes: KEYMANWEB-COM-1VH

Supersedes: #13270.

User Testing

TEST_ANDROID_PREDICTIONS: Using the Keyman for Android test artifact, verify that predictive text appears to function as usual.

@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Feb 20, 2025
@dinakaranr
Copy link

Test Results

I tested this issue with the attached Keyman"18.0.197-beta-test-13290" build(20/02/2025) on Android 14(Physical device). Here I am sharing my observation.

  • TEST_ANDROID_PREDICTIONS (Passed):
  1. Install the keyman-18.0.197.apk file.
  2. Launch Keyman and dismiss the "Get Started" menu.
  3. Open the keyman notepad and then the "Euro_Latin_SIL" keyboard appears.
  4. Added a few sentences.
  5. Verified that the predictive text appeared on the suggestion banner while typing words.
  6. Note: Observed that the predictive text appeared for Keep and Chrome (editpad.org and search box) browsers.
    It works well. Thank you.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Feb 20, 2025
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +45 to +49
try {
this.lmEngine = new LMLayer(capabilities, predictiveWorkerFactory?.constructInstance());
} catch {
// We can condition on `lmEngine` being null/undefined.
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the try/catch would be around constructInstance() only, not around new LMLayer. Even then, if there is an error in the constructor apart from the WebWorker not being available, the catchall is going to mask the error completely. Hence, I think we should console.warn() on it (not sure my suggestion is perfect here).

Suggested change
try {
this.lmEngine = new LMLayer(capabilities, predictiveWorkerFactory?.constructInstance());
} catch {
// We can condition on `lmEngine` being null/undefined.
}
let instance: <TypeHere>;
try {
instance = predictiveWorkerFactory?.constructInstance();
} catch(e) {
// We can condition on `lmEngine` being null/undefined.
console.warn('Web workers are not available: ' + (e ?? '').toString());
instance = null;
}
if(instance) {
this.lmEngine = new LMLayer(capabilities, instance);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants