regolith-desktop icon indicating copy to clipboard operation
regolith-desktop copied to clipboard

Long delays for app launch of x11 and sway sessions on mantic

Open kgilmer opened this issue 1 year ago • 46 comments

This issue is blocking the Regolith 3.1 beta release

probably related:

  • https://bugzilla.redhat.com/show_bug.cgi?id=2176759
  • https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/74
  • https://forum.manjaro.org/t/very-slow-startup-on-some-apps-after-update/141806

kgilmer avatar Oct 29 '23 15:10 kgilmer

Verified that the package causing the issue (xdg-desktop-portal-gnome) is installed by default in Mantic. Unsure of the repercussions to flatpack users if we add a conflicts such that this package is removed upon Regolith install. Searching for workarounds that do not require removal of packages, but so far no luck.

kgilmer avatar Oct 29 '23 15:10 kgilmer

It looks like a fix was merged upstream a few months: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/95

cjthompson avatar Nov 02 '23 17:11 cjthompson

I worked-around this issue by masking the systemd-unit: systemctl --user mask xdg-desktop-portal-gnome

Unfortunately this breaks screen sharing. Setting XDG_CURRENT_DESKTOP=sway as per https://github.com/orgs/regolith-linux/discussions/914 restores the functionality but seems to have other side effects, such as not allowing me to run gnome-control-center

Anyone got a better workaround?

neilbags avatar Nov 02 '23 20:11 neilbags

deeper down the rabbit hole: https://github.com/linuxmint/cinnamon/issues/11857

kgilmer avatar Nov 03 '23 01:11 kgilmer

It looks like a fix was merged upstream a few months: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/95

I could be wrong but this fix only applies in cases where wayland and x11 backends fail to initialize for some reason. In grepping logs on an affected machine, I don't notice this error path executing (the path that provides only settings). I don't think this particular patch applies to our situation, but would love to hear if I'm incorrect.

kgilmer avatar Nov 03 '23 01:11 kgilmer

This appears to be the intended escape hatch for DEs like regolith, but early attempts at setting this up don't result in a fix.

https://man.archlinux.org/man/portals.conf.5

kgilmer avatar Nov 03 '23 01:11 kgilmer

My working theory is that it is possible to use portals.conf to route dbus bindings to the appropriate portal backends for Regolith. This hypothetical configuration would prevent the xdg-desktop-portal-gnome portal from being invoked in cases that timeouts would occur.

This theory rests in part upon the guess that the app launch delays are a result of timeouts (vs something else). eg

xdg-desktop-por[62144]: Failed to create settings proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached

I've tried ~10 variations on this, and have noticed changes in log failures based on variation (leading me to guess that the regolith config is being read, although I have no direct evidence), but have yet to be able to launch apps upon session start without the delay if the gnome portal package is installed.

~$ cat /usr/share/xdg-desktop-portal/regolith-portals.conf
[preferred]
default=wlr;gtk;

kgilmer avatar Nov 03 '23 02:11 kgilmer

this command's output seems helpful:

$ /usr/libexec/xdg-desktop-portal --verbose

evidence that regolith config file is being loaded:

XDP: Using portal configuration file '/usr/share/xdg-desktop-portal/regolith-portals.conf' for desktop 'regolith'

a hint at what's causing the delay (this log entry is printed after ~1 min delay, when xdg-desktop-portal-gnome is installed:

(/usr/libexec/xdg-desktop-portal:81487): xdg-desktop-portal-WARNING **: 00:40:10.425: Failed to create background proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached

kgilmer avatar Nov 03 '23 07:11 kgilmer

Budgie DE's portal config: https://github.com/BuddiesOfBudgie/budgie-desktop/blob/main/data/budgie-portals.conf

kgilmer avatar Nov 03 '23 19:11 kgilmer

Verified that previous ubuntu versions (23.04) did contain the package xdg-portal-desktop-gnome (version 44)

kgilmer avatar Nov 04 '23 05:11 kgilmer

Filed an issue against GNOME for help: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/104

kgilmer avatar Nov 04 '23 05:11 kgilmer

Configuration elements believed to be associated with this issue:

  • XDG_CURRENT_DESKTOP value
  • /usr/share/xdg-desktop-portal/regolith-portals.conf
  • Debian package xdg-desktop-portal-gnome

kgilmer avatar Nov 04 '23 05:11 kgilmer

Debugging tool: https://github.com/bilelmoussaoui/ashpd

kgilmer avatar Nov 06 '23 02:11 kgilmer

https://github.com/bilelmoussaoui/ashpd/issues/174

kgilmer avatar Nov 12 '23 18:11 kgilmer

vala based backend implementation: https://github.com/elementary/portals

kgilmer avatar Nov 12 '23 19:11 kgilmer

For what it's worth, I was having this issue after updating to mantic. I ended up running sudo apt purge xdg-desktop-portal-gnome and it solved my problem. I admit to basically having no idea what I'm doing with this stuff but I don't seem to have created a different problem for myself. Zoom screen sharing still works, Flameshot still works, the Gnome settings app still works.

I can post any configuration, environment settings or logs if that would be helpful.

Edit 27-NOV-2023: Full screen sharing works but I have lost the ability to share just a specific window

dpbackes avatar Nov 17 '23 15:11 dpbackes

Thanks for the feedback @dpbackes!

Zoom screen sharing still works, Flameshot still works, the Gnome settings app still works.

Do you mean, these work within a Regolith session, or another session? I guess my concern is that not having xdg-desktop-portal-gnome installed will cause regressions while using gnome-shell or other gnome-based sessions.

kgilmer avatar Nov 22 '23 17:11 kgilmer

I have had some limited success in overcoming what I believe to be the rootcause for the launch delay:

xdg-desktop-por[5678]: Failed to create settings proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached

I took the Elementary OS portal implementation and modified it to be the "Regolith" portal backend (see patch). I updated the dbus bindings such that it responds to the org.freedesktop.impl.portal.desktop.gnome dbus name.

If I manually start the backend from the command-line, and then launch a gtk-based app (calculator), the timeout message does not appear in the log and the app does not appear to have a startup delay, while logged into the X11 regolith session and having xdg-desktop-portal-gnome installed.

~$ /usr/libexec/xdg-desktop-portal-regolith -r -v
** (xdg-desktop-portal-regolith:7347): DEBUG: 09:18:04.504: XdgDesktopPortalRegolith.vala:36: Access Portal registered!
** (xdg-desktop-portal-regolith:7347): DEBUG: 09:18:04.504: XdgDesktopPortalRegolith.vala:39: AppChooser Portal registered!
** (xdg-desktop-portal-regolith:7347): DEBUG: 09:18:04.505: XdgDesktopPortalRegolith.vala:42: Background Portal registered!
** (xdg-desktop-portal-regolith:7347): DEBUG: 09:18:04.506: XdgDesktopPortalRegolith.vala:49: org.freedesktop.impl.portal.desktop.gnome acquired
** (xdg-desktop-portal-regolith:7347): DEBUG: 09:18:13.346: XdgDesktopPortalRegolith.vala:57: bus watch 2

elementary-portal-patch.diff.zip

It's unclear to me why the portals broker is not automatically loading my backend. I did not spend much time with the patching though, it could be that I missed something. I believe my backend should be being loaded because:

  1. XDG_CURRENT_SESSION = Regolith;GNOME-Flashback;GNOME
  2. /usr/share/xdg-desktop-portal/portals/regolith.portal exists

CC @SoumyaRanjanPatnaik

kgilmer avatar Nov 22 '23 17:11 kgilmer

Hey. I was going to try and replicate your findings on my system. So I installed the xdg-desktop-portal-gnome package. But surprisingly enough, the launch delay did not exist for me.

I have no idea what fixed it. Maybe an update to xdg-desktop-portal? Sounds unlikely. Do you have any ideas how I can re-bug my system and in the process, figure out a potential fix?

SoumyaRanjanPatnaik avatar Nov 22 '23 20:11 SoumyaRanjanPatnaik

Maybe this? - https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/95

SoumyaRanjanPatnaik avatar Nov 22 '23 20:11 SoumyaRanjanPatnaik

BTW you might to look at these issues /comments -

  • https://github.com/flatpak/xdg-desktop-portal/pull/955#issuecomment-1705301396
  • https://github.com/flatpak/xdg-desktop-portal/issues/656#issuecomment-966276573

SoumyaRanjanPatnaik avatar Nov 22 '23 20:11 SoumyaRanjanPatnaik

Thanks for the links Soumya. I'm digging more into what org.freedesktop.impl.portal.desktop.gnome provides,as it seems to be most directly related to the issue.

Do you have any ideas how I can re-bug my system and in the process, figure out a potential fix?

I have a test environment setup with Mantic and unreleased Regolith 3.1 snapshot that's in currently in testing. I can repro the issue, and my packages are up to date so expect the issue is still present but LMK if you see different behavior in a clean setup.

kgilmer avatar Nov 24 '23 15:11 kgilmer

It seems that org.freedesktop.impl.portal.desktop.gnome is just the gnome-specific interface that the portal broker (xdg-desktop-portal) is to delegate when configured to use the gnome portal backend. As in, it does not offer some specific application interface itself, but is rather the middleman interface (I'm guessing).

Based on this, the question becomes, why is it not possible to compose a Regolith portal config file that prevents the portal broker from trying to instantiate this non-existent dbus service in the Regolith session.

kgilmer avatar Nov 24 '23 15:11 kgilmer

Adding the following file (copied and adapted from gnome-portals.conf) causes the regolith backend to be loaded upon desktop session start by the portals broker:

$ cat /usr/share/xdg-desktop-portal/regolith-portals.conf 
[preferred]
default=regolith;gtk;
org.freedesktop.impl.portal.Access=gtk;
org.freedesktop.impl.portal.Secret=gnome-keyring;

kgilmer avatar Nov 24 '23 17:11 kgilmer

Updating the regolith portals configuration file to "handle" (do not handle, but by declaring in the file, presumably preventing the broker from trying to invoke the gnome portal backend with it's lengthy timeout) allows the Regolith X11 session to coexist with the gnome portal backend. I don't this in itself is "the fix" but provides backing proof for basis for a proper solution.

$ cat /usr/share/xdg-desktop-portal/portals/regolith.portal 
[portal]
DBusName=org.freedesktop.impl.portal.desktop.regolith
Interfaces=org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Print;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.Inhibit;org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Account;org.freedesktop.impl.portal.Email;org.freedesktop.impl.portal.DynamicLauncher;org.freedesktop.impl.portal.Lockdown;org.freedesktop.impl.portal.Settings;org.freedesktop.impl.portal.Background;org.freedesktop.impl.portal.Wallpaper;org.freedesktop.impl.portal.ScreenCast;org.freedesktop.impl.portal.RemoteDesktop;org.freedesktop.impl.portal.Clipboard;org.freedesktop.impl.portal.InputCapture;org.freedesktop.impl.portal.Screenshot;
UseIn=regolith

I amended the "Implements" section by observing in /var/log/syslog the interfaces the portal broker was calling into the gnome backend with, and then adding them. Once they were all added the launch behavior appears to no longer timeout on the gnome portal backend.

kgilmer avatar Nov 24 '23 17:11 kgilmer

Going back to a previous experiment that I want to retry given findings in the last post, I uninstalled the regolith portal backend from my test environment. I created a regolith-portals.conf file that maps all dbus names to the gtk backend. However, at runtime I see that the portal broker continues to try calling into the gnome portal backend despite my explicit mapping in the config file. This behavior seems to be incorrect, will post a question on upstream ticket to see if I've missed something such that this issue can be resolved without a custom portal implementation.

$ cat /usr/share/xdg-desktop-portal/regolith-portals.conf 
[preferred]
default=gtk;
org.freedesktop.impl.portal.Secret=gnome-keyring;

org.freedesktop.impl.portal.Access=gtk;
org.freedesktop.impl.portal.Account=gtk;
org.freedesktop.impl.portal.AppChooser=gtk;
org.freedesktop.impl.portal.Background=gtk;
org.freedesktop.impl.portal.Clipboard=gtk;
org.freedesktop.impl.portal.DynamicLauncher=gtk;
org.freedesktop.impl.portal.Email=gtk;
org.freedesktop.impl.portal.FileChooser=gtk;
org.freedesktop.impl.portal.Inhibit=gtk;
org.freedesktop.impl.portal.InputCapture=gtk;
org.freedesktop.impl.portal.Lockdown=gtk;
org.freedesktop.impl.portal.Notification=gtk;
org.freedesktop.impl.portal.Print=gtk;
org.freedesktop.impl.portal.RemoteDesktop=gtk;
org.freedesktop.impl.portal.ScreenCast=gtk;
org.freedesktop.impl.portal.Screenshot=gtk;
org.freedesktop.impl.portal.Settings=gtk;
org.freedesktop.impl.portal.Wallpaper=gtk;
2023-11-24T10:20:57.834510-08:00 ltpt xdg-desktop-por[2731]: Failed to create screenshot proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
2023-11-24T10:20:57.835696-08:00 ltpt xdg-desktop-por[2731]: Choosing gnome.portal for org.freedesktop.impl.portal.Background via the deprecated UseIn key
2023-11-24T10:21:22.867919-08:00 ltpt xdg-desktop-por[2731]: Failed to create background proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
2023-11-24T10:21:22.869739-08:00 ltpt xdg-desktop-por[2731]: Choosing gnome.portal for org.freedesktop.impl.portal.Wallpaper via the deprecated UseIn key
2023-11-24T10:21:47.896237-08:00 ltpt xdg-desktop-por[2731]: Failed to create wallpaper proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
2023-11-24T10:21:47.921624-08:00 ltpt xdg-desktop-por[2731]: Choosing gnome.portal for org.freedesktop.impl.portal.ScreenCast via the deprecated UseIn key

kgilmer avatar Nov 24 '23 18:11 kgilmer

Can you try running /usr/libexec/xdg-desktop-portal-gnome ? I get the following:

Non-compatible display server, exposing settings only.

This is exactly the fix introduced in https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/95. And fixes https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/74.

SoumyaRanjanPatnaik avatar Nov 24 '23 19:11 SoumyaRanjanPatnaik

Also, here's what the logs for me look like:

XDP: Using gnome.portal for org.freedesktop.impl.portal.Settings (config)
XDP: Found 'gtk' in configuration for default
XDP: Using gtk.portal for org.freedesktop.impl.portal.Settings (config)
XDP: providing portal org.freedesktop.portal.Settings
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.FileChooser (config)
XDP: providing portal org.freedesktop.portal.FileChooser
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.AppChooser (config)
XDP: providing portal org.freedesktop.portal.OpenURI
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.Print (config)
XDP: providing portal org.freedesktop.portal.Print
XDP: Found 'gtk' in configuration for default
XDP: Using gtk.portal for org.freedesktop.impl.portal.Notification (config)
XDP: providing portal org.freedesktop.portal.Notification
XDP: Found 'gtk' in configuration for default
XDP: Using gtk.portal for org.freedesktop.impl.portal.Inhibit (config)
XDP: providing portal org.freedesktop.portal.Inhibit
XDP: Found 'gtk' in configuration for default
XDP: Using gtk.portal for org.freedesktop.impl.portal.Access (config)
XDP: providing portal org.freedesktop.portal.Device
XDP: providing portal org.freedesktop.portal.WebExtensions
XDP: providing portal org.freedesktop.portal.Location
XDP: providing portal org.freedesktop.portal.Camera
XDP: Found 'wlr' in configuration for default
XDP: Using wlr.portal for org.freedesktop.impl.portal.Screenshot (config)
XDP: providing portal org.freedesktop.portal.Screenshot
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.Background (config)
XDP: Starting background app monitor
XDP: providing portal org.freedesktop.portal.Background
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.Wallpaper (config)
XDP: providing portal org.freedesktop.portal.Wallpaper
XDP: Found 'gnome' in configuration for default
XDP: Using gnome.portal for org.freedesktop.impl.portal.Account (config)
XDP: using org.freedesktop.impl.portal.Account at org.freedesktop.impl.portal.desktop.gnome

Here's what my regolith-portals.conf looks like:

[preferred]
default=wlr;gtk;gnome

Notice that I'm not seeing the timeouts and the following error doesn't exist anymore:

Choosing gnome.portal for org.freedesktop.impl.portal.Background via the deprecated UseIn key

SoumyaRanjanPatnaik avatar Nov 24 '23 19:11 SoumyaRanjanPatnaik

Potential fix - setting the preferred value for interfaces that gnome exposes to none until we have our own portals implementation for some of these interfaces.

org.freedesktop.impl.portal.Access=none;
org.freedesktop.impl.portal.Account=none;
org.freedesktop.impl.portal.AppChooser=none;
.
.
.
org.freedesktop.impl.portal.Wallpaper=none;

Can you test this out?

SoumyaRanjanPatnaik avatar Nov 24 '23 19:11 SoumyaRanjanPatnaik

Can you try running /usr/libexec/xdg-desktop-portal-gnome ? I get the following:

Non-compatible display server, exposing settings only.

This is exactly the fix introduced in https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/95. And fixes https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/74.

On my test environment (X11, Mantic) I do not see anything about Non-compatible display server, exposing settings only. when running the backend. I have xdg-desktop-portal-gnome version 45.0-1 installed. I have verified from the Ubuntu source tarball for the package that the fix is indeed built into this version, but for some reason isn't being triggered for the x11 session on my test instance. I have not yet looked into the sway session, as I don't want to complexify test results for config changes across the sessions.

kgilmer avatar Nov 24 '23 20:11 kgilmer