Bug 466804 - plasma-integration inappropriately forces software rendering for certain NVIDIA GPU when checkContext.create() fails, but hardware rendering actually works better for it
Summary: plasma-integration inappropriately forces software rendering for certain NVID...
Status: RESOLVED FIXED
Alias: None
Product: plasma-integration
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.2
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 466274 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-03-04 03:56 UTC by benmordecai
Modified: 2023-10-24 01:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
Opacity Mask Failure (57.15 KB, image/png)
2023-03-04 03:56 UTC, benmordecai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description benmordecai 2023-03-04 03:56:02 UTC
Created attachment 156980 [details]
Opacity Mask Failure

Examples of problem apps are Kasts and Nextcloud Desktop Client. Opacity mask fails to work causing opaque rectangles to obscure the program's important content. Initially filed bug report to Kasts (https://bugs.kde.org/show_bug.cgi?id=466274) but discovered that same problem shows up in other apps. With both Nextcloud and Kasts I was able to disable the opacity mask in the source code and prove the content was there but covered by an opaque rectangle. 

The Nextcloud AppImage does not have the bug, but the official repositories do. 

Discussion and troubleshooting steps on the Arch Linux here: bbs: https://bbs.archlinux.org/viewtopic.php?id=283774

Other apps like Neochat and Monero Gui also have visual bugs, but I have done no similar troubleshooting. As mentioned in the Arch bbs post, the visual bug can also be eliminated by setting QT_QPA_PLATFORMTHEME=gtk3 before executing kasts.





STEPS TO REPRODUCE
1. Install a program that uses QML OpacityMask
2. Run program


OBSERVED RESULT
Opaque rectangles.

EXPECTED RESULT
Transparent rectangles for proper UI.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.27.2
(available in About System)
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
Exclusive X11 system. Nvidia drivers.
Comment 1 benmordecai 2023-03-08 02:34:49 UTC
Passing QT_QPA_PLATFORMTHEME=qt5ct works just as well as QT_QPA_PLATFORMTHEME=gtk3. 

Since reporting this bug I have discovered that whatever is underlying the problem is also causing kdenlive to crash on launch. Passing QT_QPA_PLATFORMTHEME=qt5ct on the launch of kdenlive resolves the problem.
Comment 2 Nate Graham 2023-03-11 03:07:31 UTC
*** Bug 466274 has been marked as a duplicate of this bug. ***
Comment 3 Nate Graham 2023-03-11 03:32:38 UTC
There's probably a problem with your graphics card or its driver if it's not capable of displaying this content properly.

Using a QPT other than plasma-integration seems to work around the issue by avoiding the code that plasma-integration sets to initialize GPU rendering properly (based on its definition of properly!). So something that plasma-integration does triggers the bug in your graphics card. Let's go over what it does:

- Falls back to software rendering if it can't create an OpenGL context properly
- Sets QSG_RENDER_LOOP=basic on Wayland if you're using an NVIDIA GPU

So let's see if we can find which combination of settings causes it to get broken. Please try to run each of the following:

# Software rendering, basic render loop:
QT_QPA_PLATFORMTHEME=qt5ct QT_OPENGL=software QT_QUICK_BACKEND=software QML_SCENE_DEVICE=softwarecontext QSG_RENDER_LOOP=basic kasts

# Software rendering, threaded render loop:
QT_QPA_PLATFORMTHEME=qt5ct QT_OPENGL=software QT_QUICK_BACKEND=software QML_SCENE_DEVICE=softwarecontext QSG_RENDER_LOOP=threaded kasts

# hardware rendering, basic render loop:
QT_QPA_PLATFORMTHEME=qt5ct QSG_RENDER_LOOP=basic kasts

# hardware rendering, threaded render loop:
QT_QPA_PLATFORMTHEME=qt5ct QSG_RENDER_LOOP=threaded kasts

Let's see which one breaks.

If nothing does, we have a better guess that something else in plasma-integration triggers this.
Comment 4 benmordecai 2023-03-11 03:40:12 UTC
Command:

QT_QPA_PLATFORMTHEME=qt5ct QT_OPENGL=software QT_QUICK_BACKEND=software QML_SCENE_DEVICE=softwarecontext QSG_RENDER_LOOP=basic kasts

Result: fail

Command: QT_QPA_PLATFORMTHEME=qt5ct QT_OPENGL=software QT_QUICK_BACKEND=software QML_SCENE_DEVICE=softwarecontext QSG_RENDER_LOOP=threaded kasts

Result: fail

Command: QT_QPA_PLATFORMTHEME=qt5ct QSG_RENDER_LOOP=basic kasts

Result: success

Command: QT_QPA_PLATFORMTHEME=qt5ct QSG_RENDER_LOOP=threaded kasts

Result: success
Comment 5 benmordecai 2023-03-11 03:41:00 UTC
Just a note, I am on X11 and NOT wayland
Comment 6 Nate Graham 2023-03-11 04:59:15 UTC
Interesting results. This means that hardware rendering is actually working properly, and the problem is that plasma-integration is forcing software rendering instead. There are two code paths to make this happen:

1. OpenGL isn't available (clearly not the case here)
2. The function call `checkContext.create()` fails

Looks like the latter thing is happening, which does imply a bug in our code somewhere. CCing David for further investigation.
Comment 7 benmordecai 2023-04-09 01:28:15 UTC
Curious if anyone has had the chance to look at this recently. Don't want to be a nag. I would look at it myself if I knew C++ and how the functions worked, but I've seen a few released of plasma-integration without any motion.
Comment 8 benmordecai 2023-10-23 23:49:31 UTC
I have finally found the solution to this problem. Source: https://www.reddit.com/r/kde/comments/obqe82/system_monitor_unable_to_use_hardware_acceleration/?rdt=40203

I ran `kcmshell5 qtquicksettings` and my backend was set to `software`. I changed it to automatic and rebooted and my problems seem to be globally fixed. 

I do not believe that I ever set this setting to `software` so I do not know if there is a bug that caused the default setting to be set that way rather than automatic, so if this is not a bug, someone is free to mark this as resolved.
Comment 9 Nate Graham 2023-10-24 01:27:02 UTC
It's done automatically on Plasma 5. On Plasma 6 we don't do this anymore as the upstream bug it's working around has been fixed. So we can consider this fixed on Plasma 6, and essentially unfixable on Plasma 5 (only workaround-able). Feel free to continue using that workaround on Plasma 5; glad you found it!