Colored borders around windows after update [duplicate]

NB: Nvidia has released an official fix; please see ByteCommander's answer, my own answer and/or Kaz Wolfe's answer.


Upon waking up Ubuntu 16.04 from Suspend, the following graphical glitches appear around all windows, context menus, and similar:

enter image description here


This is currently known to affect the following NVIDIA cards running the proprietary drivers:

  • NVIDIA GeForce 610M, driver version 375.39, 340.102
  • NVIDIA GT 630M, driver version 375.39
  • NVIDIA GTX 650, driver version 375.39
  • NVIDIA GT 740M, driver version 378.13
  • NVIDIA GTX 745, unknown driver version
  • NVIDIA GTX 850M, driver version 375.39, 378.13
  • NVIDIA GT 940M, driver version 375.39
  • NVIDIA GTX 950M, unknown driver version
  • NVIDIA GTX 960M, driver version 378.13
  • NVIDIA GTX 970, driver version 375.39
  • NVIDIA GTX 970M, driver version 375.39
  • NVIDIA GTX 980 TI, unknown driver version
  • NVIDIA GTX 1060, driver version 375.26, 375.39, 378.09
  • NVIDIA GTX 1070, driver version 378.09

The above above list has been sourced from reports from other users here on AU, this thread, and this thread.

NB: This is be no means an exclusive list. It probably effects nearly all Nvidia cards.

Furthermore, this issue has been replicated on a clean install where the only change was a software update and the installation of the latest NVIDIA drivers.


What is going on, and how can it be resolved?


Solution 1:

NB: This was a temporary workaround until Nvidia released a patched driver. Scroll down to find the other answers with the actual fix. - Android Dev


I have the same issue using GPU: Nvidia GTX 970 with nvidia 375.39 driver on Ubuntu 16.04.2 LTS

I have observed this since a recent upgrade of the nvidia driver. I thus suspect that it is a bug in the driver.

I found an answer on the nvidia board. It is a confirmed bug in the driver and nvidia is apparently already working on it. In the meantime, one can restart compiz with

compiz --replace

to get rid of the artifacts.

The bug is in the Ubuntu bug tracking system including a workaround script to automatically restart compiz after resume.

Solution 2:

UPDATE 2:

Nvidia now also updated their nvidia-375 drivers to version 375.66, which is available from the standard Ubuntu repositories of all currently supported releases.

That means from now on, you should not have to take any special actions any more, except for doing the normal system updates as always. You don't need the driver package from the graphics-drivers PPA if you don't want them.

Here's the changelog excerpt for the package from the main repos on 16.04 regarding this bug:

$ apt changelog nvidia-375=375.66-0ubuntu0.16.04.1

  [...]
    - Fixed a regression that caused corruption in certain
      applications, such as window border shadows in Unity, after
      resuming from suspend.
  [...]

UPDATE:

Nvidia has finally fixed this issue and released a new working driver version: nvidia-381

The solution described in this answer has been updated as well and now suggests to upgrade to this fixed version instead of downgrading to the latest version before the bug. It remains the same procedure though, you just switch out the package names.


Problem cause:

Some of the proprietary Nvidia graphics driver packages for Ubuntu (namely nvidia-375 and nvidia-378) are buggy and produce the white artefacts around window borders that are shown in your screenshots in the question. This happens reproducibly every time you suspend and wake up from that again.

Until around a few days ago, the nvidia-367 package in Xenial's repository was working fine and reliably, but now they updated it and converted it to a transitional package which automatically installs the buggy nvidia-375 version instead.

Solution (updated after bugfix release from Nvidia):

Make sure that you really have a Nvidia graphics card, which is causing the problem, and not one from a different brand that coincidentally misbehaves in a similar way. Installing Nvidia drivers for non-Nvidia graphics cards will do no good.

You can verify this by checking the output of the command below:

lspci -k | grep -iEA3 '3d|vga'

My solution for now is to downgrade from nvidia-375 or nvidia-378 to nvidia-370, which seems to work fine so far.
As Nvidia released a new upgraded driver version nvidia-381 with this bug fixed, we can (and should) install that one instead of downgrading.

This package is not available from the standard repositories, but you can easily get it from a PPA and replace your current driver with it by running the commands below:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt purge nvidia*

sudo apt install nvidia-370
sudo apt install nvidia-381

