98

I've used many variants of Linux(mostly Debian derivatives) for over a decade now. One problem that I haven't seen solved satisfactorily is the issue of horizontal tearing, or Vsync not being properly implemented.

I say this because I use used 5 different distros on 4 different computers with various monitors and Nvidia/AMD/ATI/Intel graphics cards; every time, there has been an issue with video tearing with even slight motion.

This is a big problem, especially since even Windows XP doesn't have these issues on modern hardware. If anyone is going to use Linux for anything, why would they want constant defects to show up when doing anything non-CLI?

I'm guessing that either few developers know about this problem or care enough to fix it. I've tried just about every compositor out there, and usually the best they can do is minimize the issue but not eliminate it. Shouldn't it be as simple as synchronizing with the refresh rate of the monitor? Is there some politics among the OSS community that's preventing anyone from committing code that fixes this?

Every time I've asked for help on this issue in the past, it either gets treated as an edge case(which I find difficult to believe it is given the amount of times I've replicated the problem) or I get potential solutions that at most minimize the tearing.

  • 2
    You don't mention which DE you use. KDE has been fine with tearing for a year or so now. – Sparhawk Feb 4 '15 at 5:09
  • 1
    How could one easily replicate the problem? In a Debian/Ubuntu/Mint computer? – Xen2050 Feb 4 '15 at 5:53
  • 49
    This XKCD just seems to fit so well here... – Angew Feb 4 '15 at 14:40
  • My experience with tearing has been completely different. I'm a very happy gaming and watching movies on Linux. Steam has really made Linux a viable platform for great games. I've been playing Witcher 2 and Talos Principle lately, and I haven't seen any tearing in some 50 hours of game play. This is with an Nvidia card with proprietary drivers on Arch. I agree with Xen2050 that this question would be more useful if exact specs were given for your builds. I'm not denying there is a problem, I just have had a very good experience. – labyrinth Feb 4 '15 at 16:28
  • With Nvidia compositing solved the problem for me, when I used to use Nvidia back in 2007. Not in full screen though because full screen windows turn off the compositor, it assumes you're going to run an OpenGL game I think. With Intel, have you tried setting Section "Device" Option "TearFree" "true" in X? It doubles video RAM use but I think it'll work. – Zan Lynx Feb 4 '15 at 23:04
91

This is all due to the fact that the X server is out-dated, ill-suitable for today's graphics hardware and basically all the direct video card communication is done as an extension ("patch") over the ancient bloated core. The X server provides no builtin means of synchronization between user rendering the window and the screen displaying a window, so the content changes in the middle of rendering. This is one of the well-known issues of the X server (it has many, the entire model of what the server does and is outdated - event handling in subwindows, metadata about windows, graphical primitives for direct drawing...). Widget toolkits mostly want to gloss over all this, but tearing is still a problem because there is no mechanism to handle that. Additional problems arise when you have multiple cards that require different drivers, and on top of all this, opengl library has a hard-wired dependency on xlib, so you can't really use it independently without going through X.

Wayland, which is somewhat unenthusiastically trying to replace X, supports a pedantic vsync synchronization in its core, and is advertised to have every frame exactly perfect.

If you quickly google "wayland video tearing" you'll find more information on everything.

  • 38
    +1 for “X is the problem, take a look at Wayland.” Dead serious, it's the correct answer. – HalosGhost Feb 4 '15 at 12:48
  • 2
    @HalosGhost wayland evangelism on the go :) still no network session support? – kagali-san Feb 4 '15 at 14:13
  • 3
    @kagali-san I didn't say Wayland was perfect (it isn't). But it's definitely better than X. :) – HalosGhost Feb 4 '15 at 14:35
  • 8
    @kagali-san: Weston has had its RDP backend merged just a year ago, if you find that somehow relevant to a question about video tearing. – grawity Feb 4 '15 at 22:36
  • 3
    @orion: and thanks to you this very page is now the #1 result for wayland video tearing :P – Tobia Tesan Sep 4 '16 at 10:38
16

Screen tearing appears mostly because of two reasons - drivers that aren't there yet, and lack of vsync with certain window managers.

As for drivers, both free and proprietary drivers support free-tearing compositing (nvidia and amd both). Be aware that e.g. enabling tear-free desktop in catalyst (fglrx) may cause frame drop and lags, so it is usually disabled by default. As for open driver, vsync should be enabled by default. So screen tearing issue may be solved by trying different drivers and configuring them.

As for window managers, it's known that Openbox, Awesome and others lightweight wms don't support tear-free. XFCE (xfwm, to be specific) has fixed it in recent releases, 4.11/12 now have Vsync. Major desktop environments also have no problems with tearing, including GNOME, KDE, Unity and Cinnamon.

If you still experience screen tearing, your option is to try another compositing manager like Compton or Kwin. Kwin is the window manager for KDE and I have experience of using kwin in XFCE when it didn't support vsync and it worked really well.

