Bug 32734

Summary: Lost damage with compiz
Product: xorg Reporter: Vladimir <lomov.vl>
Component: Driver/intelAssignee: Chris Wilson <chris>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: major    
Priority: medium CC: corsac, freedesktop, kibi, lool, nassau, stefan, tsdh, xovni
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=351357
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
The mc running in urxvt, exist dialog. Version 2.13.902
none
The mc running in urxvt, after swapping panels. Version 2.13.902
none
Emacs window. See the cursor blank box in minibuffer line (not a rectangle). Version 2.13.902
none
The mc running in urxvt. Version 2.13.901
none
The Emacs window. See the cursor box in minibuffer line (here rectangle). Version 2.13.901
none
xrandr --verbose output
none
Video BIOS dump
none
dmesg outpu (without drm.debug=0x06)
none
intel_gpu_dump output (xz compressed)
none
X log. Version 2.13.901
none
screenshot of Emacs using the Dina font (a bitmap font): no corruption
none
screenshot of Emacs using the Andale Mono font (TTF): corruption on almost any change
none
rxvt-unicode, vim, xft:montecarlo: corruption none

Description Vladimir 2010-12-29 23:36:51 UTC
Created attachment 41515 [details]
The mc running in urxvt, exist dialog. Version 2.13.902

Hi.

My system:

Software: Archlinux x86_64, mesa, intel-dri, libdrm compiled from git repo, xorg 1.9, kernel-zen (stable).

Hardware: Asus X58L, Intel Duo T5450, GMA 3100 gfx.

With xf86-video-intel of 2.13.902 version some applications have a corrupted windows (I don't know how to say in other words what I see). With version 2.13.901 those applications are Ok.

See attached screenshots.
Comment 1 Vladimir 2010-12-29 23:38:39 UTC
Created attachment 41516 [details]
The mc running in urxvt, after swapping panels. Version 2.13.902
Comment 2 Vladimir 2010-12-29 23:40:09 UTC
Created attachment 41517 [details]
Emacs window. See the cursor blank box in minibuffer line (not a rectangle). Version 2.13.902
Comment 3 Vladimir 2010-12-29 23:41:56 UTC
Created attachment 41518 [details]
The mc running in urxvt. Version 2.13.901
Comment 4 Vladimir 2010-12-29 23:42:59 UTC
Created attachment 41519 [details]
The Emacs window. See the cursor box in minibuffer line (here rectangle). Version 2.13.901
Comment 5 Vladimir 2010-12-30 00:33:59 UTC
Sorry, forgot:

$ uname -r
2.6.36-zen2-ARCH-00183-gf4774cf

Display:
LVDS-1
Comment 6 Vladimir 2010-12-30 00:35:51 UTC
Created attachment 41520 [details]
xrandr --verbose output
Comment 7 Vladimir 2010-12-30 00:36:30 UTC
Created attachment 41521 [details]
Video BIOS dump
Comment 8 Vladimir 2010-12-30 00:37:46 UTC
Created attachment 41522 [details]
dmesg outpu (without drm.debug=0x06)
Comment 9 Vladimir 2010-12-30 00:50:31 UTC
Created attachment 41523 [details]
intel_gpu_dump output (xz compressed)
Comment 10 Chris Wilson 2010-12-30 03:48:21 UTC
Mind adding lspci or Xorg.log so that I check the PCI ID rather than relying on an extremely confusion marketing name?
Comment 11 Vladimir 2010-12-30 19:45:50 UTC
I again forgot something...

$ sudo lspci -v
...
00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 03)
	Subsystem: ASUSTeK Computer Inc. Device 1017
	Flags: bus master, fast devsel, latency 0
	Capabilities: [e0] Vendor Specific Information: Len=0a <?>
	Kernel driver in use: agpgart-intel
	Kernel modules: intel-agp

