Bug 14109 - event jam/mouse events getting stuck
Summary: event jam/mouse events getting stuck
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/elographics (show other bugs)
Version: 7.2 (2007.02)
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
: 15875 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-01-17 04:50 UTC by Christoph Walter
Modified: 2009-12-17 17:12 UTC (History)
7 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch to fix incorrect usage of variables within xf86EloReadInput (3.02 KB, patch)
2008-05-20 21:16 UTC, William Brack
no flags Details | Splinter Review
Patch to fix incorrect usage of variables within xf86EloReadInput (2.33 KB, patch)
2008-06-16 19:19 UTC, William Brack
no flags Details | Splinter Review
Patch to fix incorrect usage of variables within xf86EloReadInput (3.46 KB, patch)
2008-06-17 20:11 UTC, William Brack
no flags Details | Splinter Review
xf86EloReadInput(): fix xserver unresponsiveness during touch (2.04 KB, patch)
2009-10-26 13:28 UTC, Michael Smith
no flags Details | Splinter Review
xf86EloReadInput(): fix xserver unresponsiveness during touch (2.47 KB, patch)
2009-12-15 12:04 UTC, Michael Smith
no flags Details | Splinter Review

Description Christoph Walter 2008-01-17 04:50:30 UTC
We are using the driver together with the following hardware:

(--) Elographics touchscreen is a Intellitouch, connected through a serial link.
(--) The controller is a model E271-2200, firmware revision 1.7.
(--)  Additional features:
(--)    External A/D converter
(--)    Z axis active

The Driver/XServer version is:

(II) Module elographics: vendor="X.Org Foundation"
        compiled for 7.2.0, module version = 1.1.0
        Module class: X.Org XInput Driver
        ABI class: X.Org XInput driver, version 0.7



