Fix Screen Tearing on Ubuntu with Nvidia Graphics Card
Watch this video to check whether you have a screen tearing issue: https://www.youtube.com/watch?v=MfL_JkcEFbE
First, please check if this solution works on your computer.
nvidia-settings, open "X Server Display Configuration", select your screen (if you have multiple monitors like me), click the "Advanced..." button in the bottom, click on the "Force Full Composition Pipeline" checkbox, and then click the "Apply" button.
If after you apply this setting, the issue disapper, then you can move on. Otherwise, please consider to find another solution.
Now, the problem is solved. But if you restart your computer, you will find the issue appear again. So we need to make this change permanent.
Create a script called
nvidia-force-full-compositon.sh, and put these codes in it:
#!/bin/bash nvidia-settings --assign CurrentMetaMode="$(nvidia-settings -q CurrentMetaMode -t|tr '\n' ' '|sed -e 's/.*:: \(.*\)/\1\n/g' -e 's/}/, ForceCompositionPipeline = On, ForceFullCompositionPipeline=On}/g')" > /dev/null
Save, and give it x permission by
chmod +x nvidia-force-full-compositon.sh.
Now, go to
~/.config/autostart/ directory, create a new file called
nvidia-force-full-compositon.desktop, and put these codes in it (you need to change
/path/to/your/script to the actual path of the shell script you just created):
[Desktop Entry] Type=Application Name=nvidia-force-full-compositon Exec=/path/to/your/script
And we are done. The script will be executed every time you boot your machine.