Bug 478327

Summary: Desktop effects were restarted due to a graphics reset
Product: [Plasma] kwin Reporter: bradleyfourie
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: nate, vlad.zahorodnii, xaver.hugl
Priority: NOR Keywords: multiscreen
Version First Reported In: 5.27.10   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Output of command

Description bradleyfourie 2023-12-09 23:56:24 UTC
When running Dota 2, an Alt+Tab or maybe a Steam chat message/other pop-up creates a notification from KWin Window Manager saying "Desktop effects were restarted due to a graphics reset". This then causes extreme lag if returning to Dota and multiple Alt+Tab some times returns it to a usable state. I have tested some other games and it doesn't seem to occur.

I was initially using Arch when this issue first occurred and I thought it was a system update (not related to KDE) that caused it. I can confirm the issue is happening on Fedora Kinoite, Fedora Workstation (KDE spin) and I think OpenSUSE Tumbleweed as well. I am pretty sure this is a regression because I don't remember this being a problem before (haven't used KDE for too long.)

This issue does not occur on GNOME, Sway or Hyprland.

I am on a laptop connected to an external monitor through USB-C -> DP (internal monitor disabled and only using external.) VRR state doesn't stop the bug from occurring. This issue doesn't seem to occur when only using the laptop monitor.

STEPS TO REPRODUCE
1. Launch Dota 2 with external monitor (not sure if cable type matters)
2. Alt+Tab or receive notification that steals focus

OBSERVED RESULT
KWin Window Manager notification pops up: "Desktop effects were restarted due to a graphics reset" and when changing back to the game extreme lag/freeze occurs. Alt+Tabbing multiple times sometimes returns the game to a playable state.

EXPECTED RESULT
Alt+Tab without issues.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora Linux 39 Kinoite
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11

ADDITIONAL INFORMATION
ASUS ROG Strix G15 AMD Advantage Edition (G513QY)
AMD Ryzen 9 5900HX
RX6800M
32GB RAM
Comment 1 bradleyfourie 2023-12-10 00:00:36 UTC
Something else to note after testing, this issue only occurs with Wayland session.
Comment 2 bradleyfourie 2023-12-16 11:03:49 UTC
After further testing this definitely seems to be related to desktop effects and the task switcher. I cannot isolate it to one specific option, value or combination. If all are disabled then it works better and if I disable the two tick boxes under Window Management > Task Switcher > Visualisation this issue is pretty much non-existent. I say pretty much because there is still lag for a second or two which occurs when switching and I still get the "Desktop effects were restarted due to a graphics reset" pop-up (strangely only after quitting the game) even though I have disabled all desktop effect options in Workspace Behaviour > Desktop Effects.
Comment 3 bradleyfourie 2023-12-16 11:08:27 UTC
Other things that may be of note, the following message is spammed excessively (multiple times a second) in journal: "kf.plasma.core: findInCache with a lastModified timestamp of 0 is deprecated".

Another is "Could not find the Plasmoid for Plasma::FrameSvgItem(0x555df9ba0510) QQmlContext(0x555df6957370) QUrl("file:///usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/global/Globals>"
Comment 4 Zamundaaa 2023-12-16 16:23:24 UTC
Please attach the output of
> journalctl --user-unit plasma-kwin_wayland --boot 0
after the bug happens
Comment 5 bradleyfourie 2023-12-16 18:08:17 UTC
Created attachment 164227 [details]
Output of command

Different installation (Arch) so slightly different KDE version and Steam is installed from Arch repo instead of Flatpak from when logged but I can reinstall Kinoite if necessary:
Operating System: Arch Linux 
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.113.0
Qt Version: 5.15.11
Kernel Version: 6.6.7-arch1-1 (64-bit)
Comment 6 bradleyfourie 2023-12-16 19:11:39 UTC
I have found other posts and bugs which seem to be related, they also post a temporary fix.

https://bugs.kde.org/show_bug.cgi?id=457096
https://gitlab.freedesktop.org/drm/amd/-/issues/2075

I can confirm the following workaround works:
Create .sh file in /etc/profile.d with the following:
export KWIN_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1

With this temporary fix the laptop monitor remains on, displays the SDDM login screen and I am unable to see it in display settings. However there is zero lag or delay when Alt+Tabbing from Dota and no notifications related to desktop effects.
Comment 7 Zamundaaa 2023-12-16 19:56:29 UTC
Okay, this is two driver bugs. Please report the graphics reset to https://gitlab.freedesktop.org/mesa/mesa/-/issues, and the other one you linked already.

> KWIN_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1
You probably need to use quotes, KWIN_DRM_DEVICES="/dev/dri/card0:/dev/dri/card1" should make both GPUs be used by KWin
Comment 8 bradleyfourie 2023-12-25 12:27:18 UTC
Just adding a comment here to say this does not only occur on Dota 2 so I must have misremembered testing it or something.

I also incorrectly mentioned the "fix" in the wrong order and it should be the following:

Create .sh file in /etc/profile.d with the following:
export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
Comment 9 bradleyfourie 2023-12-25 12:44:05 UTC
(In reply to bradleyfourie from comment #8)
> Just adding a comment here to say this does not only occur on Dota 2 so I
> must have misremembered testing it or something.
> 
> I also incorrectly mentioned the "fix" in the wrong order and it should be
> the following:
> 
> Create .sh file in /etc/profile.d with the following:
> export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

Whoops, don't seem to be able to edit this but it's:
export KWIN_DRM_DEVICES="/dev/dri/card1:/dev/dri/card2"