If you play with a jscrollpane for a few minutes the mouse-events are getting stuck somehow.
I connected a ordinary USB-Mouse to the xserver too and after one or two clicks with this mouse the events came in order again.
This might happen with other jcomponents as well (tested with jdk1.4.2 and 1.6.0.
It seams that if there are a lot of events in a short period of time this happends.
Comment 1 Peter Hutterer 2008-01-28 16:44:25 UTC
can you describe "getting stuck" a bit more detailed?
have you been able to reproduce this problem with other widgets? 

It may be a stuck grab that is caused either in the driver or the widget.
Comment 2 Christoph Walter 2008-01-30 00:00:33 UTC
I haven't done any tests with other widgets then swing/awt/swt but the problem happened with jdk 1.4.2 and 1.6.0.
What happens is that at some point the mouse clicks happen to late. It seams as if the mouse-events are queued but at some point one event doesn't get out of the queue anymore. if you click a button nothing happens but if you click another button the button first clicked gets selected/clicked. this behavior starts if you use the scrollbar a lot or many events are raised at the same time.
Comment 3 Noel 2008-02-03 19:15:59 UTC
Having the same issue, everything appears to point to it being a driver issue as the problem is the same for all applications including gnome desktop. I am not only seeing late button presses but also motion is lagging way behind then catching up once more events are added

Adding option "debuglevel" "5" to the xorg.conf and watching the log file shows the driver reporting the packets of data only as the results are displayed on screen. So when the events are 'stuck' in the queue the log does not yet show any information from the driver. Once additional events are created using the mouse the touch events are processed on screen and the debug information shows at the same time.
Comment 4 Peter Hutterer 2008-02-03 19:47:33 UTC
(In reply to comment #3)
> Having the same issue, everything appears to point to it being a driver issue
> as the problem is the same for all applications including gnome desktop. I am
> not only seeing late button presses but also motion is lagging way behind then
> catching up once more events are added

yes, I agree. if we don't see the same problems from other devices it's most likely the driver. unfortunately, elographics is unmaintained and I don't have a device. So I mostly rely on you to debug. 

> Adding option "debuglevel" "5" to the xorg.conf and watching the log file shows
> the driver reporting the packets of data only as the results are displayed on
> screen. So when the events are 'stuck' in the queue the log does not yet show
> any information from the driver. Once additional events are created using the
> mouse the touch events are processed on screen and the debug information shows
> at the same time.

please get the driver from git master and put a few xf86Msg("....") statements into before xf86Post* calls. this will print out whether the driver actually passes the events on to the DDX.

can you post your log output as you have it now?

Comment 5 Noel 2008-02-04 12:35:48 UTC
Here is a section of the log file with the xf86Msg lines inserted I can include more but obviously there is a large amount of information being outputted

These packets were sent when the cursor was lagging. There appears to be some duplication of packets towards the end. The xf86Msg simply shows the command that is about to be outputted.


Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xEA-->0xBF  0x3-->0xC2  0xA6-->0x68  0x5-->0x6D  0xFF-->0x6C  0x0-->0x6C Expecting checksum 108, got 108
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(1002), v1(1446)
EloConvert: Screen(0) - x(268), y(398)
EloConvert During Fix: Screen(0) - x(268), y(398)
EloConvert After Fix: Screen(0) - x(268), y(398)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(1002), v1(1446)
EloConvert: Screen(0) - x(268), y(398)
TouchScreen: x(1002), y(1446), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xBD-->0x92  0x3-->0x95  0xBE-->0x53  0x5-->0x58  0xFF-->0x57  0x0-->0x57 Expecting checksum 87, got 87
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(957), v1(1470)
EloConvert: Screen(0) - x(255), y(405)
EloConvert During Fix: Screen(0) - x(255), y(405)
EloConvert After Fix: Screen(0) - x(255), y(405)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(957), v1(1470)
EloConvert: Screen(0) - x(255), y(405)
TouchScreen: x(957), y(1470), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x93-->0x68  0x3-->0x6B  0xD0-->0x3B  0x5-->0x40  0xFF-->0x3F  0x0-->0x3F Expecting checksum 63, got 63
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(915), v1(1488)
EloConvert: Screen(0) - x(243), y(410)
EloConvert During Fix: Screen(0) - x(243), y(410)
EloConvert After Fix: Screen(0) - x(243), y(410)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(915), v1(1488)
EloConvert: Screen(0) - x(243), y(410)
TouchScreen: x(915), y(1488), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x6E-->0x43  0x3-->0x46  0xEB-->0x31  0x5-->0x36  0xFF-->0x35  0x0-->0x35 Expecting checksum 53, got 53
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(878), v1(1515)
EloConvert: Screen(0) - x(233), y(418)
EloConvert During Fix: Screen(0) - x(233), y(418)
EloConvert After Fix: Screen(0) - x(233), y(418)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(878), v1(1515)
EloConvert: Screen(0) - x(233), y(418)
TouchScreen: x(878), y(1515), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x49-->0x1E  0x3-->0x21  0x3-->0x24  0x6-->0x2A  0xFF-->0x29  0x0-->0x29 Expecting checksum 41, got 41
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(841), v1(1539)
EloConvert: Screen(0) - x(222), y(425)
EloConvert During Fix: Screen(0) - x(222), y(425)
EloConvert After Fix: Screen(0) - x(222), y(425)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(841), v1(1539)
EloConvert: Screen(0) - x(222), y(425)
TouchScreen: x(841), y(1539), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x26-->0xFB  0x3-->0xFE  0x15-->0x13  0x6-->0x19  0xFF-->0x18  0x0-->0x18 Expecting checksum 24, got 24
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(806), v1(1557)
EloConvert: Screen(0) - x(213), y(430)
EloConvert During Fix: Screen(0) - x(213), y(430)
EloConvert After Fix: Screen(0) - x(213), y(430)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(806), v1(1557)
EloConvert: Screen(0) - x(213), y(430)
TouchScreen: x(806), y(1557), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x6-->0xDB  0x3-->0xDE  0x2D-->0xB  0x6-->0x11  0xFF-->0x10  0x0-->0x10 Expecting checksum 16, got 16
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(774), v1(1581)
EloConvert: Screen(0) - x(203), y(437)
EloConvert During Fix: Screen(0) - x(203), y(437)
EloConvert After Fix: Screen(0) - x(203), y(437)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(774), v1(1581)
EloConvert: Screen(0) - x(203), y(437)
TouchScreen: x(774), y(1581), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xEE-->0xC3  0x2-->0xC5  0x42-->0x7  0x6-->0xD  0xFF-->0xC  0x0-->0xC Expecting checksum 12, got 12
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(750), v1(1602)
EloConvert: Screen(0) - x(197), y(443)
EloConvert During Fix: Screen(0) - x(197), y(443)
EloConvert After Fix: Screen(0) - x(197), y(443)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(750), v1(1602)
EloConvert: Screen(0) - x(197), y(443)
TouchScreen: x(750), y(1602), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xD6-->0xAB  0x2-->0xAD  0x5A-->0x7  0x6-->0xD  0xFF-->0xC  0x0-->0xC Expecting checksum 12, got 12
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(726), v1(1626)
EloConvert: Screen(0) - x(190), y(450)
EloConvert During Fix: Screen(0) - x(190), y(450)
EloConvert After Fix: Screen(0) - x(190), y(450)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(726), v1(1626)
EloConvert: Screen(0) - x(190), y(450)
TouchScreen: x(726), y(1626), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xC2-->0x97  0x2-->0x99  0x69-->0x2  0x6-->0x8  0xFF-->0x7  0x0-->0x7 Expecting checksum 7, got 7
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(706), v1(1641)
EloConvert: Screen(0) - x(184), y(454)
EloConvert During Fix: Screen(0) - x(184), y(454)
EloConvert After Fix: Screen(0) - x(184), y(454)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(706), v1(1641)
EloConvert: Screen(0) - x(184), y(454)
TouchScreen: x(706), y(1641), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xB4-->0x89  0x2-->0x8B  0x75-->0x0  0x6-->0x6  0xFF-->0x5  0x0-->0x5 Expecting checksum 5, got 5
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(692), v1(1653)
EloConvert: Screen(0) - x(180), y(457)
EloConvert During Fix: Screen(0) - x(180), y(457)
EloConvert After Fix: Screen(0) - x(180), y(457)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(692), v1(1653)
EloConvert: Screen(0) - x(180), y(457)
TouchScreen: x(692), y(1653), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xAB-->0x80  0x2-->0x82  0x81-->0x3  0x6-->0x9  0xFF-->0x8  0x0-->0x8 Expecting checksum 8, got 8
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(683), v1(1665)
EloConvert: Screen(0) - x(178), y(461)
EloConvert During Fix: Screen(0) - x(178), y(461)
EloConvert After Fix: Screen(0) - x(178), y(461)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(683), v1(1665)
EloConvert: Screen(0) - x(178), y(461)
TouchScreen: x(683), y(1665), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0xA5-->0x7A  0x2-->0x7C  0x86-->0x2  0x6-->0x8  0xFF-->0x7  0x0-->0x7 Expecting checksum 7, got 7
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(677), v1(1670)
EloConvert: Screen(0) - x(176), y(462)
EloConvert During Fix: Screen(0) - x(176), y(462)
EloConvert After Fix: Screen(0) - x(176), y(462)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(677), v1(1670)
EloConvert: Screen(0) - x(176), y(462)
TouchScreen: x(677), y(1670), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x9F-->0x74  0x2-->0x76  0x8A-->0x0  0x6-->0x6  0xFF-->0x5  0x0-->0x5 Expecting checksum 5, got 5
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(671), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(671), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
TouchScreen: x(671), y(1674), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x9D-->0x72  0x2-->0x74  0x8A-->0xFE  0x6-->0x4  0xFF-->0x3  0x0-->0x3 Expecting checksum 3, got 3
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
TouchScreen: x(669), y(1674), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x9D-->0x72  0x2-->0x74  0x8A-->0xFE  0x6-->0x4  0xFF-->0x3  0x0-->0x3 Expecting checksum 3, got 3
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
TouchScreen: x(669), y(1674), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x9D-->0x72  0x2-->0x74  0x8A-->0xFE  0x6-->0x4  0xFF-->0x3  0x0-->0x3 Expecting checksum 3, got 3
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
TouchScreen: x(669), y(1674), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x82-->0xD5  0x9D-->0x72  0x2-->0x74  0x8A-->0xFE  0x6-->0x4  0xFF-->0x3  0x0-->0x3 Expecting checksum 3, got 3
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
TouchScreen: x(669), y(1674), Stream
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x84-->0xD7  0x9D-->0x74  0x2-->0x76  0x8A-->0x0  0x6-->0x6  0xFF-->0x5  0x0-->0x5 Expecting checksum 5, got 5
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
(II) xf86PostButtonEvent(local->dev, TRUE, 1, state == ELO_PRESS, 0, 2, cur_x, cur_y)
TouchScreen: x(669), y(1674), Release
Entering ReadInput
Entering xf86EloGetPacket with checksum == 170 and buffer_p == 0
buffer_p is 0, Trying to read 10 bytes from link
Read 10 bytes
 0x55-->0xFF  0x54-->0x53  0x84-->0xD7  0x9D-->0x74  0x2-->0x76  0x8A-->0x0  0x6-->0x6  0xFF-->0x5  0x0-->0x5 Expecting checksum 5, got 5
EloConvert Before Fix: Screen(0) - x(-1222409045), y(0)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
EloConvert During Fix: Screen(0) - x(174), y(463)
EloConvert After Fix: Screen(0) - x(174), y(463)
(II) xf86PostMotionEvent(local->dev, TRUE, 0, 2, cur_x, cur_y)
EloConvert: Screen(0) - v0(669), v1(1674)
EloConvert: Screen(0) - x(174), y(463)
(II) xf86PostButtonEvent(local->dev, TRUE, 1, state == ELO_PRESS, 0, 2, cur_x, cur_y)
TouchScreen: x(669), y(1674), Release
Comment 6 Magnus Vigerlof 2008-02-04 13:41:02 UTC
I just looked through the event processing code in this driver (because I saw the mail on xorg-ml, and I had an idea) and I think I noticed a difference from the wacom driver where the X events are generated. We have a limited loop when we are called to process data from the wacom tablet, i.e. for each call we can generate lots of X events. I just can't see such loop in this driver.

Maybe this will cause the events from the driver to pile up if data is coming in too fast? I haven't got one of these either so I can't do much more than giving you hints... Just a though, hopefully it's worth something for you.
Comment 7 Noel 2008-02-06 14:59:56 UTC
(In reply to comment #6)
> I just looked through the event processing code in this driver (because I saw
> the mail on xorg-ml, and I had an idea) and I think I noticed a difference from
> the wacom driver where the X events are generated. We have a limited loop when
> we are called to process data from the wacom tablet, i.e. for each call we can
> generate lots of X events. I just can't see such loop in this driver.
> 
> Maybe this will cause the events from the driver to pile up if data is coming
> in too fast? I haven't got one of these either so I can't do much more than
> giving you hints... Just a though, hopefully it's worth something for you.
> 

Indeed that appears to be the case, I have another touchscreen here that I have setup with the mutouch driver which is originally based on the elographics driver and it is able to pickup multiple packets per loop, I'm modifying the elographics driver to use this type of limited loop. However I'm unsure of how to submit a patch could someone point me in the right direction?
Comment 8 Peter Hutterer 2008-02-06 15:19:28 UTC
(In reply to comment #7)
> Indeed that appears to be the case, I have another touchscreen here that I have
> setup with the mutouch driver which is originally based on the elographics
> driver and it is able to pickup multiple packets per loop, I'm modifying the
> elographics driver to use this type of limited loop. However I'm unsure of how
> to submit a patch could someone point me in the right direction?

Just get the driver from git://anongit.freedesktop.org/git/xorg/driver/xf86-input-elographics and fix it up. Then create a patch and attach it to this bugreport. I'll review and push it.

Magnus, if you have time I'd appreciate it if you could help with the review process.
Comment 9 Peter Hutterer 2008-02-27 15:12:04 UTC
Wrapped ReadInput into a while loop. This should fix it.

Pushed as 72408c2404246b9cb4698bd45be439be8ced3c23
Comment 10 Peter Hutterer 2008-05-08 17:03:25 UTC
*** Bug 15875 has been marked as a duplicate of this bug. ***
Comment 11 Peter Hutterer 2008-05-08 17:04:44 UTC
Reopening due to Bug 15875.

Cliff:
I don't actually have a device so you need to help me here.
Comment 12 William Brack 2008-05-20 21:12:55 UTC
I tried to use this driver on an Advantech PPC-L106 (Geode system with touchscreen), using a modified Debian Sid system (xorg 7.3+10).  There were two problems.  First, the 'while' around the ReadInput caused the X system to 'hang' as soon as the screen was touched.  There was no appreciable CPU usage, and I was still able to ssh into the system, but I needed to shutdown and restart the system to recover (removing the 'while' fixed this).  Second, there were some coding errors within xf86EloReadInput (when XFREE86_V4 is set) which caused totally incorrect cursor behavior.  I am attaching a patch which only includes the 'while' when the (undefined) compile-time-defined variable GETPACKET_LOOP is present, and fixes the coding errors.

With this patch, my system now works reasonably well.
Comment 13 William Brack 2008-05-20 21:16:02 UTC
Created attachment 16658 [details] [review]
Patch to fix incorrect usage of variables within xf86EloReadInput
Comment 14 Peter Hutterer 2008-05-20 22:18:05 UTC
On Tue, May 20, 2008 at 09:12:55PM -0700, bugzilla-daemon@freedesktop.org wrote:
> --- Comment #12 from William Brack <wbrack@mmm.com.hk>  2008-05-20 21:12:55 PST ---
> I tried to use this driver on an Advantech PPC-L106 (Geode system with
> touchscreen), using a modified Debian Sid system (xorg 7.3+10).  There were two
> problems.  First, the 'while' around the ReadInput caused the X system to
> 'hang' as soon as the screen was touched.  There was no appreciable CPU usage,
> and I was still able to ssh into the system, but I needed to shutdown and
> restart the system to recover (removing the 'while' fixed this).  Second, there
> were some coding errors within xf86EloReadInput (when XFREE86_V4 is set) which
> caused totally incorrect cursor behavior.  I am attaching a patch which only
> includes the 'while' when the (undefined) compile-time-defined variable
> GETPACKET_LOOP is present, and fixes the coding errors.
> 
> With this patch, my system now works reasonably well.

Thanks for the patch. A few questions:

One issue I have with this patch is that it papers over the real issue rather
than fixing it. Previously, we found that we need the while loop to not drop
packets. Now - on some devices - this causes a freeze. I think the correct
bugfix would be to fix xf86EloGetPacket to return if no data is available
rather than playing an #ifdef game. 

The rest of the patch looks fine.
Comment 15 William Brack 2008-05-20 23:02:58 UTC
I accept your point that "papering over" is certainly not a "good" solution, and the #ifdef is quite awkward. My immediate problem was to stop the "hangup" in order to be able to use the touchscreen, and the removal of the "while" allowed that for me.  I also wanted to get the remainder of the fix introduced as quickly as possible, since (for me) the touchscreen was unusable without it.  It's a little difficult for me to test anything other than the h/w which I possess, but I'll see if I can come up with a further suggestion to attempt to solve the more global problem.  Give me a few days - I have a few other unrelated problems with higher urgency.
Comment 16 Peter Hutterer 2008-06-12 01:04:18 UTC
ping?
Comment 17 William Brack 2008-06-14 13:30:28 UTC
Apologies for the slow response - my TODO list keeps growing, so I inserted an 'interrupt' for this task :-).

The problem we are trying to address is that we would like to process multiple packets if they are present, while not "hanging up" if there are no packets currently waiting. The idea of just putting a "while" loop into xf86EloReadInput where it fetches packets is, unfortunately, not sufficient. xf86EloGetPacket uses a blocking read (the file descriptor is opened with blocking input), so calling it when no data is waiting leads to the "hang" which I experienced.

I believe one possible solution is to change
    while (xf86EloGetPacket(priv->packet_buf,
                       &priv->packet_buf_p,
                       &priv->checksum,
                       local->fd) == Success) {
to be
    while (xf86WaitForInput(local->fd, ELO_MAX_WAIT) > 0) {
         if (xf86EloGetPacket(priv->packet_buf,
                       &priv->packet_buf_p,
                       &priv->checksum,
                       local->fd) != Success)
             return;

This seems to work OK for me.

Reading through the code, it looks as though there are several other conditions concerning reading "unexpected" data (too much, too little, superfluous) which could lead to further problems, but all of that is not directly related to this bug. If my TODO list ever empties, I'll try to see if I can do some further cleanup for this driver.
Comment 18 Peter Hutterer 2008-06-15 04:56:23 UTC
Actually, just calling xf86WaitForInput isn't enough, since we might not get
enough bytes to read, so xf86EloGetPacket would hang again. I just had a look
at xf86OpenSerial and found that the socket is opened blocking.

Simply setting the socket nonblocking should fix the issue. 


diff --git a/src/xf86Elo.c b/src/xf86Elo.c
index 6b855a7..400aeb9 100644
--- a/src/xf86Elo.c
+++ b/src/xf86Elo.c
@@ -72,6 +72,8 @@
 #include "xf86Module.h"
 #endif
 
+#include <fcntl.h>
+
 #else /* XFREE86_V4 */
 
 #include <X11/Xos.h>
@@ -1412,6 +1414,8 @@ xf86EloControl(DeviceIntPtr       dev,
        Error("Unable to open Elographics touchscreen device");
        return !Success;
       }
+      SYSCALL(fcntl(local->fd, F_SETFL,
+                  fcntl(local->fd, F_GETFL) | O_NONBLOCK));
 #else
       SYSCALL(local->fd = open(priv->input_dev, O_RDWR|O_NDELAY, 0));
       if (local->fd < 0) {
Comment 19 William Brack 2008-06-15 07:54:16 UTC
This is part of what I was describing as code spots where potentially "reading unexpected data" could lead to problems. However, my proposed change should work OK as long as only "expected" data occurs. I considered setting the socket as non-blocking, but the problem with that is that partial reads (and writes) could (would?) occur, and I'm not convinced the remainder of the code within the module can properly deal with that condition. My mention of "further cleanup" was based upon an intention to implement O_NONBLOCK throughout.
Comment 20 Peter Hutterer 2008-06-16 16:43:49 UTC
The xf86WaitForInput patch has been pushed as
086e9d2056c8fbb5138b54b95f4559acf8f0f158. The patch isn't perfect, but at
least it's less broken than HEAD, which is a win :)

I'm not closing this bug as fixed yet, I'd really like to see proper
non-blocking error handling code.
Comment 21 William Brack 2008-06-16 19:19:36 UTC
Created attachment 17158 [details] [review]
Patch to fix incorrect usage of variables within xf86EloReadInput

Could I also request that you push the remainder of the patch I originally submitted?  Here is a revised version, against HEAD.

Thanks!
Comment 22 Peter Hutterer 2008-06-17 04:09:30 UTC
> --- Comment #21 from William Brack <wbrack@mmm.com.hk>  2008-06-16 19:19:36 PST ---
> Created an attachment (id=17158)
>  --> (http://bugs.freedesktop.org/attachment.cgi?id=17158)
> Patch to fix incorrect usage of variables within xf86EloReadInput

I have some issues with the patch in terms of supported server
versions. The current X server (1.4, 1.5 and git master) do the scaling
themselves, and the call to xf86EloConvert should only happen for older
servers.

#if GET_ABI_MAJOR(XINPUT_ABI) == 0
 //scale
#endif

would be the correct approach here. If you can prepare a patch that includes
this, I'll push it.

That aside, I also just pushed some cleanup fixes, please make sure you get
them before you start preparing your patch.
Comment 23 William Brack 2008-06-17 20:11:04 UTC
Created attachment 17205 [details] [review]
Patch to fix incorrect usage of variables within xf86EloReadInput

Assuming I understood you correctly, here's the modified patch.  Note that, since I'm currently using a "not too cutting-edge" Debian version of the server, I don't have any easy way to test the condition under which xf86EloConvert is not called, but I'll add a full "git" compile onto my (ever-expanding) TODO list :-).

Also note that I reduced the timeout for the new xf86WaitForInput call, because I found that "dragging" the cursor on the touchscreen was unacceptably slow to respond (OK after this reduction).
Comment 24 Peter Hutterer 2008-06-17 21:23:18 UTC
Pushed as  038798931482575adb411129f016e207034e2dee
Comment 25 santosh 2008-10-27 06:35:58 UTC
Anyone made progress to fix it well?
I'm facing this issue even with latest version.

Thanks,
Santosh
Comment 26 Christoph Walter 2008-10-27 07:34:39 UTC
We had this problem until we used the internal com ports for the touchscreen. Are you using some kind of a serialcard?
Comment 27 santosh 2008-10-27 07:50:24 UTC
yes.

(--) Elographics touchscreen is a Intellitouch, connected through a serial link.
(--) The controller is a model E271-2200, firmware revision 1.9.
(--)  Additional features:
(--)    External A/D converter
(--)    Z axis active
Comment 28 Michael Smith 2009-10-26 13:28:36 UTC
Created attachment 30705 [details] [review]
xf86EloReadInput(): fix xserver unresponsiveness during touch

Hi,

The fix in 038798931482575adb411129f016e207034e2dee ensures all bytes are emptied from the OS buffer by looping until xf86WaitForInput returns 0.

But it has a timeout of 1 millisecond, so the X server may block for a while when there's no more data. I'm attaching a patch to get rid of the delay by setting the timeout to 0.

There's also a much longer block (usually 6 to 9 ms) in the read() call. The "Vlim" device option is set to 10, so the read() wants to block until it has a buffer of 10 bytes. At 9600 bps this could take up to 9 ms. I got rid of the Vlim and Vtime options, and the server blocking went away. (There was already code to handle partial buffers.)

Before the patch, glxgears FPS was dropping by about 50% while pressing the touchscreen. Now it's more like 1%.

I'm also suggesting changing the "break" to "continue" when xf86EloGetPacket() returns !Success. This will let the loop continue to drain data from the serial buffer, if there's any left. Usually !Success just means there wasn't a full buffer, but once in a while it could be line noise or something, so we still want to drain it if we can.

Mike
Comment 29 Peter Hutterer 2009-12-13 22:12:53 UTC
Michael, please submit this as a git-formatted patch and I'll push it.

http://wiki.x.org/wiki/Development/Documentation/SubmittingPatches.


If anyone else wants to provide a Tested-by, please do so, I don't have the hardware necessary.
Comment 30 Michael Smith 2009-12-15 12:04:45 UTC
Created attachment 32095 [details] [review]
xf86EloReadInput(): fix xserver unresponsiveness during touch

Resubmitting patch in Git format.
Comment 31 Peter Hutterer 2009-12-15 15:15:19 UTC
Thank you, merged. I'll push this in two days from now, just in case someone
wants to throw in a Tested-by.
Comment 32 Peter Hutterer 2009-12-17 17:12:02 UTC
Pushed as b9531248d1b5d00b2ba941f576fc160ea5e1444b, thanks for the patch.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.