After you finished that procedure, reboot your computer and test whether you still have any issues. For me they were gone. Good luck.

Solution 3:

This is was a bug in the Nvidia drivers.

Nvidia has been able to reproduce the issue, and they are working on a fix, which will be included in their next driver release. (The fix has now been released, see the below section).

See this thread on the Nvidia developer forums for more information. This bug has also been reported on Launchpad.

Thanks to @Stefan for his great sluthing skills in uncovering this information!


Nvidia has finally released an official fix!

  • The fix comes courtesy of beta driver 381.09 Relevant screenshot from the changelog: enter image description here

  • This driver is not currently in any repositories

  • Until the above changes, you will need to install the new driver manually Update: the 381.09 driver is now in an unofficial repository. You can either install the patched driver from the unofficial PPA, or you can install it manually.

  • UPDATE - FIX NOW IN OFFICIAL REPO:

    Kudos to @ubfan1 for reporting this! See the below section for details


1. Installing the patched [release] driver from the official repo (recommended):

Nvidia pushed an update to their release driver on 05/04/2017, containing, among other things, the bug fix you're looking for. The updated release driver has been given the version 375.66

Since this 375.66 is in the official repository, loading the patched driver is quite simple.

  • If you are currently on the buggy 375.39 version, then all that should be required is a simple:

    sudo apt-get update
    sudo apt-get upgrade
    

  • If you are on the legacy driver, then you should perform a:

    sudo apt-get update
    

    Followed by switching to the new driver version in Additional Drivers:

    enter image description here


  • If you are currently using a manually installed driver, you should uninstall it, reboot, and then perform the steps outlined above.

After rebooting, you should find that your Nvidia driver has been updated to 375.66.


2. If you don't need the newer driver for compatibility with your GPU:*

*Note that this section has been superseded by section #1

If your graphics card is old enough that it is supported by v340 of the driver, there is no need to install a newer version from an unofficial PPA. For people with newer cards like the GTX 9-series or 10-series however, you will need a newer driver.

For convenience, here's a complete list of the cards supported by version 340 of the driver:

GeForce 800M Series (Notebooks):
GeForce GTX 880M, GeForce GTX 870M, GeForce GTX 860M, GeForce GTX 850M, GeForce 845M, GeForce 840M, GeForce 830M, GeForce 825M, GeForce 820M, GeForce 810M

GeForce 700 Series:
GeForce GTX TITAN Z, GeForce GTX TITAN Black, GeForce GTX TITAN, GeForce GTX 780 Ti, GeForce GTX 780, GeForce GTX 770, GeForce GTX 760, GeForce GTX 760 Ti (OEM), GeForce GTX 750 Ti, GeForce GTX 750, GeForce GTX 745, GeForce GT 740, GeForce GT 730, GeForce GT 720, GeForce GT 710, GeForce GT 705

GeForce 700M Series (Notebooks):
GeForce GTX 780M, GeForce GTX 770M, GeForce GTX 765M, GeForce GTX 760M, GeForce GT 755M, GeForce GT 750M, GeForce GT 745M, GeForce GT 740M, GeForce GT 735M, GeForce GT 730M, GeForce GT 720M, GeForce GT 710M, GeForce 720M, GeForce 710M, GeForce 705M

GeForce 600 Series:
GeForce GTX 690, GeForce GTX 680, GeForce GTX 670, GeForce GTX 660 Ti, GeForce GTX 660, GeForce GTX 650 Ti BOOST, GeForce GTX 650 Ti, GeForce GTX 650, GeForce GTX 645, GeForce GT 645, GeForce GT 640, GeForce GT 635, GeForce GT 630, GeForce GT 620, GeForce GT 610, GeForce 605

GeForce 600M Series (Notebooks):
GeForce GTX 680MX, GeForce GTX 680M, GeForce GTX 675MX, GeForce GTX 675M, GeForce GTX 670MX, GeForce GTX 670M, GeForce GTX 660M, GeForce GT 650M, GeForce GT 645M, GeForce GT 640M, GeForce GT 640M LE, GeForce GT 635M, GeForce GT 630M, GeForce GT 625M, GeForce GT 620M, GeForce 610M

GeForce 500 Series:
GeForce GTX 590, GeForce GTX 580, GeForce GTX 570, GeForce GTX 560 Ti, GeForce GTX 560 SE, GeForce GTX 560, GeForce GTX 555, GeForce GTX 550 Ti, GeForce GT 545, GeForce GT 530, GeForce GT 520, GeForce 510