00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (rev 03) (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. Device 14e2
	Flags: bus master, fast devsel, latency 0, IRQ 44
	Memory at feb00000 (64-bit, non-prefetchable) [size=1M]
	Memory at d0000000 (64-bit, prefetchable) [size=256M]
	I/O ports at ec00 [size=8]
	Expansion ROM at <unassigned> [disabled]
	Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
	Capabilities: [d0] Power Management version 3
	Kernel driver in use: i915
	Kernel modules: i915

00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (rev 03)
	Subsystem: ASUSTeK Computer Inc. Device 14e2
	Flags: bus master, fast devsel, latency 0
	Memory at fe900000 (64-bit, non-prefetchable) [size=1M]
	Capabilities: [d0] Power Management version 3
...(In reply to comment #10)
> Mind adding lspci or Xorg.log so that I check the PCI ID rather than relying on
> an extremely confusion marketing name?
Comment 12 Vladimir 2010-12-30 19:47:07 UTC
Created attachment 41540 [details]
X log. Version 2.13.901
Comment 13 Sébastien Luttringer 2011-01-08 20:06:04 UTC
issue is still present on 2.14.0.
Comment 14 Vladimir 2011-01-08 23:36:20 UTC
I tried with new kernel (2.6.37) shipped with Archlinux (x86_64)
xorg-server: 1.9.3.901,
xf86-video-intel: from git,
mesa: from git,
the problem still there.

Again, version 2.13.901 works fine.
Comment 15 Vladimir 2011-01-11 21:36:26 UTC
(In reply to comment #14)
> I tried with new kernel (2.6.37) shipped with Archlinux (x86_64)
> xorg-server: 1.9.3.901,
> xf86-video-intel: from git,
> mesa: from git,
> the problem still there.
> 
> Again, version 2.13.901 works fine.

Seems I figured out the condition and programs that have weird behavior.

First of all, I tried xf86-video-intel beginning from 2.12.0 version up to 2.14.0. The strange behavior of programs listed below begins with 2.13.902 version.

Currently my system has:
xorg-server: 1.9.3.901
kernel: 2.6.37 and 2.6.36 (tried with both)
xcompmgr: 1.1.5

Most of time I use urxvt terminal (rxvt-unicode compiled with 256 color support), emacs (compiled from bzr), mc (compiled from git) and gvim (provided by distro). These programs use a filled box as a cursor.

Test 1: install xf86-video-intel 2.14, run urxvt (1), mc in urxvt (2), gnome-terminal (3), emacs (4) and gvim (5). Run them under pure openbox session WITH xcompmgr running.
(1): the cursor is missing;
(2): mc has artifacts (my origin post);
(3): fine, a filled cursor is shown, mc runs fine (without artefacts);
(4): the same artifacts as in my first post (weird behavior of cursor while on some characters in minibuffer, for example, when open a file), artifacts in main window while scrolling a text file;
(5): cursor is fine but when open a text file and scroll it artifacts are appers.

Other terminal emulators (roxterm, lxterminal, terminal) work fine (like gnome-terminal). Also a test text file opened in gedit was displayed fine.

Test 2: the same but WITHOUT xcompmgr (or just killed): problems are vanished except urxvt.

P.S. Though tests with urxvt and emacs I run now under openbox session the same behavior was when I run them under KDE session.
Comment 16 Vladimir 2011-01-12 00:32:33 UTC
UPD: when urxvt is started as
urxvt -depth 0
(from manual:
-depth bitdepth
           Compile xft: Attempt to find a visual with the given bit depth; resource depth.

           [Please note that many X servers (and libXft) are buggy with respect to "-depth 32" and/or alpha channels, and will cause all sorts of
           graphical corruption. This is harmless, but we can't do anything about this, so watch out]
)
WITHOUT running xcompmgr problem with mc running inside urxvt is gone.

But I'm not sure how this is related with emacs and gvim.
Comment 17 Tassilo Horn 2011-01-12 23:39:05 UTC
I have the same (or at least very similar) display corruption in Emacs X11 buffers after upgrading to xf86-video-intel-2.14.0 on my Gentoo laptop.  After updating mesa from 7.9.1 to 7.10 the situation slightly improved, but still there are some artifacts.

I use kwin with compositing as window manager.

The bug is also tracked at Gentoo:

  https://bugs.gentoo.org/show_bug.cgi?id=351357
Comment 18 Taras Shpot 2011-01-31 12:17:44 UTC
Created attachment 42772 [details]
screenshot of Emacs using the Dina font (a bitmap font): no corruption
Comment 19 Taras Shpot 2011-01-31 12:18:45 UTC
Created attachment 42773 [details]
screenshot of Emacs using the Andale Mono font (TTF): corruption on almost any change
Comment 20 Taras Shpot 2011-01-31 12:30:23 UTC
I have a similar issue with Arch Linux on a laptop with integrated Intel graphics.

I took screenshots of emacs -Q (no user config) with hl-line-mode (highlight current line) to illustrate the artifacts better.
With compositing enabled:
bitmap font: no problem
https://bugs.freedesktop.org/attachment.cgi?id=42772
TTF font: artifacts after almost any action (in this case, moving the cursor up and down)
https://bugs.freedesktop.org/attachment.cgi?id=42773

After disabling compositing the problem goes away.
Also, the urxvt + mc problem described reproduces here.

mesa/intel-dri 7.10
xf86-video-intel 2.14
uname -r: 2.6.37-ARCH

lspci -v:
00:00.0 Host bridge: Intel Corporation Mobile 4 Series Chipset Memory Controller Hub (rev 09)
	Subsystem: Fujitsu Technology Solutions Device 113f
	Flags: bus master, fast devsel, latency 0
	Capabilities: [e0] Vendor Specific Information: Len=0a <?>
	Kernel driver in use: agpgart-intel
	Kernel modules: intel-agp

00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])
	Subsystem: Fujitsu Technology Solutions Device 113f
	Flags: bus master, fast devsel, latency 0, IRQ 42
	Memory at f2400000 (64-bit, non-prefetchable) [size=4M]
	Memory at d0000000 (64-bit, prefetchable) [size=256M]
	I/O ports at 1800 [size=8]
	Expansion ROM at <unassigned> [disabled]
	Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
	Capabilities: [d0] Power Management version 3
	Kernel driver in use: i915
	Kernel modules: i915

00:02.1 Display controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09)
	Subsystem: Fujitsu Technology Solutions Device 113f
	Flags: bus master, fast devsel, latency 0
	Memory at f2100000 (64-bit, non-prefetchable) [size=1M]
	Capabilities: [d0] Power Management version 3
Comment 21 Chris Wilson 2011-01-31 12:35:49 UTC
*** Bug 33253 has been marked as a duplicate of this bug. ***
Comment 22 Chris Wilson 2011-02-03 01:53:07 UTC
Does

commit da990536eca09c6de74627541cd56ecfad925eda
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 3 09:41:48 2011 +0000

    uxa: Undo damage translation before appending
    
    The region is used to paint onto the backing pixmap (and thus
    translated) prior to being passed to the damage layer (wrt to the
    drawable). So the local translation needs to be undone first.
    
    Identified by Christopher James Halse Rogers.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33650
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

improve matters? (ROAF confused me, I thought he was talking about this bug...)
Comment 23 Guillaume Ayoub 2011-02-03 10:33:18 UTC
(In reply to comment #22)
> Does 
> commit da990536eca09c6de74627541cd56ecfad925eda
> improve matters? (ROAF confused me, I thought he was talking about this bug...)

Yes, it does for me! No more artifacts with Emacs nor Epiphany. Thank you so much!

For the record:
- Using gentoo with gnome-shell
- xf86-video-intel-2.14.0, mesa-7.10, vanilla-kernel-2.6.37
- Artifacts with Emacs (same as described here by Vladimir), parts of pages not redrawn with Epiphany
- No more artifacts with your (1-line!) patch
Comment 24 Taras Shpot 2011-02-03 11:23:30 UTC
Yes, the patch fixes the artifacts for me.
Thank you!
Comment 25 Vladimir 2011-02-03 19:26:08 UTC
(In reply to comment #22)
> Does
> 
> commit da990536eca09c6de74627541cd56ecfad925eda
> Author: Chris Wilson <chris@chris-wilson.co.uk>
> Date:   Thu Feb 3 09:41:48 2011 +0000
> 
>     uxa: Undo damage translation before appending
> 
>     The region is used to paint onto the backing pixmap (and thus
>     translated) prior to being passed to the damage layer (wrt to the
>     drawable). So the local translation needs to be undone first.
> 
>     Identified by Christopher James Halse Rogers.
> 
>     Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33650
>     Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> improve matters? (ROAF confused me, I thought he was talking about this bug...)

Yes, thanks. This solves problem with urxvt and emacs with working composite manager (xcompmgr).
Comment 26 Loïc Minier 2011-02-04 05:54:57 UTC
FTR, I was getting corruption of the cursor in xterm, and this also fixes it; thanks!
Comment 27 Christian Nassau 2013-10-24 14:21:50 UTC
It seems the fix was not merged in xserver-xorg-video-intel-2.99.904 (the version shipped in ubuntu 13.10). I saw the same problem as described here with display corruption under emacs. 

The problem can be fixed by adding the line 
   pixman_region_translate(&region, -dst_x, -dst_y); 
in the file src/sna/sna_composite.c:

        /* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
         * manually append the damaged regions ourselves.
         */
        pixman_region_translate(&region, -dst_x, -dst_y); // <--- new line
        DamageRegionAppend(&pixmap->drawable, &region);
Comment 28 Chris Wilson 2013-10-24 14:37:28 UTC
No, that is bogus.
Comment 29 Chris Wilson 2013-10-24 14:46:09 UTC
commit 2b6cb1cf45cff2bb4383bd6bf50aec0af8895079
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Oct 24 15:42:12 2013 +0100

    sna: Do not apply drawable offsets to DamageRegionAppend
    
    DamageRegionAppend() will itself apply the drawable offsets, so we need
    to pass it the untransformed region. This also fixes an issue where we
    might fallback without applying any Damage.
    
    Reported-by: Christian Nassau <nassau@nullhomotopie.de>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=32734
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 30 Christian Nassau 2013-10-24 15:04:53 UTC
Well, I could of course reboot my machine with the broken video driver from the original ubuntu 13.10 install and make screenshots of the mess on my Emacs window. I could also post all sorts of log files, lspci output, etc...

But I've got a feeling that none of this will get us past the automatic bogus barrier, so I'll refrain from wasting everybody's valuable time here. For me things work with the patch I posted, so the problem is indeed RESOLVED now.
Comment 31 Christian Nassau 2013-10-24 15:13:37 UTC
I might have misunderstood comment #29, sorry.

If the commit in comment 29 refers to an actual bugfix, then thanks a lot.
Comment 32 Andreas Reis 2013-11-18 00:36:09 UTC
Funny thing, but this 'fix' is actually causing this bug for me, at least with any kind of terminal (tested rxvt-unicode & xterm) when I have a xft font selected (the default non-xft one still works properly).

Tested this by running xf86-video-intel-git (latest commit 6e9a8c5a) with and without this (Oct 24) commit reverted on Xserver 1.14.4 and -git (29240e5c), other deps are git as well. WM is xmonad, compositing is done by compton (git), an actively developed fork of xcompmgr.

It starts relatively innocuous with backspace not updating the line's last character, to quickly deteriorate into the mess as seen in the screenshot once a program like vim is used.

Had to take a horribly grainy screenshot with my tablet since ImageMagick's import apparently skips the faulty composite effects (maybe the fault lies with compton?).

Should I start a new bug?
Comment 33 Andreas Reis 2013-11-18 00:39:01 UTC
Created attachment 89378 [details]
rxvt-unicode, vim, xft:montecarlo: corruption
Comment 34 Chris Wilson 2013-11-18 12:34:51 UTC
Please test with

commit 4194100691347ccec4b1863f3f62987d9286707b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Nov 18 12:33:05 2013 +0000

    sna: Process Damage relative to dst->pDrawable not its pixmap->drawable
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=32734
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 35 Andreas Reis 2013-11-18 19:42:32 UTC
Appears to indeed resolve the issue (for me).
Comment 36 Chris Wilson 2013-11-19 09:50:06 UTC
Sounds good to me...

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.