Bug 460404 - [Regression]: Kwin 5.26.0 uses software renderer instead of GLX
Summary: [Regression]: Kwin 5.26.0 uses software renderer instead of GLX
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: glx (show other bugs)
Version: 5.26.0
Platform: Compiled Sources Linux
: HI normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-10-14 04:32 UTC by Dan
Modified: 2023-11-17 15:57 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan 2022-10-14 04:32:13 UTC
KDE Plasma Version: 5.26.0
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.5
Kernel Version: 6.0.1 (64-bit)
Graphics Platform: X11
Graphics Processor: NVIDIA GeForce RTX 2070 with Max-Q Design/PCIe/SSE2

With Kwin 5.25.5, the compositor works fine with GLX, but after upgrading to 5.26.0, Kwin will use only the software renderer and warn about degraded performance. So it's probably a regression, since it was working with 5.25.5 and nothing was changed, except for the Plasma upgrade.

Any hints? Thanks.
Comment 1 Simon Vogl 2022-10-16 21:36:08 UTC
Can confirm this on my desktop system, RTX 2070 Super + i9-9900K

It seems like the automatic detection of what render to use is broken, because if I go to the "Plasma-Renderer" app and manually change the output module to "OpenGL" hardware-accelerated rendering works completely fine and the performance regression is gone.