GeForce 500M Series (Notebooks):
GeForce GTX 580M, GeForce GTX 570M, GeForce GTX 560M, GeForce GT 555M, GeForce GT 550M, GeForce GT 540M, GeForce GT 525M, GeForce GT 520M, GeForce GT 520MX

GeForce 400 Series:
GeForce GTX 480, GeForce GTX 470, GeForce GTX 465, GeForce GTX 460 SE v2, GeForce GTX 460 SE, GeForce GTX 460, GeForce GTS 450, GeForce GT 440, GeForce GT 430, GeForce GT 420, GeForce 405

GeForce 400M Series (Notebooks):
GeForce GTX 485M, GeForce GTX 480M, GeForce GTX 470M, GeForce GTX 460M, GeForce GT 445M, GeForce GT 435M, GeForce GT 425M, GeForce GT 420M, GeForce GT 415M, GeForce 410M, GeForce 405M

GeForce 300 Series:
GeForce GT 340, GeForce GT 330, GeForce GT 320, GeForce 315, GeForce 310

GeForce 300M Series (Notebooks):
GeForce GTS 360M, GeForce GTS 350M, GeForce GT 335M, GeForce GT 330M, GeForce GT 325M, GeForce GT 320M, GeForce 320M, GeForce 315M, GeForce 310M, GeForce 305M

GeForce 200 Series:
GeForce GTX 295, GeForce GTX 285, GeForce GTX 280, GeForce GTX 275, GeForce GTX 260, GeForce GTS 250, GeForce GTS 240, GeForce GT 230, GeForce GT 240, GeForce GT 220, GeForce G210, GeForce 210, GeForce 205

GeForce 200M Series (Notebooks):
GeForce GTX 285M, GeForce GTX 280M, GeForce GTX 260M, GeForce GTS 260M, GeForce GTS 250M, GeForce GT 240M, GeForce GT 230M, GeForce GT 220M, GeForce G210M, GeForce G205M

GeForce 100 Series:
GeForce GT 140, GeForce GT 130, GeForce GT 120, GeForce G100

GeForce 100M Series (Notebooks):
GeForce GTS 160M, GeForce GTS 150M, GeForce GT 130M, GeForce GT 120M, GeForce G 110M, GeForce G 105M, GeForce G 103M, GeForce G 102M

GeForce 9 Series:
GeForce 9800 GX2, GeForce 9800 GTX/GTX+, GeForce 9800 GT, GeForce 9600 GT, GeForce 9600 GSO, GeForce 9600 GSO 512, GeForce 9600 GS, GeForce 9500 GT, GeForce 9500 GS, GeForce 9400 GT, GeForce 9400, GeForce 9300 GS, GeForce 9300 GE, GeForce 9300 SE, GeForce 9300, GeForce 9200, GeForce 9100

GeForce 9M Series (Notebooks):
GeForce 9800M GTX, GeForce 9800M GTS, GeForce 9800M GT, GeForce 9800M GS, GeForce 9700M GTS, GeForce 9700M GT, GeForce 9650M GT, GeForce 9650M GS, GeForce 9600M GT, GeForce 9600M GS, GeForce 9500M GS, GeForce 9500M G, GeForce 9400M G, GeForce 9400M, GeForce 9300M GS, GeForce 9300M G, GeForce 9200M GS, GeForce 9100M G

GeForce 8 Series:
GeForce 8800 Ultra, GeForce 8800 GTX, GeForce 8800 GTS 512, GeForce 8800 GTS, GeForce 8800 GT, GeForce 8800 GS, GeForce 8600 GTS, GeForce 8600 GT, GeForce 8600 GS, GeForce 8500 GT, GeForce 8400 GS, GeForce 8400 SE, GeForce 8400, GeForce 8300 GS, GeForce 8300, GeForce 8200, GeForce 8100 /nForce 720a

GeForce 8M Series (Notebooks):
GeForce 8800M GTX, GeForce 8800M GTS, GeForce 8700M GT, GeForce 8600M GT, GeForce 8600M GS, GeForce 8400M GT, GeForce 8400M GS, GeForce 8400M G, GeForce 8200M G, GeForce 8200M

Quadro Series:
Quadro K6000, Quadro K5200, Quadro K5000, Quadro K4000, Quadro K4200, Quadro K2200, Quadro K2000, Quadro K2000D, Quadro K620, Quadro K600, Quadro K420, Quadro 6000, Quadro 5000, Quadro 4000, Quadro 2000, Quadro 2000D, Quadro 600, Quadro 410, Quadro 400

Quadro Series (Notebooks):
Quadro K5100M, Quadro K5000M, Quadro K4100M, Quadro K4000M, Quadro K3100M, Quadro K2100M, Quadro K3000M, Quadro K2000M, Quadro K1100M, Quadro K1000M, Quadro K610M, Quadro K510M, Quadro K500M, Quadro 5010M, Quadro 5000M, Quadro 4000M, Quadro 3000M, Quadro 2000M, Quadro 1000M

Quadro FX Series:
Quadro CX, Quadro FX 370, Quadro FX 370 Low Profile, Quadro FX 380, Quadro FX 380 Low Profile, Quadro FX 570, Quadro FX 580, Quadro FX 1700, Quadro FX 1800, Quadro FX 3700, Quadro FX 3800, Quadro FX 4600, Quadro FX 4700 X2, Quadro FX 4800, Quadro FX 5600, Quadro FX 5800

Quadro FX Series (Notebooks):
Quadro FX 3800M, Quadro FX 3700M, Quadro FX 3600M, Quadro FX 2800M, Quadro FX 2700M, Quadro FX 1800M, Quadro FX 1700M, Quadro FX 1600M, Quadro FX 880M, Quadro FX 770M, Quadro FX 570M, Quadro FX 380M, Quadro FX 370M, Quadro FX 360M

Quadro NVS Series:
Quadro NVS 290, Quadro NVS 295, NVS 510, NVS 315, NVS 310, NVS 300, Quadro NVS 420, Quadro NVS 450

Quadro NVS Series (Notebooks):
NVS 5400M, NVS 5200M, NVS 5100M, NVS 4200M, NVS 3100M, NVS 2100M, Quadro NVS 320M, Quadro NVS 160M, Quadro NVS 150M, Quadro NVS 140M, Quadro NVS 135M, Quadro NVS 130M

Quadro Plex Series:
Quadro Plex Model II, Quadro Plex D Series, Quadro Plex Model IV, Quadro Plex 7000

Quadro Sync Series:
Quadro Sync, Quadro G-Sync II

Quadro SDI:
Quadro SDI

GRID Series:
GRID K2, GRID K520

NVS Series:
Quadro NVS 290, Quadro NVS 295, NVS 510, NVS 315, NVS 310, NVS 300, Quadro NVS 420, Quadro NVS 450

NVS Series (Notebooks):
NVS 5400M, NVS 5200M, NVS 5100M, NVS 4200M, NVS 3100M, NVS 2100M, Quadro NVS 320M, Quadro NVS 160M, Quadro NVS 150M, Quadro NVS 140M, Quadro NVS 135M, Quadro NVS 130M

ION (Desktops):
ION

ION (Notebooks):
ION

ION LE (Desktops):
ION LE

ION LE (Notebooks):
ION LE

So, if your GPU is supported by 340, then you can simply switch to version 340 in Additional Drivers. (Version 340 does not have this bug.)

enter image description here

Be sure to reboot after switching the driver version.


3. To install the patched [beta] driver from an unofficial PPA (recommended):

  1. Fire up a terminal with CTRL+ALT+T

  2. Run these commands:

    sudo -i
    add-apt-repository ppa:graphics-drivers/ppa
    apt-get update
    apt-get install nvidia-381
    
  3. Reboot your computer, and you should be good to go! After your computer reboots, open Nvidia X Server Settings. With any luck, you'll see the new driver version:

    enter image description here


4. To manually install the patched [beta] driver (NOT recommend):

Installing the Nvidia drivers from the *.run file is generally not a very good idea. It tends to break things. Thus, it is better to install them from a PPA, as described above. Nevertheless, if you're adventures and want to install them manually, this is the process that worked for me with Ubuntu 16.04 and a GTX650.

Before installing the patched driver, you MUST uninstall your current proprietary driver and switch to the Nouveau driver:

enter image description here

