18

This is more of KDE than Ubuntu question, but...
I have visible tearing on screen. KDE composition, flash video in Firefox, and simple games like kpat are vsynced, but in steam games and in movies there is a distinct constant tearing. If I turn off vsync everywhere, the tearing is double as noticeable, so it is not just GPU ignoring the settings.
What bugs me most it that I'm having the same problem on many different setups. Does everybody have this problem and nobody cares?
My setup

  • Kubuntu (last few versions) or OpenSuse or Gentoo.
  • KDE 4.12 - 4.13
  • Nvidia GTX 260, 570, TITAN, different driver versions.
  • I watch movies in SMplayer with mplayer2 backend. VLC has the same problem.

What did I try (and it didn't help)

  • Switching on and off in different configurations the Vsync settings in nvidia-settings and KDE Desktop effects.
  • Switching Mplayer output and direct rendering settings.
  • Turning off Adaptive power mode in nvidia-settings.
  • Turning off compositing
  • Changing monitor Hz
  • Running mplayer from CLI
  • Performing rituals and sacrifices

What did work (but is not and acceptable solution)

  • Disabling KDE, and running Mplayer in pure X session
  • Switching to nouveau AND turning off composition AND opening video in fullscreen - without any part it is still tearing.

Please advice.

UPDATE 1 I found out that if I go to Desktop Effects -- Advanced and change there anything valuable (OpenGL version, scaling algorythm) and push Apply, the tearing is gone until reboot. However, no setting solves this once and for all. After reboot I have to go and change something again.I guess it is enough to blame this on a bug, not my mistakes, so I will file out bug report.

bain
  • 11,260

6 Answers6

9

The source of problem was (of course) faulty nvidia drivers. The solution is simple. Add environmental variables:

export __GL_YIELD="USLEEP"
export __GL_THREADED_OPTIMIZATIONS=1

somewhere before X starts. System-wide /etc/profile/ works fine.

terdon
  • 100,812
  • 2
    This didn't help in 14.04 nor 16.04 – Giovanni Toraldo Jul 20 '16 at 06:31
  • I put these two lines in /etc/profile.d/noscreentearing.sh and when rebooting the system crashed, rendering it unable to reboot, it now only starts up on cold boots. Removing the file again didn't fix the issue but while it's there it at least prevents screen tearing. – Lampe2020 Jun 21 '23 at 19:35
8

Simple guide to solve this annoying problem :)

  1. Create file:

    /etc/profile.d/Tearing.sh
    
  2. Insert this code:

    export __GL_YIELD="USLEEP"
    
  3. Then make it executable with:

    chmod +x /etc/profile.d/Tearing.sh
    
  4. Once that's done, reboot or press ctrl + alt + F2, login and run sudo service lightdm restart Or restart what ever your display manager is.

The GL_YIELD worked for me, and now vertical sync appears to be working as it should.

(https://www.kubuntuforums.net/showthread.php?63946-No-vertical-sync-with-NVIDIA&highlight=tearing)

7

I have tried all the tricks and nothing solved on Ubuntu 15.04 (along with xorg-edgers and nvidia-355) , until I came on nvidia archlinux page.

Test with:

nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"

In order to make the change permanent, you need to add the following line to the "Screen" section of your Xorg configuration file, for example in /etc/X11/xorg.conf.d/20-nvidia.conf

Option  "metamodes" "nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"
  • 1
    Copying and pasting the same answer to many questions is not very good. You should have marked as duplicate, the fact that these questions have answers already. Thanks :) – Mitch Aug 14 '15 at 11:49
  • Thanks, I was experiencing tearing, and the other solutions (like setting the __GL_YIELD variable) did not work. Also, I had previously experienced trouble with setting the Xorg file, but the above command line worked successfully. I will try adding the command line to my ~/.xprofile. It's a hack, but it should work. – Chris Sep 06 '15 at 23:31
  • Worked in Mint 17, just needed to generate xorg.conf (as it is deprecated and nothing usefull in xorg.conf.d) after stopping mdm with "Xorg -configure" and remove subsections "Display" in generated file, adding the line above did the trick. Thanks. – tomasb Mar 01 '16 at 19:57
  • This worked for me on Xubuntu 16.04, but after running the command my second monitor gets no signal anymore and when I check the nVidia X Server Settings, it says that it's disabled. Is there some way to fix that? – comfreak Feb 17 '17 at 13:02
5

I had it nailed...

So - first of all be sure to check if the problem persists after you switch the Desktop Effects off (Alt+Shift+F10). I can guarantee that the problem might already be gone.

