problem with key repeat, extra key up events

Bug #403339 reported by warren on 2009-07-23
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
X.Org X server
Fix Released
Medium
xorg-server (Ubuntu)
Medium
Unassigned

Bug Description

Binary package hint: xorg

This is a well known bug discussed elsewhere, the problem is although there are fixes available, none have been implemented. When a key is held down, the system should wait a bit then generate a string of key down events. The key up event should only be triggered when the key is actually physically released. Currently, key presses produce a chain of key down and key up events. Based on what I have read, the error is introduced in a sloppy fix of another problem, where some legitimate key up events were not occurring. This is only a serious problem for video games, as other software does not require exacting standards for input.

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: nvidia
Package: xorg 1:7.4~5ubuntu18
ProcEnviron:
 PATH=(custom, no user)
 LANG=en_CA.UTF-8
 SHELL=/bin/bash
ProcVersion: Linux version 2.6.28-13-generic (buildd@vernadsky) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009
SourcePackage: xorg
Uname: Linux 2.6.28-13-generic i686

Related branches

Created an attachment (id=27196)
Xorg.0.log

Perhaps too obvious to point out, but this bug is visible through GDK too. GDK tries to always set detectable autorepeat, and if XkbSetDetectableAutoRepeat says it is not supported, GDK emulates it by filtering out the extra KeyReleased events. With this bug, since support is claimed but doesn't work, GDK doesn't do the emulation either.

This breaks some applications in Wine too but I'm mainly commenting to point out this:

  http://lists.freedesktop.org/archives/xorg/2009-June/045945.html

I hope this is useful to anyone coming here looking for more information.

Just confirmed in current git.
I'm not in the position to increase this bugs Priority, but IMO it should be changed to high. This is now hitting mainstream distributions (eg Ubuntu 9.04) and quite some apps may be affected, possibly in some subtle ways.
The problem is understood and Daniel seems to have a fix in his repo, so I hope this will be resolved soon.

warren (warren-driscoll) wrote :

Binary package hint: xorg

This is a well known bug discussed elsewhere, the problem is although there are fixes available, none have been implemented. When a key is held down, the system should wait a bit then generate a string of key down events. The key up event should only be triggered when the key is actually physically released. Currently, key presses produce a chain of key down and key up events. Based on what I have read, the error is introduced in a sloppy fix of another problem, where some legitimate key up events were not occurring. This is only a serious problem for video games, as other software does not require exacting standards for input.

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: nvidia
Package: xorg 1:7.4~5ubuntu18
ProcEnviron:
 PATH=(custom, no user)
 LANG=en_CA.UTF-8
 SHELL=/bin/bash
ProcVersion: Linux version 2.6.28-13-generic (buildd@vernadsky) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009
SourcePackage: xorg
Uname: Linux 2.6.28-13-generic i686

warren (warren-driscoll) wrote :
Bryce Harrington (bryce) on 2009-07-24
Changed in xorg (Ubuntu):
status: New → Confirmed
Timo Aaltonen (tjaalton) wrote :

It would be nice to know where it is discussed and where to find the fixes..

affects: xorg (Ubuntu) → xorg-server (Ubuntu)
Changed in xorg-server (Ubuntu):
status: Confirmed → Incomplete
warren (warren-driscoll) wrote :
warren (warren-driscoll) wrote :

Oops, the first link is not relevant on recheck.

*** Bug 22194 has been marked as a duplicate of this bug. ***

Another application that is affected by this bug: https://gna.org/bugs/?14033

There is a patch attached to the the mail that is linked above. Is there something wrong with that fix?

