-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
bug(web): poor cookie default can cause engine-init error #13278
Comments
My initial suspicion was focused on the following block: keyman/web/src/app/browser/src/keymanEngine.ts Lines 177 to 182 in 263f918
When that Promise is resolved, registered-stub deferment ends. But, what if there are pending It may be wiser to replace that with... if(this.config.deferForInitialization.isResolved) {
// abort! Maybe throw an error, too.
return this.config.deferForInitialization.corePromise;
} Per MDN's documentation:
Adding a new handler here will ensure that later, secondary That said... we'd still be queuing up a new Promise resolution... and since the So, next I turned my attention here: keyman/web/src/app/browser/src/keymanEngine.ts Lines 216 to 229 in 263f918
Line 219: So... huh. Is there a subtle detail I'm missing here? |
With the user's site, it appears that there needs to be a clean cache in regard to the site. The first successful load (with Keyman Engine for Web activating) seems to generate this case; refreshing or revisiting the page afterward doesn't trigger the issue for me. It does appear to reproduce consistently, but only on the first visit each time after I use the "Delete browsing data" function or similar. I did this in Chrome with the following options set:
What I see:
Line 537 of the main page is the first |
init
calls; can lead to unexpected errors
Using that, via breakpoint I am able to see two things:
The engine actually does attempt to load one of the page's intended keyboards first. I confirmed that by setting a breakpoint at the first line of ... and I think I see what's happening. Within app/browser's engine init:
keyman/web/src/app/browser/src/keymanEngine.ts Lines 204 to 206 in 7ab6887
Note that we aim to preserve whatever the user's last keyboard setting was upon repeat visits to the page. keyman/web/src/app/browser/src/keymanEngine.ts Lines 228 to 236 in 7ab6887
At the end of init, we allow stubs to register (the first of which is generally auto-activated, depending on init options), after which we look to enforce their prior keyboard setting. The issue: what happens when there is no prior keyboard setting? keyman/web/src/app/browser/src/contextManager.ts Lines 753 to 769 in 7ab6887
Upon first visit, Contrast with the longer-standing
keyman/web/src/app/browser/src/contextManager.ts Lines 800 to 807 in 7ab6887
The final default is likely what was being modeled by the error-triggering path, but now that it's known to have adverse effects, we should nix that. |
Good analysis. Reminds me that we should be deprecating KMW's responsibility for storing state and shifting that responsibility to a completely separate module... |
This comes out of https://community.software.sil.org/t/keman-keyboard-is-not-rendering-on-chorme-and-mozilla-browsers/9783/6.
When attempting to reproduce the user's error on their site, I saw a rather... paradoxical-looking bug occur. I'll copy down the relevant parts of their source below.
Starting at line 534:
OK, that looks fine. Keyboard stubs can be registered before engine init, after all - especially with local information, and especially when the keyboard's
.js
file is locally hosted. TheaddKeyboards
methods have built-in checks that will defer further processing until the engine has sufficiently initialized; they're safe to call in this manner.Starting at line 1970 or so (Chrome prettified this):
OK, that looks to be fine -
sil_arabic_phonetic
has a stub added way earlier in the line-534 script tag's code. They're automatically deferred, yeah, but that should be fulfilled beforeinit
returns , so we should be fine here... right?The thing is... I did see one instance where a rather strange error occurred upon investigation. I couldn't get it to repro, but I saw an error with the following details:
init
’sthen
clause.So... somehow
sil_arabic_phonetic
wasn't registered by line 1978? But... how? Did the later block'sthen
somehow get called before the deferred stub-registering calls got completed? They should be synchronous after the deferment wears off!The text was updated successfully, but these errors were encountered: