Bug 1754395
Summary: | Qt applications lose system theme if launched via dbus activation (from flatpak applications or krunner) | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | P D <pizzadudedotca> |
Component: | plasma-workspace | Assignee: | KDE SIG <kde-sig> |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | medium | Docs Contact: | |
Priority: | unspecified | ||
Version: | 33 | CC: | 4denis.kh, bcotton, carlos.rca185, chitlesh, drixi.b, equeim, ericsbinaryworld, fedora, gbcox, goeran, io, jgrulich, kde-sig, kitt997, LailahFSF, luke, mchilson+fedora, me, ncross, ndzou, rdieter, sudhir, than, thunderbirdtr, vitaly, windozf, zawertun, zbyszek |
Target Milestone: | --- | Keywords: | Patch, Reopened, Triaged |
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | dolphin-19.08.2-2.fc31 plasma-workspace-5.20.5-3.fc33 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-01-16 01:34:06 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Attachments: |
Created attachment 1618065 [details]
what dolphin is supposed to look like
Does anyone pay attention to these bug reports? Yes, people pay attention. Personally, I've just had no time to look deeply yet, even less so to add acknowledgements for every incoming bug report. Patience grasshopper. That said, this almost certainly isn't a dolphin issue (ie, problem lies elsewhere). One possibility: dbus-activated applications may not inherit (all? any?) user environment variables FEDORA-2019-1f174ad525 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-1f174ad525 baloo-widgets-19.08.2-1.fc31, dolphin-19.08.2-2.fc31, dolphin-plugins-19.08.2-1.fc31, kate-19.08.2-1.fc31, kdialog-19.08.2-1.fc31, keditbookmarks-19.08.2-1.fc31, kfind-19.08.2-1.fc31, khelpcenter-19.08.2-1.fc31, konqueror-19.08.2-1.fc31, konsole5-19.08.2-1.fc31, yakuake-19.08.2-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-1f174ad525 Hi, thanks for taking a look at this. However, even with that dolphin update, the issue still occurs with dolphin. (And other qt applications, but that would require some other update) baloo-widgets-19.08.2-1.fc31, dolphin-19.08.2-2.fc31, dolphin-plugins-19.08.2-1.fc31, kate-19.08.2-1.fc31, kdialog-19.08.2-1.fc31, keditbookmarks-19.08.2-1.fc31, kfind-19.08.2-1.fc31, khelpcenter-19.08.2-1.fc31, konqueror-19.08.2-1.fc31, konsole5-19.08.2-1.fc31, yakuake-19.08.2-1.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report. This is not fixed. Related bug 1749362 ? Yes. Same bug. The update above should fix dolphin, as it is no longer dbus-activated on f31+ (it is autostarted with: dolphin --daemon on session start instead). *** Bug 1749362 has been marked as a duplicate of this bug. *** It doesn't fix it, as dolphin can still be launched with dbus (for example - from a flatpak) Interesting, the mechanism is different now. dolphin running as a background daemon listening on that dbus interface (as part of your user session) now launches dolphin, instead of dbus itself. Means that the dolphin daemon isn't inheriting your session environment properly either? Odd, I recall it working for me in my own testing at the time I made the update (I don't have a f31 box handy currently to retest). I am experiencing this with KeePassXC on Fedora 31. When I launch it via terminal it works as expected but when launched from KRunner then the theme gets messed up. Don't know if it's related or not but I have following error when running `dbus-update-activation-environment --all --systemd` from the console: dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments Also I see such errors in the ~/.xsession-errors after every login to KDE. Issue is gone after I uninstall package Lmod, it exports some env variables with new lines and tab characters (BASH_FUNC_ml%% and some other). Command `systemctl --user import-environment` will fail to import those variables. Removal of Lmod package fixed issue for me with Spectacle. Removing Lmod solved the issue for me. I had to do it via "sudo rpm -e --nodeps Lmod" because some packages I use (like Kdenlive) depended on it. Can Lmod be removed safely without it causing harm to other apps like Kdenlive? I haven't noticed any issues in my minimal testing, and I don't think it's needed though I'm not sure what Lmod does. I also removed Lmod, and got system themes back in Spectacle. For many users, it seems to be a dependency (in my case, the Nomacs image viewer). It seems that the reason we all have this same bug is OpenCV, which both Nomacs and Kdenlive are using. I'm a rookie in these parts though, so I'll leave it to The Powers That Be to decide whether a bug should be filed against Lmod instead dolphin. I am also seeing this and this dependency seems to be required by e.g. digikam. Want to add that this is affecting Spectacle for me on KDE Plasma with Fedora 31 updated to the latest packages. I had this annoying problem also with Spectacle. Not only losing the system theme but also the 2x scaling which made it impossible to use on my HiDPI screen. The comment #17 above about importing user environment gave me some tips on solving this issue. Here are my steps: run 'systemctl --user import-environment' from the command line. If you see any errors, then your environment failed to get passed into systemd user instance, and therefore not passed into dbus activated programs. The next step would be to pin-point where the error occurs during the import. For this I'm afraid there's no approach other than trial and error. Start with the most basic .bashrc, or .zshrc, etc. Then invoke a login shell (normally with the -l argument to the shell), and rerun the import command above. You may need to disable the scripts under /etc/profile.d as well. If #25 is right - it'd be nice if we could have some confirmation or a script we could run to check this. Cause of this bug is simple - systemd don't import ALL enviroment variables if any variable name is not POSIX compilant (it must conform to the regex [0-9A-Z_], see: https://github.com/systemd/systemd/blob/a859abf062cef1511e4879c4ee39c6036ebeaec8/src/basic/env-util.c#L19). You can test it with this command: `env %=1 systemctl --user import-environment`, it will fail. Now there is 2 known packages exporting those variables: environment-modules and Lmod. Solution is simple - skip ONLY invalid variables while importing others. I've created bug in the systemd, but still without answer - https://github.com/systemd/systemd/issues/14878. Created attachment 1675998 [details]
plasma-workspace-5.18.4.1-filter-environment.patch
If the mountain will not come to Muhammad...
There is a patch to fix this issue for KDE.
It must be applied to the plasma-workspace.
Someone - please test it, it should help, but anyway some testing required.
(In reply to Yaroslav Sidlovsky from comment #28) > Created attachment 1675998 [details] > plasma-workspace-5.18.4.1-filter-environment.patch > > If the mountain will not come to Muhammad... > > There is a patch to fix this issue for KDE. > It must be applied to the plasma-workspace. > Someone - please test it, it should help, but anyway some testing required. I tested the patch because you uploaded it to your copr repo and it seems to work fine. https://src.fedoraproject.org/rpms/plasma-workspace/c/c7021c7de4738619fcc9b61ce27c762ce4dc1f89?branch=master imported patch, only for f32+ currently. Will likely be working on plasma-5.18 update for f31 soon that will include this fix too Created attachment 1676095 [details]
plasma-workspace-5.18.4.1-filter-environment-v2.patch
I've just made more complex and more correct (as I think) patch that modifies environment only for process "dbus-update-activation-environment".
After applying this patch:
$ LANG=C journalctl -b 0 -g 'environment variable removed'
-- Logs begin at Fri 2020-04-03 11:15:20 MSK, end at Fri 2020-04-03 20:51:11 MSK. --
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "BASH_FUNC_ml%%"
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "BASH_FUNC_module%%"
Apr 03 20:44:31 rapidus startplasma-x11[170521]: program: "dbus-update-activation-environment" environment variable removed: "LMOD_sys"
Created attachment 1676096 [details]
plasma-workspace-5.18.4.1-filter-environment-v2.patch
Thanks, triaging to plasma-workspace component Applied latest patch submission to plasma-workspace : %changelog * Thu Apr 09 2020 Rex Dieter <rdieter> - 5.18.4.1-2 - update patch "Qt applications lose system theme if launched via dbus activation" (#1754395) As of most recent updates it appears to be fixed now. At least I can launch KDE programs from the launcher and they're coming up with the right theme instead of a light theme. https://github.com/systemd/systemd/pull/17188 should resolve this. This message is a reminder that Fedora 31 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '31'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 31 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. seems this has come back again. at least when launching from krunner I confirm this, on Fedora 33 with Plasma 5.20 apps launched from krunner use Fusion theme. xdg-desktop-portal-kde also uses Fusion theme for me. Appears the previous patch/workaround not longer works indeed. Looks like systemd PR was merged, https://github.com/systemd/systemd/pull/17188 I'll try to find out which systemd versions include that fix (and/or lobby to get it backported to fedora's packaged systemd) I'm backporting that PR to F33 now. Is systemd-246.7-2.fc33.x86_64 from updates-testing supposed to fix this? I updated to that version just now and I still have to remove the Lmod package or I get same issue. (In reply to P D from comment #41) > Is systemd-246.7-2.fc33.x86_64 from updates-testing supposed to fix this? I > updated to that version just now and I still have to remove the Lmod package > or I get same issue. Yeah, it was. My understanding was that the issue was caused by 'systemctl import-environment' totally failing when at least one envvar was rejected. This is not the case any more: $ rpm -q systemd Lmod systemd-246.7-2.fc33.x86_64 Lmod-8.4.1-1.fc33.x86_64 $ systemctl --user show-environment | wc -l 8 $ systemctl --user import-environment 'BASH_FUNC_module%%=' Not a valid environment variable name: BASH_FUNC_module%%= $ SYSTEMD_LOG_LEVEL=debug systemctl --user import-environment running_in_chroot(): Permission denied Bus n/a: changing state UNSET → OPENING sd-bus: starting bus by connecting to /run/user/1000/systemd/private... Bus n/a: changing state OPENING → AUTHENTICATING Ignoring invalid environment assignment "BASH_FUNC_ml%%=() { eval $($LMOD_DIR/ml_cmd \"$@\")\n}". Ignoring invalid environment assignment "BASH_FUNC_module%%=() { eval $($LMOD_CMD bash \"$@\") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)\n}". Bus n/a: changing state AUTHENTICATING → RUNNING Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=SetEnvironment cookie=1 reply_cookie=0 signature=as error-name=n/a error-message=n/a Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=n/a error-name=n/a error-message=n/a Bus n/a: changing state RUNNING → CLOSED $ systemctl --user show-environment | wc -l 45 As you can see, the import works, and the two bash-function-variables are ignored, as intended. (Initially the plan was to allow such variables to be set, but that proved unworkable. See the upstream bug for all the gory history.) If you still see the issue, then maybe it's caused by something else now. Is there a way to blacklist a package in DNF? If so, Maybe Fedora KDE should just blacklist the Lmod package by default so new users don't run into this issue. Lmod is there for a reason. The bug needs to be figured out and resolved. I discovered the bug affects only KDE for X Windows. KDE Wayland works fine. I'm using F33 KDE Spin, testing repositories enabled, and I can confirm this is still happening. Somebody who uses kde should then figure this out. It seems that it must be caused by something else than systemd at this point. It's something to do with dbus-activated services, that they aren't inheriting the full user environment. $ dbus-update-activation-environment --all --systemd dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments Oh, OK. So one option is too let dbus-update-activation-environment filter what it is sending, because org.freedesktop.systemd1.Manager.SetEnvironment will reject an assignment if some values are invalid. But it'd be even better to not import the whole environment block from the caller. Right now we end up with stuff like $HISTCONTROL, $OLDPWD, $PWD, $SHLVL, and bunch of other stuff that makes no sense as globals. Instead, only select environment variables that are relevant to all processes should be imported. My gross workaround so far: ~/.config/plasma-workspace/env/99-dbus-update-activation-environment.sh containing: dbus-update-activation-environment --systemd $(declare -xp | sed -e 's|^declare -x ||g') I had the same problem. It turned out that in dbus-daemon it was not running in user space (it was not active) I tried that "gross" workaround solution for testing purpose as well and that cause and issue after reboot (black-screen stuck after SDDM passed(logined)). (In reply to Rex Dieter from comment #50) > My gross workaround so far: > > ~/.config/plasma-workspace/env/99-dbus-update-activation-environment.sh > containing: > > dbus-update-activation-environment --systemd $(declare -xp | sed -e > 's|^declare -x ||g') This seems to cause the shutdown/restart etc dialog not to appear when triggered. Only removing Lmod seems to "solve" this issue without any visible drawbacks. So, I've been barking up the wrong tree... with plasma-5.20 upstream decided to write their own environment sync code and not use dbus-update-activation-environment anymore. Some relevant upstream commits: "[startkde] Replace calling dbus-update-activation-environment with native code " https://invent.kde.org/plasma/plasma-workspace/-/commit/1e444c864fc175b3826c88a51a5e2c9f95e497c3 "Syncronise environment to user systemd session" https://invent.kde.org/plasma/plasma-workspace/-/commit/77f418500e56e3227828d26619aeba462a5c8227 There was a bit of validation done in a relatively recent commit, but that probably needs more work then: https://invent.kde.org/plasma/plasma-workspace/-/commit/875bcf1918381873f11eaa286ee3e8780c069676 Interesting, went to try to debug this more today, and can no longer reproduce the issue. Possibly fixed by systemd-246.7-2.fc33 https://bodhi.fedoraproject.org/updates/FEDORA-2020-3616681a70 I can still reproduce it. Install Lmod, start KDE in X11 mode, launch spectacle or dolphin from krunner, no theme. (In reply to Rex Dieter from comment #55) > Interesting, went to try to debug this more today, and can no longer > reproduce the issue. > > Possibly fixed by systemd-246.7-2.fc33 > https://bodhi.fedoraproject.org/updates/FEDORA-2020-3616681a70 I can still reproduce it too. rpm -q systemd Lmod systemd-246.7-2.fc33.x86_64 Lmod-8.4.1-1.fc33.x86_64 I take it back too, I swear it didn't happen for ~3 repeated logins when testing, but I can vouche that issue has returned (consistently) for me again since yesterday. I can confirm too, bug still affects my system (5.9.16-200.fc33.x86_64). Pretty resilient. After being annoyed with this for a few months, I sat down and looked at this today. And I've found a way, I believe. It works for me at least! I submitted the patch upstream: https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/569 The patch "plasma-workspace-5.18.4.1-filter-environment-v2.patch" is not needed with this change. Thanks, I can confirm the upstream merge_request fix works as advertised! Cookies, hero badge, and gratitude to Jonas. patched fedora builds underway. FEDORA-2021-ea19dabe82 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-ea19dabe82 FEDORA-2021-ea19dabe82 has been pushed to the Fedora 33 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-ea19dabe82` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-ea19dabe82 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. Confirmed fixed. Thanks Jonas! :D The above patch also circumvents #1897717 but doesn't appear to resolve the root cause. I'll comment more in #1912046 FEDORA-2021-ea19dabe82 has been pushed to the Fedora 33 stable repository. If problem still persists, please make note of it in this bug report. (In reply to Fedora Update System from comment #66) > FEDORA-2021-ea19dabe82 has been pushed to the Fedora 33 stable repository. > If problem still persists, please make note of it in this bug report. problem is finally gone. Thanks everybody. |
Created attachment 1618064 [details] dolphin-ugly Description of problem: Note: I couldn't find which component to file this bug under so I picked dolphin because this bug affects dolphin (as well as other qt applications) When launching a KDE / QT application such as Dolphin or Spectacle from an application that utilizes qdbus, the qt application will lose the user selected widget style (usually breeze) and use the ugly default qt theme. For example, in the dropbox flatpak from flathub, if I open dropbox folder from the tray icon, dolphin launches without theming and looks ugly. Or if I enabled the file / folder search in krunner, and open a folder that exists on my system in dolphin with krunner, it loses the theme. If I launch Dolphin (only the application, just launching from the .desktop file) in krunner the theme works. This issue can be quickly reproduced by launching Spectacle in the terminal normally (theme works), then launching it with this command: qdbus org.kde.Spectacle / StartAgent in which spectacle launches without the theme (ugly) Version-Release number of selected component (if applicable): not sure what component provides qdbus How reproducible: Very. Steps to Reproduce: 1. launch spectacle in terminal normally (theme works) 2. close spectacle 3. launch spectacle with this command: qdbus org.kde.Spectacle / StartAgent 4. notice theme looks ugly Actual results: When launching a qt application from qdbus or from flatpak it loses the theme. Expected results: The theme should work when launching qt applications in this way. Additional info: Attached is an screenshot of what Dolphin looks like on my system when launching from dropbox flatpak or selecting a folder in krunner. (dolphin-ugly.png) Also attached is what dolphin looks like when launching normally. (dolphin-normal.png)