Changed in xorg-server:
status: Unknown → Confirmed
Bryce Harrington (bryce) on 2009-08-12
Changed in xorg-server (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Triaged
Bryce Harrington (bryce) on 2009-08-13
tags: added: jaunty

I just checked with current git and the bug is no more. Looks like it was fixed some time ago by [1].

[1] http://cgit.freedesktop.org/xorg/xserver/commit/?id=bfb219f532f3c78ba905424365ee7c5f7b5f21a2

Changed in xorg-server:
status: Confirmed → Fix Released
Launchpad Janitor (janitor) wrote :
Download full text (3.9 KiB)

This bug was fixed in the package xorg-server - 2:1.6.4-2ubuntu1

---------------
xorg-server (2:1.6.4-2ubuntu1) karmic; urgency=low

  * Merge from Debian unstable. (LP: #447010)
    Remaining Ubuntu changes:
    - debian/control:
      + set Conflicts: xkb-data (<< 0.9), since xkb-path is
        different from previous releases
      + do not Conflict with xserver-xorg-video
      + xvfb Depends on xauth, xfonts-base
      + Set Maintainer to Ubuntu Core Developers
    - debian/rules:
      + build using -fno-stack-protector
      + --with-os-vendor=Ubuntu
    - debian/xserver-xorg-core.install:
      + Add ioport, pcitweak, scanpci scripts & man pages
    - debian/patches:
      + 101_fedora_xserver-1.3.0-document-fontpath-correctly.patch:
        Specify correct paths to fonts
      + 102_ubuntu_sharevts_load_cpu.patch:
        close console fd only when ShareVTs
      + 103_psb_auto.patch:
        Autodetect poulsbo devices (but use -vesa since -psb is broken)
      + 110_fedora_no_move_damage.patch:
        further aiglx support
      + 121_only_switch_vt_when_active.diff:
        Add a check to prevent the X server from changing the VT when killing
        GDM from the console.
      + 135_rethrow_signals.patch:
        When aborting, re-raise signals for apport
      + 140_quell_acpi_errmsgs.patch:
        Avoid generating extraneous warnings when acpi is missing
      + 153_make_dmx_compile.patch:
        Change xcalloc -> calloc, so that dmx compiles.
      + 156_exevents_copykeyclass_nullptrcheck.patch,
        157_check_null_modes.patch, 162_null_crtc_in_rotation.patch,
        166_nullptr_xinerama_keyrepeat.patch, 167_nullptr_xisbread.patch
        169_mipointer_nullptr_checks.patch,
        172_cwgetbackingpicture_nullptr_check.patch:
        Fix various segfaults in xserver by checking pointers for NULL
        values before dereferencing them.
      + 164_trap-aspect-ratios.patch:
        Correct monitor EDIDs that have misreported aspect ratios.
      + 165_man_xorg_conf_no_device_ident.patch
        Correct man page
      + 168_glibc_trace_to_stderr.patch:
        Report abort traces to stderr instead of terminal
      + 174_set_bg_pixmap_of_cow_to_none.patch:
        Set background pixmap of composite overlay window to no background
      + 177_animated_cursor_change_master.patch:
        Don't create animated cursors for slave devices
      + 180_fedora_no_synaptics_mouse_synthesis.patch:
        Don't synthesize a mouse section if a synaptics device is found
      + 181_fedora_log_proc_cmdline.patch:
        Dump /proc/cmdline in the log file too
      + 184_virtual_devices_autodetect.patch:
        Use vesa for qemu device, which is not supported by cirrus
      + 185_dix_badwindow.patch:
        Don't return BadMatch from GetProperty if window isn't actually a window
      + 186_autoconfig_geode.patch
        Perform autodetection correctly for various geode devices
  * Update 184_virtual_devices_autodetect.patch to only include inserting
    cirrus, since vbox is covered by the new fedora patch.
  * Drop patches already included upstream:
    - 187_lastdeviceeventtime-no-reset.patch
    - 178_glx_flush_cache.patch
  ...

Read more...

Changed in xorg-server (Ubuntu):
status: Triaged → Fix Released
Rodd Snook (snookums) wrote :

This appears not to be fixed for me in 2:164-2ubuntu3. Holding down any key generates a string of KeyPress and KeyRelease events, rather than just KeyPress. Output from the reproducer attached to the freedesktop.org bug report:

XAutoRepeatOn returns 1
XkbSetDetectableAutoRepeat returns 1, supported = 1
KeyRelease keycode 0x24 time 0x1f2ee16
KeyPress keycode 0x28 time 0x1f3009c
KeyRelease keycode 0x28 time 0x1f30290
KeyPress keycode 0x28 time 0x1f30290
KeyRelease keycode 0x28 time 0x1f302b1
KeyPress keycode 0x28 time 0x1f302b1
KeyRelease keycode 0x28 time 0x1f302d3
KeyPress keycode 0x28 time 0x1f302d3
KeyRelease keycode 0x28 time 0x1f302f5
KeyPress keycode 0x28 time 0x1f302f5
KeyRelease keycode 0x28 time 0x1f30316
KeyPress keycode 0x28 time 0x1f30316

Rodd Snook (snookums) wrote :
Rodd Snook (snookums) wrote :
Changed in xorg-server (Ubuntu):
status: Fix Released → New
Bryce Harrington (bryce) on 2009-10-26
Changed in xorg-server (Ubuntu):
status: New → Confirmed
Rodd Snook (snookums) wrote :

The Xi code in debian git seems to be missing quite a few commits from upstream. The two which appear to be relevant to this bug are:

http://cgit.freedesktop.org/xorg/xserver/commit/?id=c05f3bc935bef4d98216d38c0e98bd57ced382df
and
http://cgit.freedesktop.org/xorg/xserver/commit/?id=bfb219f532f3c78ba905424365ee7c5f7b5f21a2

Bryce Harrington (bryce) wrote :

[This is an automatic notification.]

Hi warren,

This bug was reported against an earlier version of Ubuntu, can you
test if it still occurs on Lucid?

Please note we also provide technical support for older versions of
Ubuntu, but not in the bug tracker. Instead, to raise the issue through
normal support channels, please see:

    http://www.ubuntu.com/support

If you are the original reporter and can still reproduce the issue on
Lucid, please run the following command to refresh the report:

  apport-collect 403339

If you are not the original reporter, please file a new bug report, so
we can work with you as the original reporter instead (you can reference
bug 403339 in your report if you think it may be related):

  ubuntu-bug xorg

If by chance you can no longer reproduce the issue on Lucid or if you
feel it is no longer relevant, please mark the bug report 'Fix Released'
or 'Invalid' as appropriate, at the following URL:

  https://bugs.launchpad.net/ubuntu/+bug/403339

Changed in xorg-server (Ubuntu):
status: Confirmed → Incomplete
tags: added: needs-retested-on-lucid-by-june
warren (warren-driscoll) wrote :

I have used xev to test on Xubuntu 9.10. the bug is still present.

warren (warren-driscoll) wrote :

simple testing instructions:
-open a console
-type xev
-put mouse inside black square
-hold down a key (keep holding until end of test)
--look at console output
-the last event is a key press. that's good.
-the second last is a key release. that's bad.

Martin Renold (martinxyz) wrote :

You cannot reproduce this bug with xev. The output you describe is a little bit strange, but correct behaviour. The program has to explicitely change the behaviour through an API call.

warren (warren-driscoll) wrote :

to Martin Renold:
I must confess I do not entirely understand your statement.

My reasoning is as follows:
1) xev is the primary tool used to test and diagnose x11 windowing input events.
2) I can confirm that the error as produced in xev is also produced in java windowing events, and I would assume any other windowing events.
3) the behaviour is wrong because it is not industry standard.
4) the behaviour is wrong because it destroys information that some programs need.

