canonical / mir

The Mir compositor
GNU General Public License v2.0
627 stars 100 forks source link

[Mir-on-X] Keys repeated #1471

Open wmww opened 4 years ago

wmww commented 4 years ago

After a number of XWayland windows are open, quickly typed keys sometimes come out repeated a bunch of times. It only seems to happen when a bunch of XWayland windows are open, but both XWayland and Wayland windows are effected. I suspect this is due to a combination of causes:

EDIT: so far I've only observed this in Mir-on-X.

AlanGriffiths commented 4 years ago

I'm suspicious of the thread safety around the Mir-on-X platform. (But might find everything significant runs on a single thread when I take a closer look.)

AlanGriffiths commented 4 years ago
  • Short time before keys start repeated (Not the real issue, but our hard-coded value is quite short)

I don't think Wayland (including via Xwayland) clients make any use of Mir's server-side auto-repeat, so this shouldn't be affecting anything.

AlanGriffiths commented 4 years ago

This sounds a lot as though it might have been fixed by #1623 (or, possibly, #1646).

I've not seen it often, @wmww have you seen it recently?

wmww commented 4 years ago

I've just confirmed it's still a problem.

AlanGriffiths commented 3 years ago

This seems entirely down to the Mir-on-X platform.

The easiest way to reproduce is to use a Mir server over ssh -x to another machine on the local network. There's no need to enable X11 support on the Mir server.

I'm not sure exactly what triggers it yet, but in this scenario it happens a lot.

wmww commented 3 years ago

It seems like something is slowing down the thread that handles X11 input. In some cases, this can be slowed down by as much as dozens or hundreds of milliseconds, which then causes a key to appear down long enough to trigger a repeat. I'm tracking down where this is happening.

wmww commented 3 years ago

Hmm, I've now put X11 events on their own dispatcher and that doesn't seem to help. Maybe XLib is doing something synchronously that is blocking events?

AlanGriffiths commented 3 years ago

OK, I've dug into this on both the existing xlib and proposed xcb based X platforms.

The key repeats happen because the client doesn't see the release event until long after the press event. But that's because the same is true of the X11 input platform. From my debug session:

[2021-04-23 15:58:43.483781] < - debug - > x11-input: ====> XInputDevice::key_press(71003340000000, o, ...)
[2021-04-23 15:58:48.662458] < - debug - > x11-input: ==> XInputDevice::key_release(71003444000000, o, ...) // 104ms since press

These event timestamps are 104ms apart, but the times the events are processed are 5s apart.

We could disable the repeats on the client (that ought to be configurable on wl_keyboard anyway). We might also pass through the repeats from the server.

Alternately we could figure out why the connection is so laggy. I also noticed that the screen repaint is very laggy - typing not shown for over 5 seconds (when I moved the mouse).

AlanGriffiths commented 2 years ago

Still an issue, most noticeable with a remote X11 session. (e.g. ssh -XC another-machine miriway)