Why is video tearing such a problem in Linux?
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.
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.
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.
The solution is here: Linux Mint 17.3 MATE now comes with Compton.
Just go to
Desktop Settings ->
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:
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.
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.
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
In Peppermint Linux, go to Preferences > Peppermint Control Center, select Desktop Effects and enable “Enable desktop effects” and “Synchronize drawing to the vertical blank”.
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.
Under Ubuntu 18.04 with Mate 1.20.1, I saw nearly no vsync issues on https://www.vsynctester.com/ after setting:
Control panel > Mate tweak > Windows > Window management: Marco (no composite)
(AMD Radeon HD 6450)