Go to System Settings and open Desktop Effects:

  • Scaling Method to something else than set currently <-- actual fix

I know the options might not be named exactly as above. Sorry about that, but I am using the Polish version of Kubuntu.

The steps above fixed the problem for me. But only after a fresh install. :)

EDIT: In the current 14.04 Kubuntu version the problem is connected with the Scaling Method. Changing it to anything else than currently selected, helps to resolve the problem TEMPORARILY.

  • I have tried setting "Scaling Method to Smooth" alone and it seemed to solve the problem! But I will wait the weekend before closing the answer. Tearing disappeared for sometime already and appeared again, and what's more, that "smooth" thing should have no effect on when movie plays. Weird. Even spooky, you know. – Barafu Albino Apr 28 '14 at 18:55
  • So it seems to be this: When I change scale method to anything, tearing disappears. But after reboot, it is back, and I have to change it again to something different. – Barafu Albino Apr 29 '14 at 19:26
  • This fixed the issue for me. I think not all of the steps were necessary, but together they seem to have it covered and I'm getting beautiful hd video performance (in VLC) in both window and maximized mode. The combination of the nvidia settings plus disabling desktop effects also fixed it, but this way I can leave desktop effects enabled. Also I installed the ubuntu restricted extras package previously - not sure if this came into play or not. – gregtzar Aug 09 '14 at 01:11
  • And I can "guarantee" that if you turn your monitor off the problem "might" be gone as well :) No offense man but if the problem just "might" be gone there is no guaranty at all. Anyways my point is that this is not acceptable resolution for me and probably many others however it may help if one wants just to watch one movie and not to spend much time on it. – tomasb Mar 01 '16 at 12:51
0

Removing NVIDIA driver solved for me. For XFCE, the only thing that helped was replacing the window manager.

0

I tried every suggestion to try and fix the screen tearing while watching videos in Unity, Gnome, and Gnome Classic on two computers (one with Nvidia Titan X and the other with an old Radeon card). Nothing worked.

Then I noticed that when I switched the video output in my VLC setting from OpenGL to X11, the tearing went away but I started getting a lot of random black/white squares or "noise".

To get video playback to work, I installed Lubuntu Desktop which uses OpenBox instead of OpenGL. Lubuntu is a Ubuntu derivative that has LXDE installed by default. It is extremely lightweight and perfect for running in the background while you use Kodi and Steam, or just watch videos.

Window tearing may occur while dragging windows quickly, but this doesn't matter to me in this situation since I solely use Kodi and Steam in full screen mode on this computer.

Run the following command to install both Lubuntu’s customized LXDE and vanilla LXDE on Ubuntu:

sudo apt-get install lubuntu-desktop

Use this command instead to install only vanilla LXDE:

sudo apt-get install lxde

You can also give LXDE a spin by downloading a Lubuntu live CD.

Each environment differs only in its default settings. They come with different themes, wallpapers and panel layouts. For example, the Chromium browser is the default on Lubuntu, while Mozilla Firefox is the default on vanilla LXDE. Of course, you can use any browser you like with either. They both use the PCManFM file manager, a lightweight replacement for the Nautilus file manager found in GNOME.

After installing either package, log out and select either the Lubuntu or LXDE session from the login screen.

My videos never looked better than in Lubuntu. I was able to bump my frequency up to 120Hz to match my TV. The playback was remarkably smooth for 1920x1080p.

guttermonk
  • 1,004
  • 14
  • 29
  • OpenBox instead of OpenGL? Are they for the same task? – jarno Oct 06 '15 at 06:15
  • No, I'm suggesting you use a compositing window manager, like Openbox, that doesn't use OpenGL. https://en.m.wikipedia.org/wiki/Compositing_window_manager – guttermonk Oct 06 '15 at 10:10
  • Xfce4 uses Thunar as file manager by default, not PCManFM. – jarno Oct 09 '15 at 20:43
  • Running LXDE did not stop video tearing in Chromium browser when playing YouTube. I have Intel graphics, and ubuntu 14.04. – jarno Oct 09 '15 at 20:45
  • @Jarno, XFCE was a typo. I've edited it and replaced it with LXDE. Regarding the screen tearing, did you try a different browser? Do you have screen tearing when you play video files off your hard drive? – guttermonk Oct 13 '15 at 21:53
  • Yes I did. Tearing in Firefox ended after I did this. There is no tearing, when I play video from hard drive using a media player. – jarno Oct 15 '15 at 13:17