Bug 82273 - Cursor corruption using large cursors
Summary: Cursor corruption using large cursors
Status: CLOSED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: DRM/Intel (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: highest blocker
Assignee: Jani Nikula
QA Contact: Intel GFX Bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-07 02:52 UTC by Jan Alexander Steffens (heftig)
Modified: 2016-11-22 08:33 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Xorg log (41.19 KB, text/plain)
2014-08-12 09:24 UTC, Jan Alexander Steffens (heftig)
no flags Details
3.15.y backport of always apply cursors (8.06 KB, patch)
2014-08-13 08:26 UTC, Chris Wilson
no flags Details | Splinter Review

Description Jan Alexander Steffens (heftig) 2014-08-07 02:52:40 UTC
Cursors larger than some size (64×64, I believe) get corrupted.

While I don't have cursor themes that large, GTK3's drag and drop supports setting drag images. When these drag images — composed with the dragging cursor icon — fit into the cursor size limit, the cursor is set to the composed image instead of creating a new window to display the image.

I originally noticed this in Firefox' GTK3 port. I reproduced it using GTK3's testdnd test.

---

To reproduce:

Set cursor theme to Adwaita, with size at least 32. Size 24 is not enough to reproduce.

Get https://git.gnome.org/browse/gtk+/plain/tests/testdnd.c .

Remove the #include "config.h".

Compile using "gcc -o testdnd $(pkg-config --libs --cflags gtk+-3.0) testdnd.c".

Run testdnd.

Start dragging from the "Drag Here" button.

With cursor size at least 32:
When dragging over the "Drag Here" button, the cursor is corrupted.

With cursor size at least 48:
When dragging over the "Drop Here" button, the cursor is corrupted.

---

(For some reason, I had to restart gnome-shell for cursor size changes to apply to the dragging cursors.)

gtk3 3.12.2
gnome-themes-standard 3.12.0

xf86-video-intel 2.99.914-22-g926631e
xorg-server 1.16.0
linux 3.16

Thinkpad X220 (SNB)
Comment 1 Chris Wilson 2014-08-07 11:00:32 UTC
testdnd didn't trigger the issue for me, but it does sound like you should be going from a large cursor to a small one, which does hit a bug:

commit 52c1e64692e3e80826e526dd14aec4bee137a19b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Aug 7 11:34:26 2014 +0100

    sna: Flush cursor width changes
    
    The kernel only sees changes in the cursor width when the cursor handle
    is updated. In the cases where we reuse larger bo for smaller cursors,
    make sure we then reset the cursor handle (even though it has not
    changed) so tht the kernel updates its width.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 2 Jan Alexander Steffens (heftig) 2014-08-08 01:16:06 UTC
Much better now, although not perfect. There's occasional garbage to the right  of the cursor. Is the buffer not getting cleared properly before it's reused?
Comment 3 Chris Wilson 2014-08-08 06:28:48 UTC
Drat, I saw that whilst testing but was looking in the one place. I was looking through for a residual stride problem, but missed the effect of the stride change on the current dirty rectangle.

commit 6f69188cb2959abfb2fcd3f81cd4146aa3876bb5
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Aug 8 07:25:03 2014 +0100

    sna: Clear old cursors when resizing
    
    When changing the stride on a cursor, we have to clear the whole area
    and not just the rectangle outside of our overwritten area.
    
    Reported-by: Jan Alexander Steffens <jan.steffens@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82273
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 4 Jan Alexander Steffens (heftig) 2014-08-12 09:02:51 UTC
While my SandyBridge laptop is fine now, my desktop using Haswell Iris Pro 5200 still suffers from the exact same issue.
Comment 5 Chris Wilson 2014-08-12 09:07:37 UTC
Hmm, double check it has the fixed ddx - the ddx is common for all kernels, but the kernel needs to differentiate between snb and ivb(hsw). However, I haven't spotted an issue with ivb (which should be the same as hsw/gt3e).
Comment 6 Chris Wilson 2014-08-12 09:08:22 UTC
Also does the corruption look the same as before?
Comment 7 Jan Alexander Steffens (heftig) 2014-08-12 09:09:43 UTC
(II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 20080730
(II) intel(0): SNA compiled from 2.99.914-44-gb3138be
(--) intel(0): Integrated Graphics Chipset: Intel(R) Iris(TM) Pro Graphics 5200

Yes, it looks the same as before.

On the desktop, moving the corrupted cursor to another output makes it display properly. When the "fixed" cursor is then returned to the default (smaller) cursor, this one is then displayed corrupted (two half-height cursors side-by-side; looks like a stride issue). This cursor then displays correctly again when moved to another output.
Comment 8 Chris Wilson 2014-08-12 09:12:12 UTC
And can you check whether you see the issue with xf86-video-intel/tests/cursor-test?
Comment 9 Jan Alexander Steffens (heftig) 2014-08-12 09:20:06 UTC
Yes, it does happen.

Cursors with either width or height >64 are corrupted.

With either >=72 and both <=128, the stride is half of what it should be.
With either >=160, the stride is a quarter of what is should be.
Comment 10 Jan Alexander Steffens (heftig) 2014-08-12 09:22:13 UTC
To clarify, it seems that cursors >64x64 get a 128x128 texture with a 64 stride, and cursors >128x128 get a 256x256 texture with a 64 stride.
Comment 11 Chris Wilson 2014-08-12 09:22:35 UTC
Please attach the Xorg.0.log (or equivalent) for the failing machine.
Comment 12 Jan Alexander Steffens (heftig) 2014-08-12 09:24:00 UTC
Created attachment 104486 [details]
Xorg log
Comment 13 Chris Wilson 2014-08-12 09:37:50 UTC
Please check that your 3.15.8 has

commit 4b0e333ee1100e621c5530d368a3029d41131214
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri May 30 16:35:26 2014 +0300

    drm/i915: Always apply cursor width changes

it was marked for stable but only first applied to 3.16-rc1. Fyi, I can't see the patch in either 3.15.8 or 3.15.9.
Comment 14 Jan Alexander Steffens (heftig) 2014-08-12 12:55:48 UTC
If you can't find it in the stable releases, it's not in -zen, either.
Comment 15 Chris Wilson 2014-08-13 08:26:04 UTC
Created attachment 104547 [details] [review]
3.15.y backport of always apply cursors

Please can you quickly test this patch?
Comment 16 Jan Alexander Steffens (heftig) 2014-08-13 08:57:22 UTC
Seems to work properly, thanks.
Comment 17 Chris Wilson 2014-09-12 09:47:59 UTC
Jani, my stable request fell on deaf ears, could you try shepherding this patch into 3.16?
Comment 18 Chris Wilson 2014-09-12 09:54:02 UTC
It's for 3.15. And we are too late. :|
Comment 19 Jani Nikula 2014-09-12 10:47:28 UTC
Sorry, not much I can do since 3.15.y is EOL. Fix is in 3.16 and later.
Comment 20 Jari Tahvanainen 2016-11-22 08:33:32 UTC
Closing resolved+fixed. commit ecb889e for 3.16 and later, patch for 3.15.x verified by reporter.


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.