Bug 1086650

Summary: Keys are stuck and not released in virt-viewer under poor network conditions
Product: Red Hat Enterprise Virtualization Manager Reporter: akotov
Component: mingw-virt-viewerAssignee: Default Assignee for SPICE Bugs <rh-spice-bugs>
Status: CLOSED NOTABUG QA Contact: Desktop QE <desktop-qa-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.3.0CC: acathrow, akotov, cfergeau, djasa, fidencio, gklein, jbuchta, marcandre.lureau, tspeetje, yeylon
Target Milestone: ---   
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-23 15:08:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description akotov 2014-04-11 09:06:03 UTC
Description of problem:

When using a terminal and typing some commands keys are stuck and the stuck key is issued a lot of times to the guest.

Terminal can look like this:

$ echoooooooooooooooooooooooooooooooooooooooo

Ctrl-C does not help, hitting the key again sometimes helps, so it probably gets released.


Issue is not limited to console, it also happens in editors.

Version-Release number of selected component (if applicable):

RHEV 3.3, virt-viewer latest 0.5.6

How reproducible:

Under poor network conditions, e.g. Wi-Fi. Packet loss and latency present


Steps to Reproduce:
1. On windows client login to the RHEV Web UI and access vdi, open a console or text editor
2. On hypervisor imitate poor network circumstances:

modprobe sch_netem
tc qdisc add dev eth1 root netem los 20% delay 200ms

3. Start typing text in guest via virt-viewer console

Actual results:

Keys are sometimes stuck and not released

Expected results:

Keys are correctly released

Additional info:

Comment 2 Marc-Andre Lureau 2014-04-11 09:11:51 UTC
Is this happening with RHEL client as well? If yes, please open a duplicate.

Comment 4 Marc-Andre Lureau 2014-04-11 11:59:16 UTC
I can't reproduce with localhost fedora, and rhel6 guest.
with tc qdisc add dev lo root netem los 20% delay 200ms

Since v0.13-15-g0d5ad7e we have code to deal with press_and_release, to differentiate from sending press and release.

How do you type on keyboard during testing?

If you keep key pressed long (more than 100ms) then it will be considered as a press event, and repeat might trigger on guest.

If you type normally, you are usually under the 100ms, and a single "atomic" press/release event is sent to server/guest.

Comment 5 Marc-Andre Lureau 2014-04-11 13:40:42 UTC
I can reproduce.



(remote-viewer.exe:940): GSpice-DEBUG: key_event press: keycode: 81  state: 0  g
(remote-viewer.exe:940): GSpice-DEBUG: delayed press 16
(remote-viewer.exe:940): GSpice-DEBUG: key_event press: keycode: 87  state: 0  g
(remote-viewer.exe:940): GSpice-DEBUG: key_event release: keycode: 81  state: 0
(remote-viewer.exe:940): GSpice-DEBUG: delayed press 17
(remote-viewer.exe:940): GSpice-DEBUG: release 16
(remote-viewer.exe:940): GSpice-DEBUG: key_event release: keycode: 87  state: 0
(remote-viewer.exe:940): GSpice-DEBUG: release 17
(remote-viewer.exe:940): GSpice-DEBUG: key_event press: keycode: 69  state: 0  g
(remote-viewer.exe:940): GSpice-DEBUG: key_event release: keycode: 69  state: 0
(remote-viewer.exe:940): GSpice-DEBUG: press and release 18

Typing fast enough make press/release event overlap over keys.

In this case the current filtering code isn't good enough to trigger a single press_and_release() event. The send_key() logic needs to be improved.

Comment 6 Marc-Andre Lureau 2014-04-11 13:44:50 UTC
though the key is always eventually released. Are you saying that the key is never released, sometime?

Comment 7 akotov 2014-04-11 13:48:53 UTC
I have not seen key being stuck forever, pressing the stuck key again helps release the key faster.

Comment 8 Marc-Andre Lureau 2014-04-11 13:49:39 UTC
actually, the logic in send_key() is correct, we need to send seperate press and release event when we get such overlapped key sequence.

I am afraid we will have to send longer scancode sequences of arbitrary events, and not individual events,..

Comment 9 Marc-Andre Lureau 2014-04-11 13:54:22 UTC
I wonder if we shouldn't delay/buffer all keys events until the keyboard is released or a delay of 100ms is triggered (so that we keep event sequence, and send an atomic message to avoid repeatition)

Comment 10 David Jaša 2014-04-25 13:30:06 UTC
(In reply to Marc-Andre Lureau from comment #5)
> ...
> Typing fast enough make press/release event overlap over keys.
> 
> In this case the current filtering code isn't good enough to trigger a
> single press_and_release() event. The send_key() logic needs to be improved.

(In reply to Marc-Andre Lureau from comment #8)
> actually, the logic in send_key() is correct, we need to send seperate press
> and release event when we get such overlapped key sequence.
> 
> I am afraid we will have to send longer scancode sequences of arbitrary
> events, and not individual events,..

So this isn't a regression of bug 812347?

When you say "overlapped key sequence", does that happen only when deliberately pressing more keys at once (such as when using modifiers with keys) or is just fast-enough one-after-another typing enough to trigger the bug? I suppose it's the latter, just to make sure...

Comment 11 Marc-Andre Lureau 2014-04-25 13:52:28 UTC
(In reply to David Jaša from comment #10)
> (In reply to Marc-Andre Lureau from comment #5)
> > ...
> > Typing fast enough make press/release event overlap over keys.
> > 
> > In this case the current filtering code isn't good enough to trigger a
> > single press_and_release() event. The send_key() logic needs to be improved.
> 
> (In reply to Marc-Andre Lureau from comment #8)
> > actually, the logic in send_key() is correct, we need to send seperate press
> > and release event when we get such overlapped key sequence.
> > 
> > I am afraid we will have to send longer scancode sequences of arbitrary
> > events, and not individual events,..
> 
> So this isn't a regression of bug 812347?

No, you would have even more key repeatitions. Now key repeatition is only happening when press/release events between different keys are overlapping. In some ways, this was done like this by design not by mistake, thinking that it wouldn't trigger easily, but it seems it is easy to trigger..

> When you say "overlapped key sequence", does that happen only when
> deliberately pressing more keys at once (such as when using modifiers with
> keys) or is just fast-enough one-after-another typing enough to trigger the
> bug? I suppose it's the latter, just to make sure...

Both cases can trigger key repeat events, since press and release events will be sent as seperate events in those cases. 

I think my proposal from comment #9 still holds. Feel free to suggest more ideas...

Comment 14 Fabiano Fidêncio 2014-07-23 15:08:32 UTC
I've been testing a few ideas to solve the problem but none of them came without drawbacks, unfortunately.
Marc-André's idea about delay/buffer for all key events till the keyboard is released also has drawbacks. Indiscriminately disabling key repeat in the guest is not a good solution as well, as pointed out is this discussion (http://comments.gmane.org/gmane.comp.emulators.spice.devel/8927) about bug 812347, but this is what can be done by the user when using a poor connection.

Comment 15 Marc-Andre Lureau 2014-07-23 15:31:20 UTC
Pointing out also that VMWare and other remote desktop solutions have recommendations to disable or set guest settings to long delay before the repeat triggers, see for ex this KB http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=196.

Note that qemu doesn't implement hw/at key repeat, so in linux console by default (without sw repeater), keyrepeats are generated by clients and will not suffer undesired key repeats (kbdrate settings are ignored, only client settings matter).