The more I type, the slower the prediction/speed

We use Keyman keyboard to type in chat apps and to create web articles in our local language. It has been very helpful. But the more I type, the slower the prediction. Sometimes the app will hang, trying to load the prediction. This really slows down typing (taking a long while to finish typing just two pages of writing). Speed/predictiion also reduces when the network connection is on. I would have turn off prediction, but I need it for spell checking. Any advice please?
Note: If I copy the text I’ve written to somewhere else, and start on a fresh page, the prediction and typing become fast and smooth.

1 Like

This is curious. @joshua_horton and @eddieantonio, any ideas?

Could you tell us a bit more about how you’re using the keyboard when this happens? I’m going to make a few guesses based on what you’ve written here, but please tell me if I’m wrong on any of these. We’ll need to reproduce what you’re seeing to figure out what’s going on.

  • It sounds like you’re using Keyman to type directly within other applications. (So, as a “system keyboard.”)
    • The way you’ve phrased it, it sounds like you’ve seen the issue occur in a number of apps? Does it happen in any app you type long articles in?
    • It sounds like the application itself - not just the keyboard - is being slowed down? When things “hang”, you can’t navigate within the app you’re using? Or are only text-related things affected?

Also, thanks for that note - that gives me some ideas of what to look at already. I’ve managed to reproduce the effect on my own phone (iOS 13.4, iPhone SE) after typing around three paragraphs. (The first sign: the keyboard starts to update a bit sluggishly.) Interestingly, it does affect the keyboard and not just the predictions, which isn’t something we’d have expected based, but does match what you’re talking about.

Which reminds me: what sort of device(s) are you using when you see this? If you’re on an iPhone or your device supports changing between system keyboards, swapping to a different keyboard and then back to Keyman should have the same affect as making a “fresh page”. Hopefully that can help mitigate the issue somewhat for you while we work on fixing the problem on our side.

As far as the “when the network connection is on” part, I have no idea what might be causing that; the predictive text engine shouldn’t be interacting with the internet at all. It’ll take some time to figure out what might be causing that.

1 Like

An update: I’ve identified one issue that was likely the cause of this and have put together a fix. The release-targeted version of the fix can be tracked at https://github.com/keymanapp/keyman/pull/3302.

2 Likes

This update should be available soon in Keyman for iPhone and iPad 13.0.109 and Keyman for Android 13.0.6215.

1 Like

I’m sorry I didn’t come around here in time to answer your question. But just in case my may still be of help:

  • The issue happens in Android 5.1 and 8.0.
  • It happens in a number of apps I type long text in. E.g. Notebook app, Google Keep, WPS Office.
  • When I say “hang”, I mean that the keyboard takes some time before producing the letter just pressed, and will not process any other key press until it is done with the previous one.
  • It affects only the keyboard, and not the app I’m typing long articles in, because if I switch to Gboard within the same app, the typing is smooth (but Gboard does not contain all the letters and tones needed in the language).

ONE OTHER THING:
A friend who has been using the keyboard for this local language shared his experience with me. He had lost all the long text he typed because when he tapped the BACKSPACE button to delete a character, the keyboard kept backspacing, deleting the text as if the backspace key was held down. I have experienced this too. You might also want to look into this. Thanks. More grace.

Sorry to hear about that. Others have noted that issue (#1930) but we could never consistently reproduce the conditions to troubleshoot it. Could you check with your friend on his configuration? (Is he also using Keyman for Android?)

  • Device
  • Android version
  • Keyman for Android version number
  • Keyboard name and version
  • Language name

You can send the info in a PM if you’d rather not post.

1 Like

@darcy Hello, I’m having the same problem and it occurs in the same situation that @joshua_horton described in his second paragraph. This happens in the Keyman notepad and in Google Keep. My phone is a Pixel 3 XL, Keyman for Android 13.0.6215. I’m using the sxava keyboard. It’s language is Esperanto (shavian).

This issue is seriously affecting the Keyman app. Just two lines of text on a small screen and it starts slowing down. Can be really frustrating sometimes. I understand your team is really working hard, so I’m just bringing it as a reminder.
I’m using the latest version 14.0.275 on Android 8.

I hear you. I’ve done some investigation and have a reproduction of the issue.

Here’s my initial writeup of the problem: #5246

We’ll be investigating!

1 Like

Yes, it’s unfortunately fairly crippling for me on Android 8.1 on an item W5504 (P33) with 1GB RAM, 4 Core CPU. Is the best mitigation just not to use lexical models for now, or to keep them small?

We have a patch coming in 14.0.276 which should mitigate this. We intend to publish that version in the next day or so.

Version 14.0.276 is now available. Let us know how you go with it!

There is an improvement in 14.0.276, but the issue persists. After about 8 to 10 lines on my device, it slows down till it starts “hanging” again.

Thank you for the feedback @katelem247. That’s a bit of a disappointment, isn’t it?

I wonder if either of you (@katelem247 or @rowbory) would be willing to attempt to capture a performance profile from your device? This would help us to ensure we are chasing the right performance hotspot from our end. There are a few steps for setup the first time, but it’s not awfully complicated.

How to setup to capture a performance profile for Keyman

You’ll need:

  • your phone
  • a computer running Chrome
  • optionally (but usually simpler), a USB cable to connect your phone and the computer

More details and troubleshooting steps for this process are available in the Chrome Developer remote debugging documentation.

  1. On your phone, enable debugging:
  1. Open the Settings app.
  2. Select About phone.
  3. Tap Build number 7 times.
  4. Return to the previous screen to find Developer options.
  5. Scroll down and enable USB debugging.
  1. Connect your phone and computer with the USB cable.
  2. Unlock your phone.
  3. Make sure that the Keyman keyboard is visible on your phone in the context with the performance issue.
  4. On Chrome on the computer, open a new tab and navigate to chrome://inspect
  5. Your phone should show a message asking you to trust the computer for debugging. Go ahead and do that.
  6. Back on the Inspect tab on your computer, you should see a section titled Remote Target, and after a few seconds an entry called WebView in com.tavultesoft.kmapro. There may be two of these – one for the keyboard in the Keyman app, and one for the system keyboard. Select the one that is not marked as “hidden”, and click Inspect.
  7. If all goes well, you should see the Keyman for Android keyboard appear in a new DevTools window on your computer, looking something like this:

How to capture a performance profile

  1. After completing the above steps, click on the Performance tab in DevTools.
  2. Click the record button (:black_circle: icon in the toolbar) (or press Ctrl+E).
  3. On the phone, reproduce the performance issue.
  4. Click Stop on the computer to finish the performance trace.
  5. Click the download icon (image) to save the trace to disk
  6. Finally, send the trace to us in a DM on this forum (you may need to zip it first).

(You may want to capture two traces: one with an empty buffer so we can see Keyman performing ‘normally’, and one where keystrokes are ‘hanging’.)

1 Like

Thanks @rowbury, I’ve reviewed the profile and confirm that the performance hotspot is still in the same place – so the mitigation was not sufficiently effective. We’ll have another go at resolving that.

1 Like

Thanks. Will try to keep an eye on developments and can test again. The most annoying thing for me is not that prediction lags but that the key presses get slower and slower until you are just watching everything play out in slow motion. I’ve no idea if prediction could run in a different thread or be killed and restarted when a new key is pressed, but that might also help.

The predictions already run in their own thread and are time-bound as well.

In this case, this is a preparation routine that is preparing key event probabilities for the prediction thread – which currently needs to be done in the main thread – and the issue is it is processing the entire document for context when it really doesn’t need to. Resolving that to use a sliding window is going to take a bit of extra effort but we will be wokring on that.

1 Like