Make sure to reboot after switching. IF YOU FAIL TO UNINSTALL YOUR CURRENT PROPRIETARY DRIVER, THE NEW DRIVER WILL CONFLICT WITH THE OLD ONE AND YOU WILL BREAK THINGS!

  1. Download the patched driver file from Nvidia. Here's a direct link.

  2. Save the file to your downloads folder

  3. Log out from your GUI session (You should end up on the login screen before continuing)

  4. Fire up tty1 with CTRL+ALT+F1

  5. Login with your normal credentials

  6. Run these commands:

    sudo service lightdm stop
    cd Downloads
    chmod +x NVIDIA-Linux-x86_64-381.09.run
    sudo ./NVIDIA-Linux-x86_64-381.09.run
    
  7. Accept the license agreement:

    enter image description here

  8. It will complain that the distribution-provided pre-installer script failed. Continue anyway:

    enter image description here

  9. Select Yes when asked if you'd like to register the kernel module with dkms:

    enter image description here

  10. Select Yes when asked if you'd like to install the 32-bit compatibility libraries:

    enter image description here

  11. It will take a while to build the kernel module, so be patient!

    enter image description here

  12. Select Yes when asked if you'd like to run nvidia-xconfig:

    enter image description here

  13. Select Ok to exit the installer

  14. Almost there! Now just run these commands:

    rm ~/.Xauthority
    rm ~/.config/dconf/unity
    sudo shutdown -r now
    
  15. After your computer reboots, open Nvidia X Server Settings. With any luck, you'll see the new driver version:

    enter image description here

Solution 4:

This issue is present in 375 and 378 drivers...


Given that simply killing compiz process fixes the bad border problem, I have tested a solution that works on my Ubuntu 16.04 system every time after the system wakes.

Step 1:

I created a script called fixbadborders in the directory /lib/systemd/system-sleep. It contained the following:

#!/bin/sh
## This file (or a link to it) must be in the folder /lib/systemd/system-sleep/
## Purpose: Kill compiz after system wakes up from sleep.
## This will fix bad window borders caused by Nvidia driver 375.39.
kill $(ps -C compiz -o pid=)

Step 2:

Allowed the script to have execute permission with:

sudo chmod +x fixbadborders

To remove this script:

sudo rm /lib/systemd/system-sleep/fixbadborders

All credits go to Sun Bear who created this script comment 13

Solution 5:

NVIDIA has released an updated driver version that has fixed this regression. Any driver past 381.09 will now no longer have this issue, until NVIDIA messes up again.

Until such time as the driver reaches the main repositories, they can be downloaded from the unofficial NVIDIA driver PPA. Doing this ensures that you won't need to mess with the installer (which is widely considered a bad idea) or Nouveau. Similarly, it will allow the drivers to be installed/uninstalled through apt instead of the dangerous half-configuration the NVIDIA installer leaves drivers in. Furthermore, this will not cause any login loops or errors unless you have a weird system. To install, run:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-381

The old drivers will automatically be uninstalled and the new ones will be loaded in. Follow up by rebooting your computer (as NVIDIA drivers need to be baked into the kernel), and everything should work just fine. You can check that the drivers were installed correctly by running the below command:

nvidia-settings --version

Be sure to revert any patches described in this post before you update to the latest drivers. For example, if you installed the patched version of Unity as described below, run this command to revert back to the normal version:

sudo ppa-purge ppa:kaihengfeng/lp1292830 

Do note that you will need ppa-purge installed, which can be done like so:

sudo apt install ppa-purge

If updating is not an option (too old of a card, company policy, etc):

Kai-Heng Feng of Launchpad has been kind enough to upload a version of Unity to his own PPA (ppa:kaihengfeng/lp1292830) that should patch this issue. In order to resolve this problem, just add his PPA by running these commands:

sudo add-apt-repository ppa:kaihengfeng/lp1292830 
sudo apt update
sudo apt full-upgrade

After you're done, reboot your system or restart X11 by logging out and then back in.

Alternatively, you can also do any of the following:

  • Switch to the Intel card
    If you're running NVIDIA Prime, you can swap over to the Intel card, which will resolve this issue. Note, however, that it will prevent the system from using full graphics power.
  • Downgrade Drivers
    According to some comments on the bug-report, downgrading to NVIDIA driver 367.57 should resolve the issue completely. As this is no longer present in the PPAs, you'll need to download it directly from NVIDIA (64-bit) (32-bit) (32-bit ARM).