Screen Tearing with Nvidia Graphics

After the latest nvidia graphics update (440) I have been having a lot of issues with screen tearing using the nvidia graphics. Reverting to a previous driver version did not help either. When this problem first started I was using Manjaro Mate (a community version) but have since then reinstalled Manjaro using KDE. I am using an Acer laptop and I use optimus manager to switch between intel and nvidia graphics. Everything is fine when using the intel graphics, the screen tearing only occurs when I switch to nvidia. I've tried fixing the issue by tweaking my compositor but non of the settings for v-sync seem to change anything. (I'm using the standard compositor for KDE). When I look in my server x settings it shows that Synchronization is off but doesn't give me an option to fix it. Any help on this issue would be much appreciated.

Another thing I found pretty weird is that when I run glxgears, it tells me that its using vertical synchronization but gives me wildly large numbers in the thousands.

Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
40697 frames in 5.0 seconds = 8139.366 FPS
41371 frames in 5.0 seconds = 8274.179 FPS
40609 frames in 5.0 seconds = 8121.736 FPS
X connection to :0 broken (explicit kill or server shutdown).

My system is as follows:

System:    Kernel: 5.4.6-2-MANJARO x86_64 bits: 64 compiler: gcc v: 9.2.0 
           parameters: BOOT_IMAGE=/boot/vmlinuz-5.4-x86_64 root=UUID=19307f62-3917-4576-9d7f-e52fb1dd0ee5 rw quiet apparmor=1 
           security=apparmor resume=UUID=b4b3b32e-f9a9-41dc-9e6a-04b5704dd1db udev.log_priority=3 
           Desktop: KDE Plasma 5.17.4 tk: Qt 5.14.0 wm: kwin_x11 dm: SDDM Distro: Manjaro Linux 
Machine:   Type: Laptop System: Acer product: Aspire E5-576G v: V1.29 serial: <filter> 
           Mobo: KBL model: Ironman_SK v: V1.29 serial: <filter> UEFI: Insyde v: 1.29 date: 07/21/2017 
Battery:   ID-1: BAT1 charge: 41.7 Wh condition: 46.5/62.2 Wh (75%) volts: 12.8/11.1 model: PANASONIC AS16B5J type: Li-ion 
           serial: <filter> status: Charging 
CPU:       Topology: Quad Core model: Intel Core i5-8250U bits: 64 type: MT MCP arch: Kaby Lake family: 6 model-id: 8E (142) 
           stepping: A (10) microcode: CA L2 cache: 6144 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 28808 
           Speed: 800 MHz min/max: 400/3400 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 800 5: 801 6: 800 7: 800 8: 800 
           Vulnerabilities: Type: itlb_multihit status: KVM: Split huge pages 
           Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable 
           Type: mds mitigation: Clear CPU buffers; SMT vulnerable 
           Type: meltdown mitigation: PTI 
           Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl and seccomp 
           Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization 
           Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB filling 
           Type: tsx_async_abort status: Not affected 
Graphics:  Device-1: Intel UHD Graphics 620 vendor: Acer Incorporated ALI driver: i915 v: kernel bus ID: 00:02.0 
           chip ID: 8086:5917 
           Device-2: NVIDIA GP108M [GeForce MX150] vendor: Acer Incorporated ALI driver: nvidia v: 440.44 bus ID: 01:00.0 
           chip ID: 10de:1d10 
           Display: x11 server: X.Org 1.20.6 driver: modesetting,nvidia compositor: kwin_x11 resolution: 1920x1080~60Hz 
           OpenGL: renderer: GeForce MX150/PCIe/SSE2 v: 4.6.0 NVIDIA 440.44 direct render: Yes 
Audio:     Device-1: Intel Sunrise Point-LP HD Audio vendor: Acer Incorporated ALI driver: snd_hda_intel v: kernel 
           bus ID: 00:1f.3 chip ID: 8086:9d71 
           Sound Server: ALSA v: k5.4.6-2-MANJARO 
Network:   Device-1: Intel Dual Band Wireless-AC 3168NGW [Stone Peak] driver: iwlwifi v: kernel port: 4000 bus ID: 03:00.0 
           chip ID: 8086:24fb 
           IF: wlp3s0 state: up mac: <filter> 
           Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Acer Incorporated ALI driver: r8169 
           v: kernel port: 3000 bus ID: 04:00.1 chip ID: 10ec:8168 
           IF: enp4s0f1 state: down mac: <filter> 
