Problems with Chrome browser after suspending the computer on Ubuntu 20.04

30,496

Solution 1

I'm having more or less the same issue, on:

  • Ubuntu 18.04, 64 bit
  • GPU: GeForce GTX 1070
  • Driver: 440.100
  • Chrome Version: 86.0.4240.75 (Official Build) (64-bit)

I don't want to have to deactivate GPU usage for Chrome, and I don't want to have to restart the browser every time, losing all my tabs.

But I found a workaround that is good enough for me (at least for now):

You can kill just the browser's GPU process

  • Open the Task Manager:

    • Hit Shift+Esc (as pointed out by @NYCeyes in the comments).
    • Or alternatively, go to the Chrome main menu (3 dots on the top right corner) → More ToolsTask Manager.
  • Sort by process Task name.

  • Find the process called GPU Process.

  • Click on End process.

Chrome Task Manager - GPU Process - End process

That will "clean" all the glitchy image noise. And Chrome will immediately create a new GPU process automatically.

Note: You can automatize the process, check Andrew Bruce's answer putting these steps in a script that runs automatically.

I assume the problem is something like the GPU process using memory assuming it has the old state as before the sleep cycle, but it just has some default random noise from the default state. So I imagine Ubuntu doesn't save and restore GPU memory on a sleep cycle (I don't think it should) but the Chrome process doesn't detect that. And by killing the process it "frees" that GPU memory and then Chrome creates a new process that re-generates any needed GPU memory state (that's instant).

Solution 2

Same problem for me.

Enabling enable-vulkan in chrome://flags then restarting the browser fixed it. If that does not work, you can also try enabling ignore-gpu-blacklist as well.

Answer based on this old askubuntu answer

Solution 3

Using tiangolo's answer, you can automate the restart of the Chrome GPU process on wake. As root, I put this script in /lib/systemd/system-sleep/revive-chrome-gpu:

#!/bin/sh

set -e

if [ "$2" = "suspend" ] || [ "$2" = "hybrid-sleep" ]
then
    case "$1" in
        pre)
            true 
            ;;
        post) 
            sleep 1
            pkill -f 'chrome \-\-type=gpu-process'
            ;;
    esac
fi

Be sure to make the script executable with:

chmod +x /lib/systemd/system-sleep/revive-chrome-gpu

Solution 4

I have the same issues on Arch, and although enabling Vulkan does fix the glitches when resuming from sleep or hibernation, it also impacts performance a lot. Based on this bug report and this answer I've tried starting Chrome with the following flags: --use-cmd-decoder=validating --use-gl=desktop and this seems to fix my issue without any performance penalties.

I'm not sure if this applies to all distros, but on Arch you can put these arguments into ~/.config/chrome-flags.conf and then they will be used every time Chrome is started (or ~/.config/chromium-flags.conf if using Chromium):

~/.config/chrome-flags.conf
--use-cmd-decoder=validating --use-gl=desktop

Solution 5

1st Solution (performance issues)

In my case a solution for the Chrome browser is disable in Settings: Use hardware acceleration when available.

chrome://settings/system

enter image description here

2nd Solution

Yes, the above solution comes with performance issues. If you don't like that, you can test this other option, Chrome will run flawlessly.

Run Chrome with some flags, run always Chrome by terminal.

google-chrome-stable --use-cmd-decoder=validating --use-gl=desktop &

The & avoid blocking the terminal.

Share:
30,496
christianbueno.1
Author by

christianbueno.1

Updated on September 18, 2022

