Conversation
DO NOT MERGE This is incomplete but just looking at some of the changes required to provide worker as a separate file - only for kmw so far. Build-bot: skip Test-bot: skip
User Test ResultsTest specification and instructions
Results Template |
|
@jahorton FYI this is what I was playing with in terms of unbundling the worker; I have not yet tackled the path questions (need some special casing for unit tests, but for normal use it should be easier I hope, relative to keymanweb.js init path). And of course the Android bypass of importScript is really a separate question altogether. Are you keen to take this on? Or would you prefer that I keep working on this? |
* Rename several classes and files to clarify difference between worker and factory that constructs worker * Rework worker factories to actually implement `WorkerFactory` interface * Fixup pathing issues where `http:/host` was returned instead of `http://host` * Rename worker-thread output from worker-main.js to worker-thread.js, resolving confusion with separate worker-main module * Add path resolution for worker-thread.js to Keyman Engine * Tweak build scripts and unit tests to work with the new unbundled paths
|
Per @ermshiperete, who kindly compared the two implementations of this: #16574 is based on an earlier commit of #16565. Since both are in draft they may be incomplete, and I didn't check what from #16565 would also be in #16574, so some of my comments below might be valid for the other PR as well. In #16565
My plan is to use #16565, apply the review comments on this PR, and port the following improvements over from #16574:
|
Note that architecturally, the engine's path configuration is not ready - or even near ready - when |
Since we were bundling the worker previously, when interactively debugging, there was no way to provide sourcemaps without also bundling them. This led to a massive filesize spike, so we only bundled sourcemaps for 'debug' builds. Unbundling the worker allows us to draw in the worker sourcemaps from a separate file, so we don't really lose anything here - as long as we remember to copy the sourcemap file into the Android and iOS bundles in addition to the newly spun-off worker script file. |
Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com> Co-authored-by: Joshua Prins-Horton <jahorton@users.noreply.github.com>
jahorton
left a comment
There was a problem hiding this comment.
Past the other comment I made, I'd like to verify that the worker's sourcemaps show up properly when debugging the Android and iOS apps. Will get to that later today.
|
|
||
| // @ts-ignore | ||
| window['keyman'] = new KeymanEngine(WebWorker, sPath); No newline at end of file | ||
| window['keyman'] = new KeymanEngine(new WebPredictiveTextWorkerFactory(sPath + 'worker-thread.js'), sPath); No newline at end of file |
There was a problem hiding this comment.
This solution appears to be bypassing the standard KeymanEngine path-configuration process, instead determining the .sourcePath it would have constructed in advance?
There was a problem hiding this comment.
Yes. This is making the (hopefully fairly safe) assumption that worker-thread.js can be found at the same URL path as keymanweb.js; there's a bit of a chicken-and-egg with the pattern of constructing the predictive text worker factory before KeymanEngine is constructed. Not seeing a cleaner way of implementing this at present (although perhaps 'worker-thread.js' belongs in a constant somewhere)
There was a problem hiding this comment.
My version of the PR just initialized the actual worker later, using the configured path as a parameter for the constructInstance method.
|
The Android build checks out, but I'm not getting sourcemaps on iOS yet. Looking into that now. |
|
OK, fixed the iOS engine sourcemapping. |
This change unbundles the lexical model worker from keymanweb.js, and provides it alongside as a separate .js file.
This is groundwork to address issue #13862 with Keyman for Android, whereNote: file:// is unreliable, but http[s]:// has proven reliable (see #16628).importScriptsappears to be unreliable in aWorkercontext; this unreliability has increased dramatically as of Chrome 152.Unbundling of the worker was on the roadmap for Keyman but this change has been brought forward, originally due to the need to mitigate #13862.
WorkerFactoryinterfacehttp:/hostwas returned instead ofhttp://hostFixes: #13862
Build-bot: release
User Testing