neovide: Missing input events

Description

Rapidly inputting key strokes often results in missing strokes.

Expected behaviour

All key strokes, be it by hand or macros, should get to the text editor.

Steps to reproduce

Either mash your keyboard or use external macro software (such as AutoHotKey).

For example, mashing ‘aoeu’ together results in:

uuuu

In gvim, this would result in:

aoeuaoeuouaeaoeu

Environment

Windows 10 build 1909, using AutoHotKey and a mecanical keyboard with N-Key rollover support.

Plausible cause

After a quick look through the code base, I noticed that, in the ui_loop function in src/window.rs, the variables keycode and keytext are set to the last Event::KeyDown or Event::TextInput of the event_pump iterator, ignoring the first such events of the loop.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

On #314, by hitting several keys at once or using a macro, I get all strokes. However, space and some shifted keys are duplicated or otherwise output weirdly.

I hit all my keys once, without modifiers, then shifted, in both my main layout and qwerty. Here is the output:

##  dvorak
1234567890[]
',.pyfgcrl/=
aoeuidhtns-\
\;qjkxbmwvz

##  dvorak  shifted
!!@@##$$%%^^&&**()){{}}
""<<>>PYFGCRL??++
AOEUIDHTNS__||
||::QJKXBMWVZ

##  qwerty
1234567890-=
qwertyuiop[]
asdfghjkl;'#
\zxcvbnm,./

##  qwerty  shifted
!!"@£#$$%%^^&&**())__++
QWERTYUIOP{{}}
ASDFGHJKL::@"~#
||ZXCVBNM<<>>??

We can clearly see that the spaces are duplicated and the shifted keys behave weirdly. I don’t know how inputs should be handled with SDL2 but I suspect the Event::KeyDown and Event::TextInput events both contain the information about the key strokes and this is the reason for this behaviour. The events are later deduplicated by produce_neovim_keybinding_string called in window.handle_keyboard_input. This means the line keytexts.push((keycode, None)); in the Event::KeyDown arm will not have the input deduplicated if a corresponding Event::TextInput exists.

Since this is not a trivial issue and touches the very core of the input handling, which is the most important part of any text editor, I think we should approach this very carefully. @Kethku what’s your opinion on the matter?

My initial issue can be reproduced by setting the refresh rate to something low, for example :let g:neovide_refresh_rate=1. You will be able to type several strokes a second and see most of them fail to get there.

Thanks

I don’t think so. It’s likely either a race condition or something weird about the keyboard handling. Extra weirdly I don’t really encounter the described frequency. So I’m not sure what is going on here

This might be bad wording on my end: I don’t actually encounter it that much by regular typing but my AutoHotKey macros work about 10% of the time. Since they are important to my workflow, I’m not really sure I can switch to neovide just yet, which is a shame because it looks really good.