Bug 481538 - Discrete GPU dialog sets the legacy X-KDE-RunOnDiscreteGpu desktop key as overlooked backwards compatibility instead of upstream PrefersNonDefaultGPU
Summary: Discrete GPU dialog sets the legacy X-KDE-RunOnDiscreteGpu desktop key as ove...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Properties dialog (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-19 10:22 UTC by Berk Elyesa Yıldırım
Modified: 2024-03-16 02:39 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Berk Elyesa Yıldırım 2024-02-19 10:22:55 UTC
SUMMARY
If a desktop file doesn't already have PrefersNonDefaultGPU, the dialog sets the legacy X-KDE-RunOnDiscreteGpu key due to an overlooked conditional order in the name of backwards compatibility.

STEPS TO REPRODUCE
0. Use 2 GPUs/Hybrid laptop
1. Find an app that doesn't already have PrefersNonDefaultGPU key (almost all regular apps)
2. Mark "Use discrete GPU" in advanced launch settings
3. It writes X-KDE-RunOnDiscreteGpu instead
4. Find an app that does have PrefersNonDefaultGPU key (i.e. switcheroo-control-test-app)
5. (Un)mark "Use discrete GPU" in advanced settings
6. Correctly (un)sets the key

OBSERVED RESULT
(Un)sets PrefersNonDefaultGPU if the key already exists, but writes X-KDE-RunOnDiscreteGpu on new entries.
KIO checks for PrefersNonDefaultGPU and falls back to X-KDE-RunOnDiscreteGpu but in the wrong conditional order
Kservice part is correct (but backwards compatibility part can still be dropped)


EXPECTED RESULT
(Un)set X-KDE-RunOnDiscreteGpu if the key already exists, but write PrefersNonDefaultGPU for new entries.
OR
Only take PrefersNonDefaultGPU into account since the legacy one should be deprecated since 2020 and Plasma 6 can break backwards compatibility.

SOFTWARE/OS VERSIONS
KDE Plasma Version: Broken since bundled, Plasma 5.23
KDE Frameworks Version: Broken since added, KF 5.86.

ADDITIONAL INFORMATION
Seems to be added with https://invent.kde.org/frameworks/kio/-/commit/85c5815e10a3b448583817de98486d14ebcba3fc
The current file is in https://invent.kde.org/frameworks/kio/-/blob/master/src/widgets/kpropertiesdialogbuiltin_p.cpp?ref_type=heads#L2829 (moved since the mentioned commit)
Should either drop X-KDE-RunOnDiscreteGpu entirely, or swap the two conditionals (and backport to 5.27 as well?)
Or drop in 5.27 as well since apps can't set X-KDE-RunOnDiscreteGpu as they should follow the upstream spec anyway.

It's tiny, so can I take it as a good first fix/contribution if you can guide the decision? Thanks xP
Comment 1 Nate Graham 2024-02-21 21:22:16 UTC
Sounds good, feel free to fix this! Dropping X-KDE-RunOnDiscreteGpu makes sense to me since it's deprecated and we're in KF6 territory now.

Be aware of parallel work ongoing in https://invent.kde.org/frameworks/kio/-/merge_requests/1556.
Comment 2 Bug Janitor Service 2024-02-22 10:13:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1562
Comment 3 Berk Elyesa Yıldırım 2024-02-22 10:19:43 UTC
Thanks, I checked 1556 and this is way above that to interfere anything, just desktop key checking hehe
Just the write action condition can simply be reversed (instead of being dropped) for 5.27, but either way that needs approval and I don't know how to do stuff for LTS yet..
Comment 4 Harald Sitter 2024-03-15 14:04:07 UTC
Git commit 3fc80769b60d3590d8ece6955852080584accbaf by Harald Sitter, on behalf of Berk Elyesa Yıldırım.
Committed on 15/03/2024 at 13:43.
Pushed by sitter into branch 'master'.

Drop legacy keys for m_runOnDiscreteGpuBool

We shouldn't write X-KDE-RunOnDiscreteGpu anymore,
Prefer PrefersNonDefaultGPU following the upstream spec.

It was already half-broken anyway.

M  +1    -6    src/widgets/kpropertiesdialogbuiltin_p.cpp

https://invent.kde.org/frameworks/kio/-/commit/3fc80769b60d3590d8ece6955852080584accbaf