Does anyone have an idea as to why OGL detection might be broken on at least some NVIDIA GPUs in 5.26?
Comment 2 Arjen Hiemstra 2022-10-18 13:43:56 UTC
Can you check if the key "LastFailureTimestamp" exists in the group "Compositing" in ~/.config/kwinrc and what value it has? For 5.26 we made a change where KWin should retry enabling compositing after a short while, instead of just disabling it once. Also, does EGL work correctly?
Comment 3 Dan 2022-10-18 13:58:42 UTC
(In reply to Arjen Hiemstra from comment #2)
> instead of just disabling it once. Also, does EGL work correctly?

Hi Arjen, there's no LastFailureTimestamp in the group Compositing.

In my case, EGL doesn't work because of the bug 456372 I reported some time ago, so I'm stuck with GLX.
Comment 4 Simon Vogl 2022-10-18 14:20:13 UTC
For me "LastFailureTimestamp" doesn't exist in kwinrc either.
Just to clarify things, visually compositing does work fine for me. Compared to 5.25, I just noticed a massive performance regression but no visual degradation or functionally loss.
Manually setting the output module to "OpenGL" in the "Plasma-Renderer" app completely circumvents the issue, so the problem seems to be that the "Automatic" setting defaults to "Software" even if a capable device/driver for "OpenGL" is found.

TL;DR: everything looks fine but compositing is noticeably slower overall.
Comment 5 Simon Vogl 2022-10-18 14:23:11 UTC
(In reply to Simon Vogl from comment #4)
> For me "LastFailureTimestamp" doesn't exist in kwinrc either.
> Just to clarify things, visually compositing does work fine for me. Compared
> to 5.25, I just noticed a massive performance regression but no visual
> degradation or functionally loss.
> Manually setting the output module to "OpenGL" in the "Plasma-Renderer" app
> completely circumvents the issue, so the problem seems to be that the
> "Automatic" setting defaults to "Software" even if a capable device/driver
> for "OpenGL" is found.
> 
> TL;DR: everything looks fine but compositing is noticeably slower overall.

Nevermind, apparently setting the output module to "Software" manually also fixes the performance regression, just the "Automatic" setting seems to be causing it...
Comment 6 Arjen Hiemstra 2022-10-18 14:29:52 UTC
Can either of you share the console output of KWin? I'm curious if it mentions any errors.
Comment 7 Simon Vogl 2022-10-18 14:42:17 UTC
(In reply to Arjen Hiemstra from comment #6)
> Can either of you share the console output of KWin? I'm curious if it
> mentions any errors.

> kwin_xkbcommon: XKB: inet:323:58: unrecognized keysym "XF86EmojiPicker"
> kwin_xkbcommon: XKB: inet:324:58: unrecognized keysym "XF86Dictate"
> OpenGL vendor string:                   NVIDIA Corporation
> OpenGL renderer string:                 NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
> OpenGL version string:                  3.1.0 NVIDIA 515.76
> OpenGL shading language version string: 1.40 NVIDIA via Cg compiler
> Driver:                                 NVIDIA
> Driver version:                         515.76
> GPU class:                              Unknown
> OpenGL version:                         3.1
> GLSL version:                           1.40
> X server version:                       1.21.1
> Linux kernel version:                   6.0.1
> Requires strict binding:                no
> GLSL shaders:                           yes
> Texture NPOT support:                   yes
> Virtual Machine:                        no
> QObject::killTimer: Timers cannot be stopped from another thread
> QObject::~QObject: Timers cannot be stopped from another thread

This appears to be all kwin outputs to the console.
Comment 8 Dan 2022-10-18 14:52:04 UTC
(In reply to Arjen Hiemstra from comment #6)
> Can either of you share the console output of KWin? I'm curious if it
> mentions any errors.

My Kwin  output:

OpenGL vendor string:                   NVIDIA Corporation
OpenGL renderer string:                 NVIDIA GeForce RTX 2070 with Max-Q Design/PCIe/SSE2
OpenGL version string:                  3.1.0 NVIDIA 520.56.06
OpenGL shading language version string: 1.40 NVIDIA via Cg compiler
Driver:                                 NVIDIA
Driver version:                         520.56.6
GPU class:                              Unknown
OpenGL version:                         3.1
GLSL version:                           1.40
X server version:                       1.21.1
Linux kernel version:                   6.0.2
Requires strict binding:                no
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
QObject::killTimer: Timers cannot be stopped from another thread
QObject::~QObject: Timers cannot be stopped from another thread
kf.kirigami: Failed to find a Kirigami platform plugin
file:///usr/kde5.26/lib/qml/org/kde/plasma/extras/PlaceholderMessage.qml:238:5: QML Heading: Binding loop detected for property "verticalAlignment"
Application::crashHandler() called with signal 11; recent crashes: 2
KCrash: crashing... crashRecursionCounter = 2
KCrash: Application Name = kwin_x11 path = /usr/kde5.26/bin pid = 15015
KCrash: Arguments: /usr/kde5.26/bin/kwin_x11 --crashes 1
Comment 9 Simon Vogl 2022-10-21 14:13:42 UTC
Hmm.. since kwin does not crash at all on my end, I'm asking myself whether I'm even experiencing the same bug as OP or a different one?

I did some more testing on my Laptop with Intel + Mesa graphics and the performance regression also appears there, but to a much lesser extend. I also just tested with plasma 5.26.1 and the bug persists for me.

Apparently the performance regression only appears for me when "SceneGraphBackend" in .config/kdeglobals is not set to any value or doesn't exist. If "SceneGraphBackend" is set to any string, even if that string doesn't make any sense, the bug goes away:

.config/kdeglobals:
>[QtQuickRendererSettings]
>SceneGraphBackend=
-> Regression happens
>[QtQuickRendererSettings]
>SceneGraphBackend=opengl
-> Regression does not happen
>[QtQuickRendererSettings]
>SceneGraphBackend=software
-> Regression does not happen
>[QtQuickRendererSettings]
>SceneGraphBackend="Today is a nice day"
-> Regression does not happen

@Dan does your issue go away when you put

[QtQuickRendererSettings]
SceneGraphBackend=opengl

in .config/kdeglobals ?

If not, I should probably create a new, separate bug for my issue.
Comment 10 Dan 2022-10-21 14:27:24 UTC
(In reply to Simon Vogl from comment #9)
> Hmm.. since kwin does not crash at all on my end, I'm asking myself whether
> I'm even experiencing the same bug as OP or a different one?

In fact Kwin doesn't crash. The kcrash message is unrelated to this issue (I don't know why the kcrash appeared in the logs).

> @Dan does your issue go away when you put
> 
> [QtQuickRendererSettings]
> SceneGraphBackend=opengl
> 
> in .config/kdeglobals ?

You're correct! This fixed the issue for me. Now it's working perfectly as before ;-)
Comment 11 Simon Vogl 2022-10-21 14:30:39 UTC
(In reply to Dan from comment #10)
> (In reply to Simon Vogl from comment #9)
> > Hmm.. since kwin does not crash at all on my end, I'm asking myself whether
> > I'm even experiencing the same bug as OP or a different one?
> 
> In fact Kwin doesn't crash. The kcrash message is unrelated to this issue (I
> don't know why the kcrash appeared in the logs).
> 
> > @Dan does your issue go away when you put
> > 
> > [QtQuickRendererSettings]
> > SceneGraphBackend=opengl
> > 
> > in .config/kdeglobals ?
> 
> You're correct! This fixed the issue for me. Now it's working perfectly as
> before ;-)

OK, looks like we indeed face the same issue.
Now the question is why is there a slowdown when SceneGraphBackend under [QtQuickRendererSettings] is not set to any value / doesn't exist?
Comment 12 Dan 2022-10-21 14:56:37 UTC
(In reply to Simon Vogl from comment #11)

> OK, looks like we indeed face the same issue.
> Now the question is why is there a slowdown when SceneGraphBackend under
> [QtQuickRendererSettings] is not set to any value / doesn't exist?

Good question. but I also tested without SceneGraphBackend and it works fine here.

When I had the problem, SceneGraphBackend was set to "software", but I don't remember setting it to "software" (since it was working with 5.25, maybe Plasma 5.26 set it after the upgrade for some reason?).
Comment 13 Simon Vogl 2022-10-21 22:05:39 UTC
(In reply to Dan from comment #12)
> (In reply to Simon Vogl from comment #11)
> 
> > OK, looks like we indeed face the same issue.
> > Now the question is why is there a slowdown when SceneGraphBackend under
> > [QtQuickRendererSettings] is not set to any value / doesn't exist?
> 
> Good question. but I also tested without SceneGraphBackend and it works fine
> here.
> 
> When I had the problem, SceneGraphBackend was set to "software", but I don't
> remember setting it to "software" (since it was working with 5.25, maybe
> Plasma 5.26 set it after the upgrade for some reason?).

Well yea, the warning about software rendering is gone on "Automatic" for me as well, the performance regression however is still there.
You likely won't even notice it in normal usage, its mainly noticeable in synthetic tests like measuring how long certain QtQuick apps take to respond.
E.g. running the command "time konsole -e" takes ~75% longer to complete on "Automatic" vs. "OpenGL"/"Software" (~70ms vs ~120ms)
What does annoy me is that I have noticeable animation slowdowns on my Desktop 165Hz screen on "Automatic".
Comment 14 David Edmundson 2022-10-21 22:18:52 UTC
If it's set to anything it won't try auto-detection. If we try auto detection (which in 5.27 moved to the KDE PlatformTheme) we'll be creating GL contexts. This is throwing kwin off.

I remember in the past kwin explicitly didn't use QtQuickSettings (though I can't remember why).
Super worst case we add a special guard into the QPT to ignore kwin.
Comment 15 Vlad Zahorodnii 2022-10-24 10:12:53 UTC
(In reply to David Edmundson from comment #14)
> If it's set to anything it won't try auto-detection. If we try auto
> detection (which in 5.27 moved to the KDE PlatformTheme) we'll be creating
> GL contexts. This is throwing kwin off.
> 
> I remember in the past kwin explicitly didn't use QtQuickSettings (though I
> can't remember why).
> Super worst case we add a special guard into the QPT to ignore kwin.

https://invent.kde.org/plasma/plasma-integration/-/blob/38c985d826acc2bb233a6e608bce8502e7216ff4/src/platformtheme/qtquickrenderersettings.cpp#L103 is Q_COREAPP_STARTUP_FUNCTION correct?

startup hooks are called in QCoreApplicationPrivate::init(), and QGuiApplicationPrivate::init() calls QCoreApplicationPrivate::init() before creating the QPA plugin https://codebrowser.dev/qt5/qtbase/src/gui/kernel/qguiapplication.cpp.html#1527

Just to be sure, I added a qDebug in checkContext() and there's no global share context, kwin requests a global share context
Comment 16 Vlad Zahorodnii 2022-10-24 10:23:21 UTC
Nvm, my analysis is wrong
Comment 17 Simon Vogl 2022-11-12 11:43:57 UTC
So should we just wait for the bug to be fixed in Plasma 5.27/Plasma 6.0 or does this require more debugging?
Comment 18 David Edmundson 2023-02-01 16:19:41 UTC
>So should we just wait for the bug to be fixed in Plasma 5.27

I was unable to reproduce an issue, lets see if it's still an issue once you have this release.
Comment 19 Simon Vogl 2023-02-01 19:11:57 UTC
I just tested with the 5.27 beta (5.26.90) and "time konsole -e" still reports ~50% more time consumed with renderer output module set to "automatic" vs "opengl" or "software", I will report back with 5.27.0 full release results once 5.27.0 reaches my repos.
Comment 20 Simon Vogl 2023-02-14 22:48:14 UTC
So I just tested with 5.27.0, the performance regression persists:
"time konsole -e" returns:

With "SceneGraphBackend=opengl" in .config/kdeglobals: 
real    0m0,072s
user    0m0,046s
sys     0m0,023s

Without "SceneGraphBackend=opengl" in .config/kdeglobals: 
real    0m0,125s
user    0m0,065s
sys     0m0,048s
Comment 21 Nate Graham 2023-11-17 15:57:43 UTC
Many changes have been made to relevant parts of the graphics stack for Plasma 6 and we thin there's a good chance that the undesired fallback to software rendering is fixed by that work. As such, I'm going to mark this as fixed for now since unfortunately none of the KWin developers have been able to reproduce the issue. However please do feel free to re-open this bug report if you can still reproduce it with the Plasma 6 Alpha (or beta, or final release). Thanks for understanding!