Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Chooser does not open for Flatpak Applications #485

Open
Dutt-A opened this issue Jul 21, 2024 · 5 comments
Open

File Chooser does not open for Flatpak Applications #485

Dutt-A opened this issue Jul 21, 2024 · 5 comments

Comments

@Dutt-A
Copy link

Dutt-A commented Jul 21, 2024

Hello,

I'm on a mostly fresh install of Fedora Sway 40, and whenever I hit a button that should result in the file chooser opening up (like I try to Download something in Ungoogled Chromium or set my library in Steam), nothing happens. I've gotten stuck trying to look at fixes and debug it myself, so I was wondering if I could get some help.


system information

OS: Fedora Linux 40 (Sway) x86_64 
Kernel: 6.9.9-200.fc40.x86_64

sway information

Name         : sway
Version      : 1.9
Release      : 1.fc40
Architecture : x86_64
Size         : 861 k
Source       : sway-1.9-1.fc40.src.rpm
Repository   : @System
From repo    : anaconda
Summary      : i3-compatible window manager for Wayland
URL          : https://github.com/swaywm/sway

xdg portal package information

Name         : xdg-desktop-portal-wlr
Version      : 0.7.1
Release      : 1.fc40
Architecture : x86_64
Size         : 111 k
Source       : xdg-desktop-portal-wlr-0.7.1-1.fc40.src.rpm
Repository   : @System
From repo    : anaconda

Name         : xdg-desktop-portal
Version      : 1.18.4
Release      : 1.fc40
Architecture : i686
Size         : 488 k
Source       : xdg-desktop-portal-1.18.4-1.fc40.src.rpm
Repository   : updates
Summary      : Portal frontend service to flatpak
URL          : https://github.com/flatpak/xdg-desktop-portal/

Name         : xdg-desktop-portal
Version      : 1.18.4
Release      : 1.fc40
Architecture : x86_64
Size         : 2.3 M
Source       : xdg-desktop-portal-1.18.4-1.fc40.src.rpm
Repository   : @System
From repo    : updates
Summary      : Portal frontend service to flatpak
URL          : https://github.com/flatpak/xdg-desktop-portal/

