regolith-linux / regolith-desktop

Meta package for the Regolith Desktop Environment
1.48k stars 31 forks source link

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

Open kgilmer opened 8 months ago

kgilmer commented 8 months ago

This issue is blocking the Regolith 3.1 beta release

probably related:

kgilmer commented 8 months ago

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.

cjthompson commented 8 months ago

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

neilbags commented 8 months ago

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?

kgilmer commented 8 months ago

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

kgilmer commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

kgilmer commented 8 months ago

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

kgilmer commented 8 months ago

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

kgilmer commented 8 months ago

Configuration elements believed to be associated with this issue:

kgilmer commented 8 months ago

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

kgilmer commented 7 months ago

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

kgilmer commented 7 months ago

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

dpbackes commented 7 months ago

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

kgilmer commented 7 months ago

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 commented 7 months ago

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

SoumyaRanjanPatnaik commented 7 months ago

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 commented 7 months ago

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

SoumyaRanjanPatnaik commented 7 months ago

BTW you might to look at these issues /comments -

kgilmer commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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
SoumyaRanjanPatnaik commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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?

kgilmer commented 7 months ago

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 commented 7 months ago

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?

Setting the regolith-portals.conf file to the following:

[preferred]
default=gtk;
org.freedesktop.impl.portal.Secret=gnome-keyring;

org.freedesktop.impl.portal.Access=none;
org.freedesktop.impl.portal.Account=none;
org.freedesktop.impl.portal.AppChooser=none;
org.freedesktop.impl.portal.Background=none;
org.freedesktop.impl.portal.Clipboard=none;
org.freedesktop.impl.portal.DynamicLauncher=none;
org.freedesktop.impl.portal.Email=none;
org.freedesktop.impl.portal.FileChooser=none;
org.freedesktop.impl.portal.Inhibit=none;
org.freedesktop.impl.portal.InputCapture=none;
org.freedesktop.impl.portal.Lockdown=none;
org.freedesktop.impl.portal.Notification=none;
org.freedesktop.impl.portal.Print=none;
org.freedesktop.impl.portal.RemoteDesktop=none;
org.freedesktop.impl.portal.ScreenCast=none;
org.freedesktop.impl.portal.Screenshot=none;
org.freedesktop.impl.portal.Settings=none;
org.freedesktop.impl.portal.Wallpaper=none;

When loading firefox I observe a ~15 second delay and see messages like:

2023-11-24T12:34:55.098991-08:00 ltpt xdg-desktop-por[2782]: Choosing gnome.portal for org.freedesktop.impl.portal.FileChooser via the deprecated UseIn key
2023-11-24T12:35:20.123802-08:00 ltpt xdg-desktop-por[2782]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
2023-11-24T12:35:20.124226-08:00 ltpt xdg-desktop-por[2782]: Choosing gnome.portal for org.freedesktop.impl.portal.AppChooser via the deprecated UseIn key
2023-11-24T12:35:45.150162-08:00 ltpt xdg-desktop-por[2782]: Failed to create app chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
2023-11-24T12:35:45.150933-08:00 ltpt xdg-desktop-por[2782]: Choosing gnome.portal for org.freedesktop.impl.portal.Print via the deprecated UseIn key
2023-11-24T12:35:59.926878-08:00 ltpt systemd[1714]: xdg-desktop-portal.service: start operation timed out. Terminating.
2023-11-24T12:35:59.931620-08:00 ltpt systemd[1714]: xdg-desktop-portal.service: Failed with result 'timeout'.
2023-11-24T12:35:59.932076-08:00 ltpt systemd[1714]: Failed to start xdg-desktop-portal.service - Portal service.
kgilmer commented 7 months ago

@SoumyaRanjanPatnaik what is your XDG_CURRENT_DESKTOP value?

SoumyaRanjanPatnaik commented 7 months ago

sway:Regolith:GNOME

dpbackes commented 7 months ago

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.

Yeah within regolith sessions. Haven't tried non-regolith sessions. I also have to amend my statement. Full screen sharing still works but I have lost the ability to share specific windows.

neilbags commented 7 months ago

Yeah within regolith sessions.

Are you on x11 or Wayland? I masked this systemd unit and the delay is gone but I have lost all screen sharing

dpbackes commented 7 months ago

X11

kgilmer commented 6 months ago

Related: https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1928689.html

kgilmer commented 6 months ago

We have a path forward for the 3.1 release, see this note for details: https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/104#note_1958055

kgilmer commented 6 months ago

@SoumyaRanjanPatnaik in my testing the portals config file you specified as fix seems to work fine for both X11 and Sway. LMK if we need to consider varations of this file based on session type.

newptcai commented 2 months ago

For me it is not a long delay. The launcher sometimes appear, sometimes doesn't. Often I have to try 5 times for it to appear.