Fix Screen Tearing In Ubuntu 24.04: A Step-by-Step Guide

by Lucas 57 views

Experiencing screen tearing in Ubuntu 24.04 can be incredibly frustrating, especially when you're trying to enjoy videos or games. Screen tearing manifests as horizontal lines that appear to split the screen, creating a disjointed and visually unappealing effect. This issue occurs when your graphics card outputs frames at a different rate than your monitor's refresh rate. Fortunately, there are several potential solutions to resolve screen tearing in Ubuntu 24.04, ranging from simple configuration tweaks to driver updates. This guide will walk you through various troubleshooting steps to eliminate screen tearing and restore smooth visuals on your system.

Understanding Screen Tearing

Before diving into solutions, it's essential to understand why screen tearing happens. Your monitor has a refresh rate, measured in Hertz (Hz), which indicates how many times per second it updates the image on the screen. Your graphics card also outputs frames per second (FPS). When the FPS doesn't synchronize with the refresh rate, the monitor might display parts of two different frames simultaneously, leading to the tearing effect. This is more noticeable in fast-paced scenes or when there's a lot of motion on the screen. Factors contributing to screen tearing include outdated graphics drivers, incorrect display settings, and the absence of proper synchronization techniques like VSync.

VSync (Vertical Synchronization) is a technology designed to synchronize the frame rate output of your graphics card with the refresh rate of your monitor. When VSync is enabled, the graphics card waits for the monitor to finish its current refresh cycle before sending the next frame. This prevents the monitor from displaying partial frames, thus eliminating screen tearing. However, VSync can sometimes introduce input lag, which might be a concern for gamers. Adaptive VSync and other advanced techniques aim to mitigate this lag while still preventing tearing.

Initial Troubleshooting Steps

Let's start with some basic troubleshooting steps that often resolve screen tearing issues:

  1. Check Your Monitor's Refresh Rate: Ensure that your monitor is set to its native refresh rate. Lower refresh rates can exacerbate screen tearing. To check and adjust the refresh rate in Ubuntu:
    • Go to Settings > Displays. Make sure you are using the monitor's recommended resolution.
    • Look for the Refresh Rate option. Select the highest available refresh rate that your monitor supports.
  2. Restart Your Computer: A simple restart can sometimes resolve temporary glitches that cause screen tearing.
  3. Close Unnecessary Applications: Running too many applications simultaneously can strain your graphics card and lead to performance issues, including screen tearing. Close any programs that you're not actively using.

Enable VSync

Enabling VSync is a common solution for screen tearing. Here's how to enable it in different environments:

Using NVIDIA Settings:

If you have an NVIDIA graphics card, you can use the NVIDIA X Server Settings to enable VSync:

  1. Open NVIDIA X Server Settings. You can usually find it by searching in the applications menu.
  2. Navigate to X Server Display Configuration. Select your display.
  3. Click on Advanced. Look for the Force Composition Pipeline option. Enable it.
  4. Also, check the Force Full Composition Pipeline option if available.
  5. Save the configuration and restart your computer.

Using AMD Settings:

For AMD graphics cards, the process is similar:

  1. Open AMD Radeon Settings. You can find it in the applications menu.
  2. Go to the Graphics tab.
  3. Find the Wait for Vertical Refresh option. Set it to Always On or Enhanced Sync (if available).
  4. Restart your computer.

Using Intel Graphics Settings:

If you're using integrated Intel graphics, the settings might be a bit different:

  1. Open Intel Graphics Command Center.
  2. Go to the Display tab.
  3. Look for the Vertical Sync option and enable it.
  4. Restart your computer.

Update Graphics Drivers

Outdated or corrupted graphics drivers are a frequent cause of screen tearing. Updating to the latest drivers can often resolve the issue. Here's how to update drivers in Ubuntu:

Using the Software & Updates Tool:

  1. Open Software & Updates. You can find it by searching in the applications menu.
  2. Go to the Additional Drivers tab.
  3. Select the proprietary driver recommended for your graphics card.
  4. Click Apply Changes and wait for the drivers to install.
  5. Restart your computer.

Using the Command Line:

You can also update drivers using the command line:

  1. Open the Terminal.
  2. Type the following command to update the package list:
    sudo apt update
    
  3. Then, upgrade the system:
    sudo apt upgrade
    
  4. To install specific drivers, you might need to add a PPA (Personal Package Archive). For example, for NVIDIA drivers:
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update
    sudo apt install nvidia-driver-XXX
    
    Replace XXX with the driver version you want to install (e.g., nvidia-driver-535).
  5. Restart your computer.

Configure Compton

Compton is a lightweight compositing manager that can help reduce screen tearing, especially in environments where VSync is not properly enforced. Here's how to install and configure Compton:

  1. Open the Terminal.
  2. Install Compton:
    sudo apt install compton
    
  3. Create a Compton configuration file:
    nano ~/.config/compton.conf
    
  4. Add the following configuration:
    vsync = true;
    unredir-if-possible = true;
    
  5. Save the file and exit the text editor.
  6. Run Compton:
    compton --config ~/.config/compton.conf &
    

To make Compton start automatically on boot, you can add it to your startup applications:

  1. Open Startup Applications. You can find it by searching in the applications menu.
  2. Click Add.
  3. Enter a name (e.g., Compton).
  4. In the Command field, enter compton --config ~/.config/compton.conf.
  5. Click Add.

Try a Different Desktop Environment

Sometimes, screen tearing issues are specific to a particular desktop environment. If you've tried the above solutions and are still experiencing tearing, consider trying a different desktop environment like XFCE, MATE, or KDE Plasma. These environments have different compositing managers and may handle screen synchronization differently.

To install a different desktop environment:

  1. Open the Terminal.
  2. Install the desired desktop environment. For example, to install XFCE:
    sudo apt install xfce4
    
  3. During the installation, you'll be prompted to choose a display manager. Select lightdm or gdm3.
  4. Restart your computer.
  5. At the login screen, select the new desktop environment from the session menu.

Additional Tips and Tricks

  • Check Your Cable: Ensure that you're using a high-quality cable (HDMI or DisplayPort) to connect your monitor to your computer. Faulty cables can sometimes cause display issues.
  • Try a Different Kernel: In rare cases, the Linux kernel itself might be contributing to the problem. Consider trying a different kernel version.
  • Disable Compositing: Some applications have their own compositing settings that might conflict with the desktop environment's compositor. Try disabling compositing in the application's settings.

By following these steps, you should be able to diagnose and resolve screen tearing issues in Ubuntu 24.04. Remember to test each solution individually to identify the root cause of the problem. Good luck, and enjoy smooth, tear-free visuals!