mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 08:25:32 +00:00
Summary of these changes: Two targeted improvements; more optimization is possible but IMO this is a significant enough improvement to go through test: 1. In oskView.ts, avoid calling `VisualKeyboard.refreshLayout` twice from `OSKView.refreshLayout`. This roughly halves the time spent in `VisualKeyboard.refreshLayout` for a keyboard switch. 2. In modelManager.ts, we avoid a very expensive `unloadModel` / `loadModel` sequence from `registerModel` by checking to see if the model spec we are passed is already registered. This avoids an expensive callback to Keyman for Android which causes the banner to 'bounce'. Longer notes: So `VisualKeyboard.refreshLayout` is called 20+ times during a keyboard switch. It is a very expensive call. It is the bulk of the time spent when you press the globe key in Keyman for Android. This seems ripe for optimization; see the following functions in keyboard.html: * `setKeymanLanguage` -> `setActiveKeyboard` -> 6 calls * `enableSuggestions` -> `registerModel` -> 8 calls * `stateChange` -> 6+ calls `OSKView.refreshLayout` always seems to call `VisualKeyboard.refreshLayout` twice: first with `setSize`, and then again itself. Keyman for Android and KeymanWeb seem to fight over who is responsible for selecting models (KMW first calls `loadModel`, then Keyman for Android calls `unloadModel`, `loadModel`, through `enableSuggestions`). The fix for rotation (`correctOSKTextSize()`), as called from `stateChange()`, is expensive as well, because it rebuilds the entire keyboard from scratch. Along with that, we have the size of the webview changing as the model is unloaded and reloaded and lots of back-and-forth between the KeymanWeb and KMEA which seems unnecessary. Shouldn't KeymanWeb be responsible for loading and unloading models, once they are all registered? We should only need to register the models once at page load time (when config changes, do we just reload the page?). |
||
|---|---|---|
| .. | ||
| prediction | ||
| domKbdInterface.ts | ||