[Kubuntu 18.04] Persistent tearing/screen refresh problem in KWin and nvidia

Bug #1758685 reported by YAFU on 2018-03-25
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
kwin (Ubuntu)
Undecided
Unassigned

Bug Description

Kubuntu 18.04 64bits
GTX 960
==
$ uname -a
Linux yafu 4.15.0-12-generic #13-Ubuntu SMP Thu Mar 8 06:24:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
==
$ sudo dpkg -l | grep -i nvid

ii libnvidia-cfg1-390:amd64 390.42-0ubuntu1 amd64 NVIDIA binary OpenGL/GLX configuration library
ii libnvidia-common-390 390.42-0ubuntu1 all Shared files used by the NVIDIA libraries
ii libnvidia-compute-390:amd64 390.42-0ubuntu1 amd64 NVIDIA libcompute package
ii libnvidia-compute-390:i386 390.42-0ubuntu1 i386 NVIDIA libcompute package
ii libnvidia-decode-390:amd64 390.42-0ubuntu1 amd64 NVIDIA Video Decoding runtime libraries
ii libnvidia-decode-390:i386 390.42-0ubuntu1 i386 NVIDIA Video Decoding runtime libraries
ii libnvidia-encode-390:amd64 390.42-0ubuntu1 amd64 NVENC Video Encoding runtime library
ii libnvidia-encode-390:i386 390.42-0ubuntu1 i386 NVENC Video Encoding runtime library
ii libnvidia-fbc1-390:amd64 390.42-0ubuntu1 amd64 NVIDIA OpenGL-based Framebuffer Capture runtime library
ii libnvidia-fbc1-390:i386 390.42-0ubuntu1 i386 NVIDIA OpenGL-based Framebuffer Capture runtime library
ii libnvidia-gl-390:amd64 390.42-0ubuntu1 amd64 NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii libnvidia-gl-390:i386 390.42-0ubuntu1 i386 NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii libnvidia-ifr1-390:amd64 390.42-0ubuntu1 amd64 NVIDIA OpenGL-based Inband Frame Readback runtime library
ii libnvidia-ifr1-390:i386 390.42-0ubuntu1 i386 NVIDIA OpenGL-based Inband Frame Readback runtime library
ii nvidia-compute-390 390.42-0ubuntu1 amd64 NVIDIA computing metapackage
ii nvidia-compute-no-dkms-390 390.42-0ubuntu1 amd64 NVIDIA computing metapackage - no DKMS
ii nvidia-compute-utils-390 390.42-0ubuntu1 amd64 NVIDIA compute utilities
ii nvidia-dkms-390 390.42-0ubuntu1 amd64 NVIDIA DKMS package
ii nvidia-driver-390 390.42-0ubuntu1 amd64 NVIDIA driver metapackage
ii nvidia-kernel-source-390 390.42-0ubuntu1 amd64 NVIDIA kernel source package
ii nvidia-prime 0.8.6 all Tools to enable NVIDIA's Prime
ii nvidia-settings 390.42-0ubuntu1 amd64 Tool for configuring the NVIDIA graphics driver
ii nvidia-utils-390 390.42-0ubuntu1 amd64 NVIDIA driver support binaries
ii xserver-xorg-video-nvidia-390 390.42-0ubuntu1 amd64 NVIDIA binary Xorg driver
==============
=====

Hello, since many versions of Kubuntu/KWin this problem of tearing/flickering/bad refresh screen/screen synchronization when using nvidia proprietary drivers persists. The problem is that when there are fast changes in screen, you can see annoying horizontal lines/flashes. For example in videos, fast scrolling in web browsers, or applications such as Blender 3D. In Blender 3D the problem is easily verifiable and visible, simply open default cube scene, rotate the view with middle mouse button making one vertex on top of the cube to be in front of you, then quickly zoom in and out with the mouse wheel.

Even though this has been reported many times and marked as solved, but it has never really been solved.

The only thing that has worked for me and solves the problem (I use it since Kubuntu 14.04) is this workaround:
https://www.muylinux.com/2014/02/25/corregir-sincronizacion-tearing-nvidia-kde/

which consists of copying the following lines within this file kate "/etc/profile.d/kwin.sh":
export __GL_YIELD="USLEEP"
export KWIN_TRIPLE_BUFFER=1
===
Edit:
According to this, apparently it is not advisable to use both lines at the same time:
https://devtalk.nvidia.com/default/topic/828962/screen-tearing/

At least for me, first line is enough to eliminate tearing.
===

The question is, would it be possible for Kubuntu or nvidia maintainers to apply that workaround by default when you install Kubuntu or nvidia proprietary driver?

Otherwise there are a lot of new Kubuntu users having this problem over the years.

Thank you very much.

YAFU (yafu) wrote :

According to this, apparently it is not advisable to use both lines at the same time:
https://devtalk.nvidia.com/default/topic/828962/screen-tearing/

At least for me, first line is enough to eliminate tearing.

description: updated
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in kwin (Ubuntu):
status: New → Confirmed
Scott Deagan (scott-deagan) wrote :

Are there any other side effects as a result of using __GL_YIELD="USLEEP" or KWIN_TRIPLE_BUFFER=1? Will tearing be prevented on all connected monitors? Is there a performance hit?

At the moment, I'm using the following to get rid of tearing on Kubuntu 18.04:

1. Create file /etc/modprobe.d/zz-nvidia-tearing.conf
2. Add the following line to zz-nvidia-tearing.conf: options nvidia_drm modeset=1
3. sudo update-initramfs -u
4. sudo reboot

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers