bug report/suggested temp. patch: handling bursts of sent keys

Mark Lillibridge mark.lillibridge@hp.com
Tue Jan 12 18:45:00 GMT 2010


Background: 

    I use Nuance's Dragon NaturallySpeaking voice recognition software
to control remote Linux systems from a Windows box.  I open up xterms
and emacs windows on a local Cygwin X server.  Occasionally the voice
recognizer makes a mistake, which has to be corrected.  The mechanics of
how this is done are unimportant; what matters is how Dragon applies the
correction.  It does this by sending a large burst of keystrokes via
something like SendKeys.  (E.g., many (shift) arrow keys to select the
text to be changed, a backspace to delete it, then the replacement
text.)

    Unfortunately, there is a bug in the current released Cygwin X
server that causes it to drop sent keystrokes when the burst exceeds a
given size (roughly 64 or 128 keys depending on the version).  This
breaks correction, and forces painful manual fix up of the text.  Note
that what is really dropped are key events so the system can get into
the state where the shift key remains pressed or a key starts repeating
forever because the key up event was dropped.


Problem/temporary patch:

    I investigated and found that the problem appears to be that the X
event queue (miEventQueue) in hw/mi/mieq.c is statically allocated with
a ridiculously small value (512).  When keyboard bursts come in, this
queue overflows, causing the problem.  If I set this queue to a more
reasonable value of 5120:

    mieq.c:62:#define QUEUE_SIZE  5120    /* was 512 */

then 10 times larger key bursts can be accommodated without problem.
This value is probably still too small in practice so it would be safer
to go with a larger value like 25000.

    I characterize this as a temporary patch because ideally either the
queue would be made dynamic with no upper bound in size, or some kind of
flow control would be implemented so the code that receives Windows key
events does not overflow the event queue.


Reproducing the problem:

    Dragon NaturallySpeaking costs money, so I will instead describe how
to demonstrate the problem using AutoHotkey, which is a free download
from http://www.autohotkey.com/.  Download that program then create and
run the following script, burst.ahk:

====================  cut here for burst.ahk ====================
#space::
    Send ********** ********** ********** ********** **********{enter}********** ********** ********** ********** **********{enter}********** ********** ********** ********** **********{enter}********** ********** ********** ********** **********{enter}********** ********** ********** ********** **********{enter}
=================================================================

Finally, type the Windows key and space together while focus is on an X
application.  The bug is not present, the following will be typed:

********** ********** ********** ********** **********
********** ********** ********** ********** **********
********** ********** ********** ********** **********
********** ********** ********** ********** **********
********** ********** ********** ********** **********


On the other hand, if the bug is present you'll get something more like:

********** ********** ********** ********** **********
********** ********** ********** ********** **********
*******                                         


- Mark


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/



More information about the Cygwin-xfree mailing list