KDE - Nvidia screen corruption after resume

I was almost ready to take another crack at a better fix for this, but it appears I don’t have to now. It looks like a patch for this was applied in a recent update as the problem seems to have disappeared.

I figured it would get addressed eventually as it was a known issue. Just thought I’d give an update.

Good news for now, anyways. Problem solved.

1 Like

I still have the problem
Nvidia 415
kernel 420

thanks

Unfortunately, it’s still unsolved for me : (

It seems to come and go on my one machine that is affected.

Well as my machine was seeing this issue again I thought I’d take another stab at fixing this issue. My systemd skills are much improved from when I started this thread, so I thought maybe I’d do better this time around. Lucky thing I did, because I think I finally found a working solution.

On the positive side I whittled this down to only one unit file and no external scripts. The only negative appears to be that for some reason it takes about 20 seconds before it goes into full suspend. However, it resumes instantly and the screen corruption is not present after resuming.

On a desktop this would seem to be a great solution. On a laptop the slow suspend might be annoying if you closed the lid and then changed your mind about suspending. This might lead to a delay before you could resume. I don’t know for sure if that is the case, because I am not using this with a laptop.

A super easy to write one service file solution:

Create:

~/.config/systemd/user/plasma-restart.service

Systemd plasma-restart.service file contents:

#~/.config/systemd/user/plasma-restart.service
#systemctl --user enable plasma-restart.service
#systemctl --user start plasma-restart.service
#systemctl --user status plasma-restart.service
#systemctl --user stop plasma-restart.service
#sudo loginctl enable-linger <username>
#systemctl --user daemon-reload
#systemctl --user daemon-reexec 
[Unit]
Description=Restart plasmashell after resuming
After=suspend.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes 
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'kquitapp5 plasmashell'
ExecStop=/usr/bin/sudo -u $USER /bin/bash -lc 'plasmashell > /dev/null 2>&1 & disown; sleep 2; exit'

[Install]
WantedBy=sleep.target

Enable the plasma-restart.service:

systemctl --user enable plasma-restart.service

Reboot.

1 Like

New Fix For Screen Corruption After Suspend:

I don’t know why my prior service stopped working. Perhaps it was a kernel or driver change (or possibly another factor). Regardless, I went back to the drawing board to find a new solution. The only method that works on my computer to eliminate the screen corruption is a full plasma restart. That is actually much harder to accomplish than you would think.

At first glance this service looks deceptively simple, but it took countless command variations to find this solution. I tried using different environment variables and even an environment file (with all my variables) to try and reload plasma correctly. However, no mater what type of service, or how I tried to restart plasma it would not work 100% correctly…

Then a strange thought occurred to me, Plasma reloads itself after a crash. What if auto-loading itself after a crash loads things in the correct environment all on its own. Bizarrely, forcing a plasma crash was the solution to getting plasma to reload correctly. This fixes the screen corruption issue with a barely perceptible delay after coming out of suspend.

Here is my new service unit.

Create:

/etc/systemd/system/plasma-restart.service

plasma-restart.service file contents:

#/etc/systemd/system/plasma-restart.service
#sudo systemctl enable plasma-restart.service
#sudo systemctl start plasma-restart.service
#sudo systemctl stop plasma-restart.service
#sudo systemctl disable plasma-restart.service
#systemctl status plasma-restart.service
#sudo systemctl daemon-reload

[Unit]
Description=Plasma Restart Service
After=suspend.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/sudo -u user /bin/sh -a -c 'killall -SIGSEGV plasmashell' 

[Install]
WantedBy=suspend.target

You must subsitute your own username in place of “user” in the “ExecStart=” line of the service.

To enable the plasma-restart.service:

systemctl enable plasma-restart.service

Reboot.

I will be trying this tomorrow on my desktop. Just curious does it work on the lock screen it’s self too? I had your previous fix on my desktop but still sometimes the lock screen would still be wonky. I didn’t care much because at least my desktop seemed to stop having wonky icons.

I don’t use a lock screen, you’ll have to test it for yourself. :wink:

Will do and will let everyone know.

1 Like

I have pretty the same issue (to be honest can’t say that it annoying me, just want to experiment)

So just finished with testing. My results not good.
Here is the status of service

[lex@home-desktop ~]$ systemctl status plasma-restart.service
● plasma-restart.service - Plasma Restart Service
   Loaded: loaded (/etc/systemd/system/plasma-restart.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

Mar 01 20:31:16 home-desktop systemd[1]: Starting Plasma Restart Service...
Mar 01 20:31:16 home-desktop sudo[1583]:     root : TTY=unknown ; PWD=/ ; USER=lex ; COMMAND=/bin/sh -a -c killall -SIGSEGV plasmashell
Mar 01 20:31:16 home-desktop sudo[1583]: pam_unix(sudo:session): session opened for user lex by (uid=0)
Mar 01 20:31:16 home-desktop sudo[1583]: pam_unix(sudo:session): session closed for user lex
Mar 01 20:31:16 home-desktop systemd[1]: Started Plasma Restart Service.
Mar 01 20:31:16 home-desktop systemd[1]: plasma-restart.service: Succeeded.
Mar 01 20:31:16 home-desktop systemd[1]: Stopped Plasma Restart Service.

Well after wake up I got black screen (without wallpapers) and even desktop context menu (mouse right click) doesn’t work.

I guess, for me, better to forget about this issue. Too much efforts to resolve it.

Perhaps we have different root causes for our issues. For some people restarting Kwin solves this, and for others only a plasma restart will work. Maybe you are one of those that require a kwin restart.

Run this command to find out:

kwin_x11 --replace

If that command clears your screen corruption then test this unit written by @Beatussum.

Create the service file:

/etc/systemd/system/kwin-restart@.service

With the following contents:

[Unit]
Description=Restart kwin after resuming
After=sleep.target
StopWhenUnneeded=yes

[Service]
User=%i
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/env bash -c "XDG_RUNTIME_DIR=/run/user/`id --user` DISPLAY=:0 XDG_CURRENT_DESKTOP=KDE kwin_x11 --replace"

[Install]
WantedBy=sleep.target

To enable the service enter:

sudo systemctl enable kwin restart@<username>.service

Substitute your username for <username> in the above command.

Then restart.

Big thank you to @Beatussum for posting that solution on this related thread:

https://forum.manjaro.org/t/black-borders-around-windows-after-resume/76088/26

2 Likes

So I came home to test this today after work(I am a day or so late sorry) and found a new new issue going on with my computer and waking from suspend. Now when waking from suspend the computer wakes up and all my fans and lights come on but it never wakes up my monitor nor sends a display signal.

Still I thought maybe it was a fluke so I created the file you came up with and and everything and put it in suspend mode to see what happens when I wake it up…same thing as when I woke it when I came home from work so I have to figure out what is not waking up before I can play with this I guess.

Failed suspends are most often caused by video or network hardware not being put to sleep properly. In the case of video drivers there’s only so much you can do.

Search the forum and you will find lots of threads about fixing suspend issues with a systemd service for problems caused by network components…

1 Like

Here’s my latest version of a service to restart KDE Plasma after suspending, This version seems to work very well and unlike my last version this does not depend on crashing plasma so it doesn’t throw an error when executed.

Plasma Restart Service

With a root text editor create:

/etc/systemd/system/plasma-restart@.service

Service file contents:

#/etc/systemd/system/plasma-restart@.service
#sudo systemctl enable plasma-restart@$USER.service
#sudo systemctl start plasma-restart@$USER.service
#sudo systemctl stop plasma-restart@$USER.service
#sudo systemctl disable plasma-restart@$USER.service 

[Unit]
Description=Plasma Restart Service 
After=suspend.target 
StopWhenUnneeded=yes

[Service]
User=%i
WorkingDirectory=/home/%i
Type=oneshot
Slice=user-%i.slice
RemainAfterExit=yes
ExecStart=/bin/bash -alc "sudo -Hiu %i pkill -ABRT plasmashell"

[Install]
WantedBy=suspend.target 
Alias=plasma-restart@%i.service

Save the service file with root permissions, and exit the text editor.

Then, enable the service:

sudo systemctl enable plasma-restart@$USER.service

Then restart.

Thanks for your work ! Is it possible to add a latte-dock restart to this service?

Anything is possible. You would need to search for the latte-dock PID, then kill it before suspend, resume part is simpler.

This should be fixed with Qt 5.13, Plasma 5.16, KDE frameworks 5.59

Just updated to Qt 5.13,problem is gone)

1 Like

Nice!

Forum kindly sponsored by