Comments

  • christianbueno.1
    christianbueno.1 almost 2 years
    • Kubuntu 20.04, 64 bit
    • GPU: Geforce GT610
    • nvidia-driver-390
    • Chrome Version 85.0.4183.83
    • Intel i5-4430, core 4, 4 thread , 3GHz
    • RAM: 16GB

    Each time I go into suspend mode and then resume, Chrome browser displays the current tab as full of sand of colors, something like dithering in image processing.

    screenshot

    Other tabs display glitches too.

    The current solution is to close and reopen the browser.

    I tested nvidia-driver-418 but got a black screen problem and reinstalled nvidia-driver-390.

    The problem is more evident in Chrome, but it sometimes appears in vscode in small areas. There, hovering the mouse over the affected place or resizing the window fixes the problem. In Kubuntu the avatar of the user in the application launcher also shows dithered.

    screenshot

    I tested in the same machine with fedora 32 workstation(gnome), nvidia driver, and had the same problems with Chrome browser.

    ubuntu-drivers output

    Could it be a GPU problem?

    • EraserPencil
      EraserPencil almost 4 years
      Could you see if the solution from askubuntu.com/q/1270689 helps?
    • user3352133
      user3352133 almost 4 years
      Me too, I created a bookmark for chrome://restart so can click it whenever the machine wakes up. Had a new version of Chrome today but it still doing it. I am plain old 20.04 Ubuntu runing on a Dell XPS 17 2020
    • dharmatech
      dharmatech almost 4 years
      Same issue on Ubuntu 20.04.01 on ThinkPad W530. The answer below solved it!
    • SimonAlfie
      SimonAlfie almost 4 years
      This has come in with a recent update, as I had no issues before. I am also seeing issues with kdiff3. Not noticed any issues with VSCode myself, but maybe they are too subtle from me to of noticed yet. Running a Dell XPS 15 with 20.04.
    • Matthew Miller
      Matthew Miller over 3 years
      I just wanted to add that the reason that VSCode experiences issues is because it runs on ElectronJS which further runs on Chromium. As far as I know, FireFox does not experience these problems. Thus, it's an underlying problem in Chromium. I've only had success solving the problem by disabling hardware acceleration although this is not ideal. I think the best course of action is to wait for the problem to be patched at Chromium.
    • AlikElzin-kilaka
      AlikElzin-kilaka over 3 years
      Happens on 19.10 as well. Chrome version: 85.0.4183.121 (Official Build) (64-bit). It started happening after upgrading chrome.
    • AlikElzin-kilaka
      AlikElzin-kilaka over 3 years
    • bain
      bain over 3 years
    • Daniel Rosehill
      Daniel Rosehill over 3 years
      I just upgraded from 20.04 to 20.10 and this issue began. Very annoying as I use the suspend and restore from suspend throughout the day. I have no idea what NVIDIA driver I had before the upgrade, but now it brought me up to Nvidia-driver-450. I manually upgraded to Nvidia-driver-455 hoping that would resolve the issue but no such luck. I'll try adding the Chrome flag. Probably should have stuck with the LTS release!
    • christianbueno.1
      christianbueno.1 over 3 years
      There is no problem in fedora 33 with Nouveau NVD9 open source drivers, it would be very important to test if the problem persist with nouveau in ubuntu.
    • kelalaka
      kelalaka over 3 years
      It seems so many people like me have the same problem. At the moment, the best solution is chrome://restart/
    • Jared Chu
      Jared Chu over 3 years
      The issue is fixed for me on nvidia-driver-455 and Chrome Version 87.0.4280.66 (Official Build) (64-bit)
    • trusktr
      trusktr about 3 years
      There is a similar issue in Chrome's bug tracker: bugs.chromium.org/p/chromium/issues/detail?id=1134981
  • dharmatech
    dharmatech almost 4 years
    Works perfectly! Thank you!!!
  • Dark Templar
    Dark Templar almost 4 years
    This slows down dramatically chrome with 10+ open tabs...
  • xx77aBs
    xx77aBs almost 4 years
    No need to enable ignore-gpu-blacklist. Just enabling Vulkan fixes the issue for me, although chrome does get slow down, especially when multiple windows are open :(
  • xx77aBs
    xx77aBs almost 4 years
    This comes with huge performance penalty, especially when watching videos. If you're on laptop, your batter life will get shortened a lot.
  • Camilo Rada
    Camilo Rada almost 4 years
    Just enabling Vulkan fixed it for me.
  • Diego Rivera
    Diego Rivera almost 4 years
    This is an Arch-specific extension, and is not currently available in other Linux variants (that I know of).
  • christianbueno.1
    christianbueno.1 almost 4 years
    Thanks pal, disabling hardware acceleration reduce the performance. That's flags works better. You can run chrome by terminal google-chrome-stable --use-cmd-decoder=validating --use-gl=desktop &, using & avoid blocking the terminal.
  • Terminal User
    Terminal User almost 4 years
    It fixed the issue. but make chrome really slow when watching youtube.
  • christianbueno.1
    christianbueno.1 over 3 years
    Thanks pal, now in the future when we don't need those flags, how can we revert that?
  • Christian Fritz
    Christian Fritz over 3 years
    You can just stop using the modified .desktop file and use the one installed by the package instead when that happens.
  • AlikElzin-kilaka
    AlikElzin-kilaka over 3 years
    Upvoted. Starting chrome with google-chrome --use-gl=desktop solved the issue. Saw it here as well: askubuntu.com/a/1270843/13330
  • Jared Chu
    Jared Chu over 3 years
    Thanks a lot! It fixed the issue for me. My specs: Ubuntu 20.04, Ryzen 7, RTX 2060.
  • Homero Esmeraldo
    Homero Esmeraldo over 3 years
    Has anyone tested the second solution? Can you explain what exactly those flags are doing?
  • Passiday
    Passiday over 3 years
    Fixes the rendering issue, but now the CPU cooler goes full speed all the tiime.
  • mr_azad
    mr_azad over 3 years
    The second solution worked for me .. Thanks :)
  • K.-Michael Aye
    K.-Michael Aye over 3 years
    this works for Brave on my Kubuntu 20.04 system, using brave://flags, thanks!
  • NYCeyes
    NYCeyes over 3 years
    \o/ This is an excellent answer and works without making performance compromises. I will note though, that because Chrome's hamburger menu may be obfuscated by the glitchy pixelation, simply pressing <Shift> + <Escape> will get you to Chrome's (and Chromium's) Task Manager directly, where you can then kill the GPU process that you mentioned.
  • Daniel Rosehill
    Daniel Rosehill over 3 years
    Fixed the issue for me but not sure about performance. Will edit comment later when I have a large amount of tabs open.
  • Daniel Rosehill
    Daniel Rosehill over 3 years
    Disabling hardware acceleration worked for me.
  • Youw
    Youw over 3 years
    Worked for met too: GTX 1060, driver 455
  • Rob Cranfill
    Rob Cranfill over 3 years
    I had the same issue on my new machine with Ubuntu 20.10 and Chrome "86.0.4240.111 (Official Build) (64-bit)", but this still fixed it!
  • Andrew
    Andrew over 3 years
    Works. Ubuntu 20.04, Nvidia Vulkan β drivers, google-chrome-β. Hole feeling that it start work even faster! At lease is shows 42 fps now, vs 25 fps before on this page: shadertoy.com/view/ldB3Dt
  • Ryan Hartman
    Ryan Hartman over 3 years
    This is the best answer so far.
  • Redu
    Redu over 3 years
    Enabling Vulkan made my Google Maps crawl like a snail.
  • Elias
    Elias over 3 years
    This is also exactly why linux is currently not really suitable as a daily driver. I have this issue every time and it's soo annoying. Still, linux/unix is 100x better than windows when developing so I guess I'm stuck with this mess.
  • BeastOfCaerbannog
    BeastOfCaerbannog over 3 years
    This works and is a handy addition to tiangolo's answer. Note that if you use another Chromium-based browser, for example Brave, you should properly change the pkill command. In Brave's case it would become pkill -f 'brave --type=gpu-process'.
  • christianbueno.1
    christianbueno.1 over 3 years
    Thanks pal, very useful solution. think that the problem is with NVIDIA drivers and the kernel in Linux, because in fedora 33 with open source drivers nouveau there is no problems about it, but after install NVIDIA proprietary drivers from rpmfusion in fedora 33 the problems begin to appears.
  • christianbueno.1
    christianbueno.1 over 3 years
    And the problems appears in vscode too, in kubuntu it affects to the user avatar.
  • BeastOfCaerbannog
    BeastOfCaerbannog over 3 years
    This answer, combined with Andrew Bruce's answer, is the best option to use Chromium-based browsers with hardware acceleration until the problem gets resolved.
  • tiangolo
    tiangolo over 3 years
    Nice! I used it and it works perfectly. I just added a note to my original answer pointing to this answer. 🚀
  • raj
    raj over 3 years
    You can change the shortcut for Chrome to include these parameters, thus you don't need to run it from a terminal.
  • kelalaka
    kelalaka over 3 years
    Do we run with sudo?
  • RedEyed
    RedEyed over 3 years
    No, as you can see: sudo is inside the script
  • RedEyed
    RedEyed over 3 years
    Oh, then u have several drivers. IDK, just change the NVIDIA_DIR to the driver path u have installed
  • RedEyed
    RedEyed over 3 years
    Updated the script to get the right version
  • kelalaka
    kelalaka over 3 years
    Although I've upvoted, this not solved the issue. The best is chrome://restart/
  • RedEyed
    RedEyed over 3 years
    Sad to hear. Thanks for the upvote. In my case, it solves partially: Slack (which is based on chrome) now works fine, but Firefox is still has "artifacts" after suspending
  • kelalaka
    kelalaka over 3 years
    I've only problem with the chrome, though, strange.
  • Gui Ambros
    Gui Ambros over 3 years
    This works, but has its own side effects. After a few rounds of suspend-restart-suspend-restart, Chrome detects the successive failures and reverts back to software emulation. Everything will work and the GPU process will even show up under Chrome Task Manager, but if you investigate with chrome://gpu/ you'll see that you're running in software emulation, which uses your CPU instead of GPU. Unfortunately the only real clean solution I found so far is to restart Chrome entirely (which is a pain).
  • Thomas Kainrad
    Thomas Kainrad over 3 years
    Thanks a lot for this answer! Solves the problem also for Electron-based apps, e.g. my file now has 3 pkill commands like this: sh pkill -f 'chrome \-\-type=gpu-process'; pkill -f 'keycombiner \-\-type=gpu-process'; pkill -f 'spotify \-\-type=gpu-process'
  • Andrew Bruce
    Andrew Bruce over 3 years
    You're welcome. You could get fancy and use a regexp instead of the three kills. An exercise for the reader!
  • Chris Watts
    Chris Watts over 3 years
    For me, I find that just a pkill -f type=gpu-process will work for Chrome and other Electron-based apps all in one go. That being said, I have switched Chrome to using Vulkan too.
  • Brandon
    Brandon over 3 years
    I found that this solution doesn't work nicely with xterm.js (VS Code terminal as well as Hyper terminal). It winds up causing most of the terminal to go blank. I wound up having to resize VS Code (Ctrl + then Ctrl - to solve my problems). With Hyper I have to restart completely.
  • Andrew Bruce
    Andrew Bruce over 3 years
    Yeah I still end up restarting my browser, because although the image is restored and usable, the scrolling etc. is severely degraded after the GPU process has been killed. Perhaps the processes using the old GPU process are kicked down to CPU?
  • Kishalay
    Kishalay over 3 years
    For chrome the command will change. Please check your task manager. It will come under "--type=gpu-process"
  • trusktr
    trusktr about 3 years
    Similar issue in Chrome's bug tracker: bugs.chromium.org/p/chromium/issues/detail?id=1134981
  • Siniša
    Siniša over 2 years
    Worked for me too! Ubuntu 20.04 with nVIDIA 480 (proprietary, tested) on a Dell laptop with nVIDIA GTX 1050 Ti Mobile had issue with Google Chrome. If I would take a tab and drag it to be a separate window, that window would be drawn with additive over everything and pretty much be either all white after few seconds. Enabling Vulkan extension fixed it! Thanks mate!
  • w-sky
    w-sky over 2 years
    This seems to be the simplest solution and it works fine on my system for Chromium! (Also an Ubuntu 20.04 system with Intel i5, Nvidia GeForce graphics, recommended Nvidia driver.) However I do also use Chrome (the Google version), does anyone know how to apply this fix for Chrome? I tried ".chrome-browser.init" and "CHROME_FLAGS" but that does not work.