The last thing I tried to do to fix this was to reinstall Fedora Sway spin while keeping my home directory, but nothing got fixed. On my last install I was trying to get my gtk and qt6 themes to work together with kvantum, and it may be possible along the way that I deleted something important in the ~/home/username directory. (I recall deleting ~/.local/gtk-2.0 and ~/.local/gtk-3.0.

I also have the following files in /usr/share/xdg-desktop-portal:


/usr/share/xdg-desktop-portal/sway-portals

[preferred]
# Use xdg-desktop-portal-gtk for every portal interface...
default=gtk
# ... except for the ScreenCast, Screenshot and Secret
org.freedesktop.impl.portal.ScreenCast=wlr
org.freedesktop.impl.portal.Screenshot=wlr
org.freedesktop.impl.portal.Secret=gnome-keyring

/usr/share/xdg-desktop-portal/wlroots-portals

[preferred]
# Use xdg-desktop-portal-gtk for every portal interface...
default=gtk
# ... except for the ScreenCast and Screenshot
org.freedesktop.impl.portal.ScreenCast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

/usr/share/xdg-desktop-portal/portals/gnome-keyring.portal

[portal]
DBusName=org.freedesktop.secrets
Interfaces=org.freedesktop.impl.portal.Secret
UseIn=gnome

/usr/share/xdg-desktop-portal/portals/gtk.portal

[portal]
DBusName=org.freedesktop.impl.portal.desktop.gtk
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.Settings;
UseIn=gnome

/usr/share/xdg-desktop-portal/portals/wlr.portal

[portal]
DBusName=org.freedesktop.impl.portal.desktop.wlr
Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.ScreenCast;
UseIn=wlroots;sway;Wayfire;river;phosh;Hyprland;

Any debugging tips or hints for where I should look next would be much appreciated. Thanks.

(Note: I posted this in originally in https://github.com/swaywm/sway/issues/8260, but I then noticed that 1 or 2 xdg-related issues got redirected to here, naturally.)

Another note is that the accessing the system print dialog from Flatpak Ungoogled Chromium actually does work, though I have no printers configured.

@TingPing
Copy link
Member

You can get some logs with /usr/libexec/xdg-desktop-portal-gtk --replace --verbose, same for the main portal.

@Dutt-A
Copy link
Author

Dutt-A commented Jul 22, 2024

Very interesting...

So using this method, I first typed your command into console. Then I went onto DuckDuckGo and searched up some images of fat dachsunds on flatpak ungoogled-chromium, and the GTK file chooser worked! I was able to download a fat dachsund with the GTK file chooser.

But as soon as I tried to download another fat dachsund without /usr/libexec/xdg-desktop-portal-gtk --replace --verbose running, I could not download the fat dachsund because the GTK file chooser didn't open. Other than that, the file chooser seems to spit out some warnings,

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:56:13.661: Unhandled parent window type 


(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:56:13.661: Failed to associate portal window with parent window 

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:56:18.889: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:56:49.217: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:57:19.536: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:57:49.845: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:58:09.533: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

(xdg-desktop-portal-gtk:75931): xdg-desktop-portal-gtk-WARNING **: 22:58:39.856: Backend call failed: Cannot invoke method; proxy is for the well-known name org.freedesktop.ScreenSaver without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

But that itself was enough to get to the crux of the bug! Something probably isn't running that should be in the background!

@Dutt-A
Copy link
Author

Dutt-A commented Jul 22, 2024

It looks like xdg-desktop-portal-gtk.service is enabled, but it keeps failing upon startup, thereby not running when it is called by applications later on

$ systemctl --user status xdg-desktop-portal-gtk | cat
× xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-gtk.service; static)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Mon 2024-07-22 08:09:19 EDT; 13min ago
    Process: 1439 ExecStart=/usr/libexec/xdg-desktop-portal-gtk (code=exited, status=1/FAILURE)
   Main PID: 1439 (code=exited, status=1/FAILURE)
        CPU: 15ms

Jul 22 08:09:19 fedora systemd[1280]: Failed to start xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation).
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Start request repeated too quickly.
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Jul 22 08:09:19 fedora systemd[1280]: Failed to start xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation).
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Start request repeated too quickly.
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Jul 22 08:09:19 fedora systemd[1280]: Failed to start xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation).
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Start request repeated too quickly.
Jul 22 08:09:19 fedora systemd[1280]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Jul 22 08:09:19 fedora systemd[1280]: Failed to start xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation).

@TingPing
Copy link
Member

TingPing commented Jul 22, 2024

A possibility is xdg-desktop-portal-gtk it is executed in a different environment than your shell, so could behave different. You may need to import some env vars.

@Dutt-A
Copy link
Author

Dutt-A commented Jul 22, 2024

I have another idea for what is going on. After login, the message in systemctl looks like this:

systemctl --user status xdg-desktop-portal-gtk | cat
× xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-gtk.service; static)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Mon 2024-07-22 15:21:05 EDT; 9min ago
    Process: 1816 ExecStart=/usr/libexec/xdg-desktop-portal-gtk (code=exited, status=1/FAILURE)
   Main PID: 1816 (code=exited, status=1/FAILURE)
        CPU: 15ms

Jul 22 15:21:05 fedora systemd[1275]: Starting xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)...
Jul 22 15:21:05 fedora xdg-desktop-por[1816]: cannot open display: 
Jul 22 15:21:05 fedora systemd[1275]: xdg-desktop-portal-gtk.service: Main process exited, code=exited, status=1/FAILURE
Jul 22 15:21:05 fedora systemd[1275]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Jul 22 15:21:05 fedora systemd[1275]: Failed to start xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation).

I found that another user here was getting the same error message but managed to solve it by installing lightdm (a login manager).

Using a login manager like lightdm will ensure that both the display server and xdg-desktop-portal-gtk are started at the same time. The issue is that without a login manager, what is going on is that xdg-desktop-portal-gtk is trying to call display without sway being started first, which creates the issue.

The bandaid solution is then to plop
exec /usr/libexec/xdg-desktop-portal-gtk
into my sway config file so the portal is started when sway is started (This is what I'm doing for now).

But ideally, either xdg-desktop-portal-gtk should always be started after the display server is started or xdg-desktop-portal-gtk should never call screen until the display server is started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants