Bug 469839 - X11 applications may not autostart properly in a Wayland session due to various important environment variables not being set
Summary: X11 applications may not autostart properly in a Wayland session due to vario...
Status: REPORTED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (show other bugs)
Version: 5.27.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2023-05-16 07:58 UTC by einbert-xeride
Modified: 2024-03-16 01:04 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description einbert-xeride 2023-05-16 07:58:07 UTC
SUMMARY

Autostarted applications may miss some important environment variables crucial for properly starting X11 applications in a Wayland session.

STEPS TO REPRODUCE
1. Add any X11 application to the autostarted application list.
2. Restart and watch how it behaves.

OBSERVED RESULT

It depends (it may hang or may not start). Generally can't be considered as "working".

EXPECTED RESULT

It shoud work as in X11 sessions.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux, Wayland sessions only
(available in About System)
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.106.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION

This is found when investigating Jetbrains Toolbox hang when autostarted in a Wayland session. JB Toolbox will show a tray icon and then freeze, with 100% CPU usage and no respond to click on the tray icon (which will typically open the JB Toolbox window). This issue exists for at least months. Such issue will disappear if manually started from the application launcher, or by manually invoking `<dir-of-toolbox-bin>/jetbrains-toolbox --minimize`. A simple perf shows that JB Toolbox is busy calling `xcb_wait_for_event` during the hang. It also doesn't appear in the output of `xlsclients` during the hang. After that I guessed that this issue may related to autostarting X11 applications in KDE.

So I made another attempt of autostarting Chrome in a Wayland session. Due to a Chrome 113 bug I'm using it without `--ozone-platform-hint=auto` which will make Chrome always use X11. Autostarting an X11 Chrome doesn't work as well. No window is displayed and the chrome process simply quits.

After further investigation I found that autostarted applications don't have some special environment variables, namely:

- DISPLAY
- GTK2_RC_FILES
- GTK_RC_FILES
- SESSION_MANAGER
- WAYLAND_DISPLAY
- XAUTHORITY

and have these environment variables different from manually started applications:

- INVOCATION_ID
- JOURNAL_STREAM

And found two of these environment variables are necessary:

- DISPLAY: unset this one makes JB Toolbox hang, as behaved when autostarted.
- XAUTHORITY: unset this one makes JB Toolbox quit with status code 44.

PS:

There's another issue I once encountered that is also related to autostart. Autostarted KeePassXC will use a bright theme instead of the dark theme (I uses Breeze Dark) when [View -> Theme] is [Automatic]. It will properly use the dark theme when manually started. This may also be a plasma issue as it started to appear after a plasma upgrade months ago, and appears on X11 session as well. I didn't pay much effort investigating it as it's not as frustrating as a hanging application, and may simply disappear after the huge refactoring towards KDE 6.
Comment 1 Nate Graham 2023-05-16 19:08:24 UTC
Good investigation, thanks a lot for that.
Comment 2 Waoweens 2024-03-12 22:08:24 UTC
I can confirm this happens on Plasma 6. Didn't happen on Plasma 5 though

Steam fails to autostart, "Unable to open a connection to X" "Check your DISPLAY environment variable and make sure that you have enabled X."

Operating System: Arch Linux 
KDE Plasma Version: 6.0.1
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.9-arch1-1 (64-bit)
Graphics Platform: Wayland