Drives:    Local Storage: total: 2.05 TiB used: 131.61 GiB (6.3%) 
           ID-1: /dev/sda vendor: Seagate model: ST2000LX001-1RG174 size: 1.82 TiB block size: physical: 4096 B logical: 512 B 
           speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: SDM1 scheme: GPT 
           ID-2: /dev/sdb vendor: Micron model: 1100 MTFDDAV256TBN size: 238.47 GiB block size: physical: 512 B logical: 512 B 
           speed: 6.0 Gb/s serial: <filter> rev: A020 scheme: GPT 
Partition: ID-1: / raw size: 704.51 GiB size: 692.46 GiB (98.29%) used: 131.56 GiB (19.0%) fs: ext4 dev: /dev/sda3 
           ID-2: swap-1 size: 2.00 GiB used: 0 KiB (0.0%) fs: swap swappiness: 60 (default) cache pressure: 100 (default) 
           dev: /dev/sda6 
Sensors:   System Temperatures: cpu: 65.0 C mobo: N/A gpu: nvidia temp: 52 C 
           Fan Speeds (RPM): N/A 
Info:      Processes: 210 Uptime: 17m Memory: 7.66 GiB used: 1.77 GiB (23.1%) Init: systemd v: 242 Compilers: gcc: 9.2.0 
           alt: 8 Shell: bash v: 5.0.11 running in: konsole inxi: 3.0.37

What about these things?
https://wiki.archlinux.org/index.php/NVIDIA/Troubleshooting#Avoid_screen_tearing
https://wiki.manjaro.org/index.php?title=Configure_NVIDIA_(non-free)_settings_and_load_them_on_Startup
:warning:Oh.. and this:
https://wiki.archlinux.org/index.php/NVIDIA_Optimus#Tearing/Broken_VSync

It has been reported that linux kernel 5.4 breaks PRIME synchronization.

I'll look more into these links... It may be the kernel update as I updated both the kernel and the graphics drivers around the same time. I might try reverting to a slightly older kernel version until the next update but first Ill look into the links.

Yes you might want to go back to 5.3 or 4.19 for the time being

Damn, that sucks, Thanks for the tip though, most of what I found online myself led to stuff just different enough from my actually scenario that it wasnt entirely useful.

Edit: There is an experimental 5.5 kernel available, might look into that as well.

5.4 kernels break prime synchronization, @philm added the new patch that fixes it earlier today. not sure when that will make it to stable branch. check to see if you have any updates available.

if you check xrandr --prop output, "PRIME Synchronization" should show "1" but without the patch it will show "0" (not working) and thats why you get tearing/stuttering and high glxgears fps results.

1 Like

Thanks for the tip.

I do get PRIME Synchronization: 0

I'll have to look more into this thread but this does seem to be the issue I am having.

Edit: Looking at the thread, Im a little bit confused on how to install the patch.

instead of doing that, you could either switch to the testing branch and run an update. or manually pull the needed kernel and nvidia packages from your preferred mirror (testing branch)

download these to a directory.

kernel and headers
https://mirror.math.princeton.edu/pub/manjaro/testing/core/x86_64/linux54-5.4.10-1-x86_64.pkg.tar.zst
https://mirror.math.princeton.edu/pub/manjaro/testing/core/x86_64/linux54-headers-5.4.10-1-x86_64.pkg.tar.zst

nvidia packages
https://mirror.math.princeton.edu/pub/manjaro/testing/extra/x86_64/linux54-nvidia-440xx-440.44-10-x86_64.pkg.tar.zst
https://mirror.math.princeton.edu/pub/manjaro/testing/extra/x86_64/nvidia-440xx-utils-440.44-3-x86_64.pkg.tar.xz
https://mirror.math.princeton.edu/pub/manjaro/testing/multilib/x86_64/lib32-nvidia-440xx-utils-440.44-1-x86_64.pkg.tar.xz

open a terminal in that directory, (replace pkg1.tar.xz with actual file names)

sudo pacman -U pkg1.tar.xz pkg2.tar.xz

After updating this way i still get the same PRIME Synchronization: 0 from before and screen tearing - I have tried both methods mentioned - sorry for the delayed response, I had some other stuff to do before continuing this
Edit: For now I'm just reverting to kernel 5.3 as everything works on it, I will try again later

Have you tried to enable "Force full composition pipeline?
I don't use prime, only using one nvidia card , but this option fixed the screen tearing for me.

maybe the patched nvidia drivers weren't pushed yet to the testing repo. either way it should be soon, for now use 5.3 which works fine.

Unfortunately when using prime that option isnt available in the server x options

Mmm yeah, well thanks anyway, I'll just have to check back in on it in a little while

Forum kindly sponsored by