Bug 94560 - [regression, bisected] Xorg 1.18.2 stray cursor appears when some applications are launched maximized on rotated display
Summary: [regression, bisected] Xorg 1.18.2 stray cursor appears when some application...
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/DDX/Xorg (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-15 20:45 UTC by Furkan
Modified: 2016-03-29 01:08 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Photo of stray cursor (731.74 KB, image/jpeg)
2016-03-15 20:46 UTC, Furkan
no flags Details
Xorg log (1.05 MB, text/plain)
2016-03-16 02:53 UTC, Furkan
no flags Details
Xrandr (8.67 KB, text/plain)
2016-03-16 09:43 UTC, Furkan
no flags Details
Bail from xf86_set_cursor_position if the HW cursor is hidden (505 bytes, patch)
2016-03-18 06:51 UTC, Michel Dänzer
no flags Details | Splinter Review
gdb breakpoint commands (137 bytes, text/plain)
2016-03-18 06:55 UTC, Michel Dänzer
no flags Details
gdb output when reproducing issue in ubuntu live ISO (55.92 KB, text/plain)
2016-03-24 02:56 UTC, Furkan
no flags Details
gdb output with breakpoints at drmmode_hide/show_cursor (62.54 KB, text/plain)
2016-03-24 04:33 UTC, Furkan
no flags Details
gdb output with xorg 1.18.1 (138.02 KB, text/plain)
2016-03-24 05:16 UTC, Furkan
no flags Details

Description Furkan 2016-03-15 20:45:14 UTC
I'm using Ubuntu 16.04 Beta, and this bug surfaced after upgrading from Xorg 1.18.1 to 1.18.2. The easiest way for me to trigger it is to launch a Chromium web application which launches maximized on my rotated display. I've also triggered it a couple of times by maximizing a shell window on my rotated display.

The stray cursor is rotated, and only appears on the rotated display. I don't know how to get rid of it other than to restart lightdm.

Attached is a photo (since the screenshot tool doesn't capture the cursor).

I did a bisect, and ended up with:

# first bad commit: [aa8770bf546a58e534ad2d0e0180f7e1013e24e9] xfree86: Re-set current cursor after RandR 1.2 CRTC configuration change

Link to the patch: https://cgit.freedesktop.org/xorg/xserver/commit/?id=b04767c84deafc44993723add4b1c5163fc11711
Comment 1 Furkan 2016-03-15 20:46:44 UTC
Created attachment 122332 [details]
Photo of stray cursor
Comment 2 Michel Dänzer 2016-03-16 01:04:09 UTC
Please attach the Xorg log file corresponding to the problem.
Comment 3 Furkan 2016-03-16 02:53:35 UTC
Created attachment 122334 [details]
Xorg log

Xorg log attached. I'm not sure what's going on with the tons of "GetModeLine" messages that are coming up.
Comment 4 Michel Dänzer 2016-03-16 09:00:31 UTC
Please also attach the output of

 xrandr --verbose

when the problem occurs.


(In reply to Furkan from comment #0)
> I've also triggered it a couple of times by maximizing a shell window on my
> rotated display.

How do you trigger the maximize to reproduce it: Clicking the maximize button, moving the window to the top of the screen, using a keyboard shortcut, ... ? Can you reproduce it the other ways as well?


To clarify, the cursor works correctly on the rotated display for some time before the stray cursor appears, right?
Comment 5 Furkan 2016-03-16 09:43:14 UTC
Created attachment 122337 [details]
Xrandr

I think it might not actually have anything to do with maximizing a window - that could have just been a coincidence. I restarted lightdm a good 15-20 times now and most of the time the stray cursor just appears on its own, and sometimes it doesn't.

But I also noticed that in lightdm I almost always seem to have 2 cursors. When the login screen first loads, there is a cursor hovering over the password field. But then when I move my mouse, a second cursor appears from the edge between the two monitors (the original cursor stays stuck in its place).
Comment 6 Michel Dänzer 2016-03-17 08:21:27 UTC
I'm still unable to reproduce the problem, despite trying many things (went back to 1.18.2 from Git master, installed lightdm, ...).

Does Option "SilkenMouse" "off" work around the problem by any chance?

If not, can you try starting X without rotation and then finding a minimal recipe for making the stray cursor appear? E.g. is simply running something like

 xrandr --output DVI-0 --rotate left --output DVI-1 --right-of DVI-0

enough?
Comment 7 Furkan 2016-03-18 00:45:44 UTC
Option "SilkenMouse" "off" doesn't solve the issue for me.

Running the xrandr command doesn't seem to have any effect either.

However, I booted up into an Ubuntu 16.04 live ISO and was able to reproduce the issue with about 5-10 minutes of work. I did that just to make sure that there wasn't something wrong with my particular configuration. Here are the steps that I followed:

1. Download the Ubuntu 16.04 daily image from here, and boot into it from a USB stick: http://cdimage.ubuntu.com/daily-live/current/

2. Edit /etc/apt/sources.list and add the line "deb-src http://archive.ubuntu.com/ubuntu xenial main universe multiverse restricted" (to let us get the build dependencies for ddx)

3. Run "sudo add-apt-repository ppa:canonical-x/x-staging" (to upgrade from Xorg 1.18.1 to 1.18.2)

4. sudo apt-get update && sudo apt-get dist-upgrade

5. sudo apt-get build-dep xserver-xorg-video-radeon

6. sudo apt-get install git

7. Grab xf86-video-ati from git, and build/install it

8. Use the following /etc/X11/xorg.conf:

Section "Device"
	Identifier "radeon"
	Driver "ati"
	Option "TearFree" "true"
EndSection
Section "Files"
        ModulePath "/opt/xorg/lib/xorg/modules,/usr/lib/xorg/modules"
EndSection

9. Edit /etc/lightdm/lightdm.conf and remove the line "autologin-user=ubuntu" (this is mandatory, you won't be able to reproduce the bug without doing this).

10. Go to the display settings, and rotate your left monitor by 90 degrees. I haven't tested this yet with 1 monitor... only with 2.

11. Run "sudo service lightdm restart"

12. Move your mouse around, and remember where you leave your cursor. Now, log in with user name "ubuntu" and a blank password. After your desktop loads, you'll have a stray cursor right on the spot where you left your mouse before logging in. If this doesn't work on the first try, restart lightdm another 2-3 times for good measure.

Now, if you copy "/home/ubuntu/.config/monitors.xml" to "/var/lib/lightdm/.config/monitors.xml" and restart lightdm again (so that your monitor is rotated by 90 degrees on the lightdm login screen as well), you'll notice that you'll now also have a stray cursor in the lightdm greeter, which is stuck hovering over the password field.
Comment 8 Michel Dänzer 2016-03-18 06:51:18 UTC
Created attachment 122403 [details] [review]
Bail from xf86_set_cursor_position if the HW cursor is hidden

Does this xserver patch help by any chance?
Comment 9 Michel Dänzer 2016-03-18 06:55:28 UTC
Created attachment 122404 [details]
gdb breakpoint commands

If the patch doesn't help, please attach gdb to the Xorg process before the problem occurs and execute the commands in this file (e.g. by passing -x gdb.txt when launching gdb), then reproduce the problem. It should generate a series of backtraces, please attach all of those.
Comment 10 Furkan 2016-03-18 08:17:45 UTC
I just tried your patch, and it seems to eliminate the problem - no more stray cursor, including on the lightdm greeter. I restarted lightdm a good 5-6 times to test it and so far, so good!
Comment 11 Furkan 2016-03-18 18:43:06 UTC
I jumped the gun on this - I had accidentally patched 1.18.1, instead of 1.18.2. The problem is still present after having patched 1.18.2.

Just to clarify, in case there is any confusion: When I set both /var/lib/lightdm/.config/monitors.xml AND /home/furkan/.config/lightdm.xml to enable rotation: (1) at the lightdm login screen, there is a stuck cursor on my primary monitor, over the password field, and (2) after logging in, the stuck cursor switches to my secondary (rotated, positioned to the left) monitor and is rotated.

When I edit /var/lib/lightdm/,config/monitors.xml to disable rotation on the login screen, I'm unable to reproduce the issue. I have no stuck cursor either on the login screen or after logging in.

With the Ubuntu 16.04 live ISO the behaviour was slightly different - with rotation disabled on the login screen, there was no stray cursor at the login screen, but it would still appear after logging in, and the position would be the same as where you last left the cursor on the login screen.

So at the moment, I don't have a way of triggering the stuck cursor "on demand". I just restart lightdm and if it's there from the start, it stays there. But if it's not there, I don't know how to make it appear afterwards. So in that case I'm assuming the gdb output wouldn't be very useful, unless it was from the live ISO?
Comment 12 Michel Dänzer 2016-03-22 03:41:53 UTC
Yes, please get the gdb output from the live ISO.
Comment 13 Furkan 2016-03-24 02:56:17 UTC
Created attachment 122514 [details]
gdb output when reproducing issue in ubuntu live ISO

Here's the gdb output. I obtained it by attaching gdb right before logging in (i.e., before pressing "enter" in the lightdm password field).

The stray cursor is not present on the lightdm greeter (both monitors are set to normal rotation). After logging in, my left monitor goes into rotated mode, and the stray cursor appears on the right screen.
Comment 14 Furkan 2016-03-24 04:33:44 UTC
Created attachment 122515 [details]
gdb output with breakpoints at drmmode_hide/show_cursor
Comment 15 Furkan 2016-03-24 05:16:05 UTC
Created attachment 122516 [details]
gdb output with xorg 1.18.1

When I log in, my cursor gets placed at the edge between the two monitors. My left-hand side monitor has a 1920x1200 resolution, and since it's rotated that means the cursor should be around x=1200. I noticed from the gdb logs above that miPointerSetCursorPosition is being called with x=1919, which of course is wrong.

I reverted to xorg 1.18.1 and ran gdb with the same breakpoints. As you can see, miPointerSetCursorPosition is now being called with x=1199, which is the correct position.
Comment 16 Michel Dänzer 2016-03-24 08:37:33 UTC
After staring at your logs and scratching my head for a while, it finally occurred to me what's happening, and I was able to reproduce it and come up with a fix: https://patchwork.freedesktop.org/patch/78155/
Comment 17 Furkan 2016-03-24 20:51:55 UTC
Sorry about those gdb log files - I didn't realize that gdb was appending to the log file instead of overwriting it. I don't know if you ended up figuring it out, but for each attachment, you'll only want to look at the very last gdb session. If you end up having to look at them again, just search for the 2nd last 'Thread 1 "Xorg" received signal SIGINT, Interrupt.' and ignore everything above that.

I just rebuilt xserver with your patch, and it seems to have fixed the issue. I'll continue to use it and report back if I notice any problems...
Comment 18 Michel Dänzer 2016-03-29 01:08:39 UTC
Fixed in master:

commit 418fe365b45a143680d3b4143dc60f7cdc5a3507
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Mar 24 17:34:23 2016 +0900

    xfree86/modes: Make sure the HW cursor is hidden when it should be


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.