sway: Slow launch for (some) GTK apps

Log shows launch to minimal desktop, followed by waybar appearing at ~15 sec as a result of being called from bar_command.

Lenovo X1Y4 with FC33, Kernel 5.9 and mesa-git, although also occuring on an Intel desktop with AMD GPU (also using mesa-git).

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 15
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

This might be related to the switch from wayland-0 to wayland-1? I solved something like this by putting a *.conf file in ~/.config/environment.d containing WAYLAND_DISPLAY=wayland-1.

Edit: try systemctl --user status xdg-desktop-portal.service. If that service failed with an error relating to the Wayland display, then that’s you’re problem. Specifically, GTK is trying to use the service here and it’s failing, with a long timeout.

Heard on IRC that adding exec systemctl --user import-environment to the config file helped with that for some reason…

Adding exec systemctl --user import-environment to my config and restarting fixed this issue for me as well

Not using sway, but ran into similar issue, as opposed to Michael, I didn’t have to get rid of all xdg-desktop-portal packages, only had to get rid of xdg-desktop-portal-gnome, which fixed the issue.

Same for me and adding exec systemctl --user import-environment not fix. But removing xdg-desktop-portal-gnome fix it ! I don’t use sandboxed app.

I had the same issue. I tried everything in the wiki and the recommendations from this issue. Unfortunately, nothing helped besides removing xdg-desktop-portal.

Later on, I figured out that I had some other portal backends installed like xdg-desktop-portal-gtk. After I removed every package that started with xdg-desktop-portal- and xdg-desktop-portal I installed xdg-desktop-portal-wlr again, which installed xdg-desktop-portal as dependency, everything worked. Besides that, I only have include /etc/sway/config.d/* in my sway config, which currently includes the file /etc/sway/config.d/50-systemd-user.conf containing the following two lines.

exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
exec hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP

I’m uncertain if the file is available on every distribution, so check that first, i.e., using cat /etc/sway/config.d/* which should print them. If not, just put them in your sway config instead of the include ... line.

@wmww Sure looks that way:

● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
     Active: failed (Result: timeout) since Wed 2020-10-14 08:13:45 NZDT; 7h ago
    Process: 4175 ExecStart=/usr/libexec/xdg-desktop-portal (code=killed, signal=TERM)
   Main PID: 4175 (code=killed, signal=TERM)
        CPU: 41ms

Oct 14 08:12:15 crackotage systemd[3828]: Starting Portal service...
Oct 14 08:13:05 crackotage xdg-desktop-por[4175]: Failed to create settings proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gtk: Timeout was reached
Oct 14 08:13:30 crackotage xdg-desktop-por[4175]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gtk: Timeout was reached
Oct 14 08:13:30 crackotage xdg-desktop-por[4175]: No skeleton to export
Oct 14 08:13:45 crackotage systemd[3828]: xdg-desktop-portal.service: start operation timed out. Terminating.
Oct 14 08:13:45 crackotage systemd[3828]: xdg-desktop-portal.service: Failed with result 'timeout'.
Oct 14 08:13:45 crackotage systemd[3828]: Failed to start Portal service.

Neither adding the environment variable, nor exec systemctl --user import-environment have seemed to help however.

Here’s a strace log from launching pavucontrol, noting the jump from 15:22:42 -> 15:22:57 and then to 15:23:07.

https://gist.github.com/tokyovigilante/872e9e24c061886ab19a14f9ae19ad3c

Note that because some distributions ship by default a similar script for X11, that explains why we’re the only ones seeing this.

https://github.com/systemd/systemd/blob/dfc637d0ff756889e8e5b7cb4ec991eb06069aa1/xorg/50-systemd-user.sh

Some systemd distributions like Arch Linux ship something similar by default:

https://github.com/archlinux/svntogit-community/blob/a334964ae6210e6dcbe5db094d51d7c27e6f89b0/trunk/50-systemd-user.conf

Obviously it’s not included by default in user config files.

I don’t think there’s much to be done here. I added a wiki entry to document the issue: https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start

xdg-desktop-portal-gnome was the culprit for me as well.

This was still an issue for my system, and will probably be for others. Mostly default Ubuntu 22.04.1 LTS with Sway installed, fixed with exec systemctl --user import-environment in my config. Sway version 1.7

FWIW the very end in my sway file runs exec "systemctl --user import-environment SWAYSOCK WAYLAND_DISPLAY; to ensure that my units see the correct $WAYLAND_DISPLAY. However this obviously breaks multi session logins of the same user, since my systemd user units will only ever work with the last started sway compositor.

Was going to edit the above post, but thanks for the speedy reply. Mysteriously fixed after a reboot with both fixes above applied. Are these true fixes and I can close this, or is there an underlying sway bug?

I’m on Hyprland, was having the same issues and fixed them by following their wiki, however, some GTK apps were still having the 25s timeout (Firefox and Virt-Manager, for me), even with GTK_USE_PORTAL=0, and I couldn’t get much relevant information from journalctl, but thankfully I ran into this blog post, and gnome-keyring-daemon was the root cause of my secondary issue.