keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
368 stars 102 forks source link

feat(web): optimization via lazy preprocessing of keyboard touch-layout info ⏩ #11265

Open jahorton opened 2 weeks ago

jahorton commented 2 weeks ago

Follows #11264, addressing part of #11166.

How can we go "further beyond" with OSK loading speed than not building all of its layers initially? Why, by not even pre-processing all of its layers initially! This PR extends the just-in-time (JIT) behavior from the prior PR by only preprocessing layer-specifications as they're needed.

So, revisiting that gff_amharic stress-test from #11263, performed on a SM-T350 / Galaxy Tab A...

gff_amharic "before"

Loading time "before": between 3.5 to 4 seconds.

gff_amharic "after"

Loading time "after": 1.2 seconds, with half of that being keyboard-script load.

To be clear, underneath the visible buildLayer and getLayer stackframes in the second ("after") image, the visible s...e is sanitize, with the sliver to its right being polyfill. This is due to the newly-introduced JIT pattern - both are executing for a single layer, and only once it is needed.

Actual time spent preprocessing & building the OSK element hierarchy: just 120ms. Remember, "before", this section cost us 2.66 seconds! Of course, we'll have to pay that 2.66 seconds over time as we visit every layer... assuming we actually do visit every layer.

Clearly, the easiest way to optimize sanitize is to just... not do it until we have to. One layer isn't that expensive, even on older devices. 42 of them? Now that... that starts to add up. Of course, this does mean that each swap to a previously-unused layer will be a bit slower than before.


Other keyboards:

So, we're going somewhere around 50% faster (or better!) for keyboard loading with more "conventional" keyboards than we were with #11140, which was already a marked improvement on what came before.

User Testing

TEST_ANDROID_USE: Test the Keyman for Android app using `sil_euro_latin``.

TEST_IOS_USE: Test the Keyman for iPhone and iPad app using sil_euro_latin.

keymanapp-test-bot[bot] commented 2 weeks ago

User Test Results

Test specification and instructions

Results Template ``` # Test Results * **TEST_ANDROID_USE (OPEN):** notes * **TEST_IOS_USE (OPEN):** notes ```

Test Artifacts