Therefore, the behaviour is both wrong and should be demonstrated by xev.

I could not get your reproducer to work: Might I suggest that we may have slightly different bugs? A solution in c might not work for java or flash.

Martin Renold (martinxyz) wrote :

Xev does not call XkbSetDetectableAutoRepeat(), thus it cannot be used to test whether XkbSetDetectableAutoRepeat() does get rid of the extra key up events or not.

Rodd Snook (snookums) wrote :

This bug appears to be fixed. The reproducer attached to the xorg bug produces the expected output:

KeyPress keycode 0x41 time 0x1cf6ab
KeyPress keycode 0x41 time 0x1cf6ce
KeyPress keycode 0x41 time 0x1cf6f0
KeyPress keycode 0x41 time 0x1cf711
KeyPress keycode 0x41 time 0x1cf733
KeyPress keycode 0x41 time 0x1cf754
KeyPress keycode 0x41 time 0x1cf775
KeyPress keycode 0x41 time 0x1cf796
KeyRelease keycode 0x41 time 0x1cf7a0

This is on a Macbook Pro Core2 Duo booted from the Ubuntu 10.04 AMD64 Deskop CD.

Changed in xorg-server:
importance: Unknown → Medium
Anagram3K (anagram3k) wrote :

This bug still exists. I can confirm it on Lucid
Linux kila-desktop 2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:26:08 UTC 2010 i686 GNU/Linux

Rodd Snook (snookums) wrote :

I'm not seeing this with the most recent Lucid xorg package (1:7.5+5ubuntu1), x86_64 architecture.

Luis, how did you test this? Note that the xev method described in comment #21 of this thread is invalid. You must test using by compiling and running the reproducer code attached to the bug at http://bugs.freedesktop.org/attachment.cgi?id=27195, or by observing unexpected behaviour in an application. If the latter, please list the application, steps to reproduce, and how the behaviour differs from what is expected.

Changed in xorg-server:
importance: Medium → Unknown
warren (warren-driscoll) wrote :

Workaround:
Works for all games that do not work properly because of keyup events.
Type
>xset r off
into console.
Works even if game is already running.
Remember to type
>xset r on
for normal operation afterwards.

I have already used this for some flash games that gave me trouble in the past.

Changed in xorg-server:
importance: Unknown → Medium
Timo Aaltonen (tjaalton) wrote :

warren: so this is still not fixed for you in 10.04 or later?

Bryce Harrington (bryce) on 2011-03-04
Changed in xorg-server (Ubuntu):
status: Incomplete → New
status: New → Incomplete
warren (warren-driscoll) wrote :

I apologize, but I decided not to use linux this year. I waited until I was certain to answer the last post, as others are affected by this bug.

Bryce Harrington (bryce) wrote :

Alright, well we'll close it out at this time. If it still affects others they can open new bug reports.

Changed in xorg-server (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.