So the solution here is experimentation, what is broken in one combination of driver/wm can work in another. I believe the situation will improve soon since open-source drivers are becoming more advanced and switching to wayland may get rid of old issues with Xorg.

  • 5
    Not really. KDE (with Kwin or other composer) still tears like hell with NVidia or Intel. – Ivan Feb 4 '15 at 10:56
  • 1
    Openbox etc. do work tear-free - you simply have to run a separate compositor, e.g. compton works wonderfully. – wingedsubmariner Feb 5 '15 at 3:56
  • @wingedsubmariner, when you guys refer to openbox, do you also mean fluxbox? – nass Apr 24 '15 at 10:16
  • also, extremely helpful that you note what is the state of WM in different window environments. – nass Apr 24 '15 at 10:18
  • @nass Absolutely. The window manager is never a limiting factor. – wingedsubmariner Apr 28 '15 at 20:43
13

If you're using an nvidia driver >= 365.20, then try enabling the "Force Full Composition Pipeline" option in nvidia-settings.

enter image description here

  • nVidia Quadro on a Lenovo W520, Fedora 25 and this worked :) – Jerther Dec 29 '16 at 3:32
  • 4
    also if you have no such option, click "advanced settings" at the bottom of the window and it will show up. why this "full composition pipeline" is not enabled by default?.. – Rast Feb 4 '17 at 18:22
  • 1
    @Rast Because it used to have some performance problems. – Ruslan Mar 4 '17 at 16:27
  • BTW, it appears that at least Intel drivers also have a TearFree option you can put into the corresponding Device section. I've just tried it, and it gives results very similar to nvidia's Full Composition Pipeline. – Ruslan Aug 7 '18 at 20:29
  • I can't seem to get the setting to save on reboots I tried creating a ~/.xinitrc file and putting "nvidia-settings --load-config-only & . /etc/X11/xinit/xinitrc" in it but that didn't seem to work – FragmentalStew Feb 5 at 3:46
9

I had a strong tearing here and now it is solved.

After reading this (wonderful explanation) of how an Xorg server works I realized that X server paints window updates directly to the memory card at any random time unless you use a compositing enabled window manager.

When compositing is enabled the window manager put together all the changes from the different window memory buffers, creates a resulting image for the whole screen and dump it to the display card on one shot.

Most modern distributions have a compositing window manager. KWin for KDE, Mutter for Gnome, Muffin for Cinnamon, Marco for Mate, xfwm for XFCE, etc. However compositing could be disabled to save resources.

In my case compositing was disabled in KDE4. Once enabled the tearing went away. EDIT: I also needed to change on KWin options the VSync strategy from Automatic to Reuse screen contents in order to get rid of tearing just as explained in this kwin specific bug report.

The driver options can be also a factor. In my case the default options works ok. Arch Wiki have great documentation about the options for different display cards such as Intel cards or NVIDIA cards.

To check if an option is enabled in your current xorg configuration you can check the log. For example, to check if DRI is enabled:

cat /var/log/Xorg.0.log | grep DRI
  • 1
    On XFCE (in Xubuntu 16.04) compositing is enabled by default but syncing to the vertical blank is not. Use the xfwm4-tweaks-settings command to show the tweaker application and on the Compositor tab you can find the above option. Turning it on made a huge difference, and can be checked here: vsynctester.com/index.html (turn the feature on/off while the displaying the animation). It is not perfect, there are some missed frames though, but much better than when it is turned off. – karatedog Oct 31 '16 at 12:17
1

The solution is here: Linux Mint 17.3 MATE now comes with Compton.

Just go to Desktop Settings -> Windows -> Window Manager and choose Metacity + Compton. That's it.

I have AMD video card and it works out of the box for open source driver.

For proprietary AMD driver, when HTML5 videos are maximized to full screen, you might see blue color that will fill the whole screen. To fix this, create and chmod +x the script below:

#!/bin/bash
killall compton 2> /dev/null
compton -b --unredir-if-possible

Run it whenever you restart the system, but don't try to add it to Startup Applications -- it might break startup for some reason.

0

In Peppermint Linux, go to Preferences > Peppermint Control Center, select Desktop Effects and enable "Enable desktop effects" and "Synchronize drawing to the vertical blank".

0

I am using Linux Mint XFCE and this problem frustrated me for quite a while. I found out solution for my laptop with Intel integrated graphic card and it solved tearing issue. For my desktop with NVIDIA card that trick cant work. But I just have found culprit.

I have sen immediate performance boost when I have disabled window compositing. Heres how you can do that:

Go to All Settings/Window Manager Tweaks/Compositor and disable that whole thing.

Keep in mind that this is distro specific and mine is Mint with XFCE and I have no idea how to find similar thing on other distros.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.