Updated: March 19, 2021
Now, don't be snarky. The title of this article does not imply you fix tearing with Intel graphics, but rather, if you happen to have a computer with Intel graphics, and use Linux, then you may have encountered video tearing, usually horizontal lines across the top third of a video frame. This usually happens in the Gnome, Xfce or MATE desktops, less so in Plasma, regardless of the underlying choice of distribution. Consistency ftw.
Anyway, I've seen this problem many times before - but it seems to have resurfaced with somewhat greater frequently recently. So let's have a little tutorial that will hopefully fix all your woes, or at least, allow you to enjoy smooth, clear video playback. After me.
Intel graphics
Before we solve the problem, we need to understand it. In the Solution section below, I am going to write all sorts of technobabble, and if you just blindly copypaste, you will fix the issue, but you won't know why. So let's start with the overview of the Intel graphics stack. This refers to the transitional driver named "intel" - which covers a huge range of different chipsets.
Now, please note that the linked man page refers to the X.Org (Xorg) display server implementation. Indeed, this guide focuses on Xorg for two reasons. One, I primarily use that, rather than Wayland. Two, partially because, see previous point, I've mostly encountered tearing under Xorg. However, I do recall also seeing video tearing under Wayland, and I will consider writing a separate tutorial for that, too. Now, let's continue with our mini education.
Video tearing usually results from a mismatch between your display and the driver, so you end up seeing the refresh of frames. You can create custom Xorg configurations that override the default behavior, so that you make use of specific features in the graphics stack that are not enabled (or disabled) by default.
Now, everything listed in the linked overview can affect video rendering in some way, and the investigatory work here is by no means trivial. After a lot of reading (and some guesswork), I narrowed down the list to one potential main culprit. So let's see what gives.
- Option "TearFree" "boolean" - Disable or enable TearFree updates. This option forces X to perform all rendering to a backbuffer prior to updating the actual display ... This option is disabled by default, but you may want to enable it. This means more video memory used, but you should also have a smoother playback.
OK, now that we know the potential tweak, we can implement it. Indeed, to resolve the problem, we will create a Xorg configuration file that overrides the defaults.
Solution
We need to create a custom configuration file:
sudo mkdir -p /etc/X11/xorg.conf.d
sudo touch /etc/X11/xorg.conf.d/20-intel.conf
Open this file in a text editor (with sudo or as root), and add the following text:
Section "Device"
Identifier "Intel Graphics"
Driver "XXXX"
Option "TearFree" "true"
EndSection
Replace XXXX with the the correct driver name for your specific hardware. You can use the generic intel, or the exact driver version. For example, on one of my laptops, the driver is i915, so the section becomes:
Section "Device"
Identifier "Intel Graphics"
Driver "i915"
Option "TearFree" "true"
EndSection
There are many ways to check what driver is in use on your system:
sudo lspci -k | grep -EA3 'VGA|3D|Display'
grep "LoadModule" /var/log/Xorg.0.log
Alternatively, you can also check using the inxi command:
inxi -G
Graphics:
Device-1: Intel Haswell-ULT Integrated Graphics driver: i915 v: kernel
Display: x11 server: X.Org 1.20.8 driver: i915 resolution: 1366x768~60Hz
OpenGL: renderer: Mesa DRI Intel HD Graphics 4400 (HSW GT2)
v: 4.5 Mesa 20.0.4
There could be some variation between systems, as some Linux distributions will keep logs under /var, while others may have them stored under /run. Moreover, the inxi command might not be available or installed. The lspci command is your safest best, and it should work on every system.
Once you have the driver identified, write the driver name in the 20-intel.conf file, save the file, and restart your session. You can reboot, or just log out and then log back in. Now, you should have a smooth and tear-free video playback.
Alternative fixes
It is possible that just the one Option line we added above does not work. So you might need to be a little more rigorous. Here are two additional options that may want to include in the 20-intel.conf file:
- Option "AccelMethod" "string" - Select acceleration method. There are a couple of ... This option defines the hardware acceleration method. UXA (Unified Acceleration Architecture) is an older but more mature backend. SNA (SandyBridge's New Acceleration) is the new method, which supersedes UXA, and is the default. If you have video tearing, you may want to fall back to the older backend, as it could offer wider overall compatibility.
- Option "DRI" "string" - Disable or enable DRI support ... Normally, this shouldn't be a problem, and your system should use OpenGL ES 3. However, if you have video tearing, then you may may want to set this option to "3".
The configuration file then becomes:
Section "Device"
Identifier "Intel Graphics"
Driver "XXXX"
Option "TearFree" "true"
Option "AccelMod" "uxa"
Option "DRI" "3"
EndSection
Conclusion
Add ... I've tested the first 20-intel.conf in Ubuntu MATE, Xubuntu and Fedora, in multiple editions of the these distributions. In most cases, the TearFree option is sufficient. One of the distro versions also required the acceleration method. Finally, in just one instance, a standalone DRI option (without the other two) resolved the tearing issue. My recommendation is, given that there's quite a range of graphics cards, to try any which permutation of these three options. It's sounds a little like witchcraft, and perhaps it is.
At least it is witchcraft with good results. Ideally, you should never ever have to face any tearing in your videos. But the Linux desktop has several cardinal problems, and user-centric, product-centric approach is the biggest of them, which is why bugs will come and go and then return, and you will have an erratic, random manifestation of these across distros, versions and hardware platforms. Anyway, try, see what gives, and hopefully, you will be able to watch videos with smooth, clean playback. I shall see you around.
Cheers.