You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Improve Linux XDG FileChooser implementation #31258
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
14.0.0
What operating system are you using?
Other Linux
Operating System Version
Linux any
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Support for the XDG FileChooser portal landed in Electron 14 #19159.
Electron should try to use the XDG FileChooser wherever it can.
Actual Behavior
There are cases where it is not used where it could be used (specifically on Ubuntu and in Flatpak, see below). The old non portal file chooser is used, meaning the work in #19159 is not taken advantage of.
Testcase Gist URL
No response
Additional Information
Any help on how to debug Electron here would be appreciated, as I’m not sure why this is happening.
Same problem for me on various Ubuntu systems with Electron 14 and 15, even with forcing GTK_USE_PORTAL=1 I still see old GTK file dialogs instead of native KDE, but on same system Firefox with GTK_USE_PORTAL=1 shows the KDE file dialogs, so seems in Electron the xdg portals are detected wrongly?
Keep in mind your system has to have a recent enough version of GTK3. I think >= 3.20. One way to double check if you are getting the XDG picker is to watch dbus calls on your system. You are looking for something along the lines of org.freedesktop.Portal.FileChooser
Hm, @tristan957 I noticed on Electron 16 while testing Jitsi Meet (Flatpak) and this demo (toolbox), it seems the portal works reliably now? I can clearly see the calls in Bustle, and within Flatpak I can choose beyond the sandbox. Even without GTK_USE_PORTAL=1 it's still using the portal.
@shimmark You really consider it optimal to force a two-stage "Pick a directory, now use our proprietary picker to pick a file within it" workflow on people for something like a directory fully of .mp4+.srt or .cue+.bin pairs?
...assuming the application developer will even be willing to support something like that, rather than just declaring tighter sandboxing an unsupported configuration.
(Or are you one of those people who actually likes iOS/iTunes-style "everything has its own library browser and that's how you interact with what it supports" UI design?)
Bear in mind that I'm far enough on the opposite end of the spectrum that I whipped up a proof of concept that generates non-reverse-DNS launcher wrappers for Flatpak'd applications so I can type mpv ... in the terminal and have it expand to flatpak run --file-forwarding "io.mpv.Mpv/x86_64/stable" @@u "$@" @@.
EDIT: Ignore this. I thought the previous message was something on flatpak/xdg-desktop-portal#463 that was arguing against it being necessary.
@shimmark Oops. Sorry. I got about half a dozen message notifications at the same time, got mixed up, and thought this wasflatpak/xdg-desktop-portal#463.
I figured out a solution which works for me after brief two hours of confusion.
#19159 tries to be safe in how it depends on libgtk by loading it dynamically and trying to find the dialog related functions dynamically. It does this by requesting a file called libgtk-3.so:
As a workaround, I linked the library (which seems to be common practice with sonames, but is for some reason applied very inconsistently by repository maintainers):
Restarting the electron application and triggering a file picker again confirmed that this was the issue.
(As an aside, the KDE file picker appeared behind the electron application which hints at an extra issue here. Setting a window override for window class xdg-desktop-portal-kde to force no focus stealing prevention fixed this, which makes me think this might caused by the parent window not being set?)
It seems to have been addressed already (indirectly) by way of 37b7e34 which came as part of #33650
That PR basically flipped to different dynamic referencing to shared library code that is known to be working for Chrome. Chrome shows the portal dialogs, so knows how to correctly get hold of the GTK native dialogs.
As far as I can tell (from the git branches), this has been on electron since version 18.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Activity
prozaiczyk commentedon Oct 2, 2021
X
MurzNN commentedon Oct 8, 2021
Same problem for me on various Ubuntu systems with Electron 14 and 15, even with forcing
GTK_USE_PORTAL=1I still see old GTK file dialogs instead of native KDE, but on same system Firefox withGTK_USE_PORTAL=1shows the KDE file dialogs, so seems in Electron the xdg portals are detected wrongly?ilya-zlobintsev commentedon Oct 10, 2021
The XDG Picker seems to work properly for me on Arch Linux with the
discord_arch_electronpackage andGTK_USE_PORTAL=1set.tristan957 commentedon Oct 14, 2021
Keep in mind your system has to have a recent enough version of GTK3. I think >= 3.20. One way to double check if you are getting the XDG picker is to watch dbus calls on your system. You are looking for something along the lines of org.freedesktop.Portal.FileChooser
MurzNN commentedon Oct 16, 2021
My Ubuntu have 3.24.25 version of GTK, and here is dbus call that I caught on file save event in app (Ferdi with Electron 15.2.0):
But still see the GTK file chooser.
And here is
dbuscall when opening file save dialog in Firefox:MurzNN commentedon Oct 16, 2021
And here is the
dbuscall onzenity --file-selectioncli command, that opens KDE choose file dialog as result:vchernin commentedon Dec 6, 2021
Hm, @tristan957 I noticed on Electron 16 while testing Jitsi Meet (Flatpak) and this demo (toolbox), it seems the portal works reliably now? I can clearly see the calls in Bustle, and within Flatpak I can choose beyond the sandbox. Even without
GTK_USE_PORTAL=1it's still using the portal.So that's something I guess.
tristan957 commentedon Dec 6, 2021
Hey that is awesome. Not sure what would have changed beyond that PR last week.
vchernin commentedon Dec 6, 2021
Yeah me neither, hopefully other apps update soon to 16 so it can be confirmed to work.
tristan957 commentedon Dec 6, 2021
VSCode is working on it, but there are still a couple of blockers. Will be cool when it does.
vchernin commentedon Dec 6, 2021
Yeah VScode will be interesting, although I'm not sure how useful the portal will be for them given flatpak/xdg-desktop-portal#463 and flatpak/xdg-desktop-portal#663 exists. Wouldn't an IDE need permanent access to a whole directory?
tristan957 commentedon Dec 6, 2021
I would think the VSCode flatpak has filesystem=host permissions. VSCode mainly just wants ability to pick file chooser at the moment.
vchernin commentedon Dec 6, 2021
Yeah, hopefully eventually they can move away from those static
filesystempermissions once/if the portal covers all their use cases.ssokolow commentedon Dec 6, 2021
@shimmark You really consider it optimal to force a two-stage "Pick a directory, now use our proprietary picker to pick a file within it" workflow on people for something like a directory fully of.mp4+.srtor.cue+.binpairs?...assuming the application developer will even be willing to support something like that, rather than just declaring tighter sandboxing an unsupported configuration.(Or are you one of those people who actually likes iOS/iTunes-style "everything has its own library browser and that's how you interact with what it supports" UI design?)Bear in mind that I'm far enough on the opposite end of the spectrum that I whipped up a proof of concept that generates non-reverse-DNS launcher wrappers for Flatpak'd applications so I can typempv ...in the terminal and have it expand toflatpak run --file-forwarding "io.mpv.Mpv/x86_64/stable" @@u "$@" @@.EDIT: Ignore this. I thought the previous message was something on flatpak/xdg-desktop-portal#463 that was arguing against it being necessary.
ssokolow commentedon Dec 6, 2021
@shimmark Oops. Sorry. I got about half a dozen message notifications at the same time, got mixed up, and thought this was flatpak/xdg-desktop-portal#463.
opl- commentedon Apr 17, 2022
I figured out a solution which works for me after brief two hours of confusion.
#19159 tries to be safe in how it depends on libgtk by loading it dynamically and trying to find the dialog related functions dynamically. It does this by requesting a file called
libgtk-3.so:https://github.com/tristan957/electron/blob/25b540187140463a4d0f9908bccc8606d2693bb4/shell/browser/ui/file_dialog_gtk.cc#L75
Debian, meanwhile, packages libgtk as
libgtk-3.so.0:As a workaround, I linked the library (which seems to be common practice with sonames, but is for some reason applied very inconsistently by repository maintainers):
Restarting the electron application and triggering a file picker again confirmed that this was the issue.
(As an aside, the KDE file picker appeared behind the electron application which hints at an extra issue here. Setting a window override for window class
xdg-desktop-portal-kdeto force no focus stealing prevention fixed this, which makes me think this might caused by the parent window not being set?)shoffmeister commentedon May 19, 2022
Fedora 36 does not ship
libgtk-3.soeither; creating it via softlink tolibgtk-3.so.0unbreaks the electron functionality.MurzNN commentedon May 19, 2022
For Ubuntu this trick works too, thanks!
So maybe we can improve this on Electron side, to detect
.0and other more precise versions of libraray?shoffmeister commentedon May 19, 2022
It seems to have been addressed already (indirectly) by way of 37b7e34 which came as part of #33650
That PR basically flipped to different dynamic referencing to shared library code that is known to be working for Chrome. Chrome shows the portal dialogs, so knows how to correctly get hold of the GTK native dialogs.
As far as I can tell (from the git branches), this has been on electron since version 18.
damnms commentedon May 24, 2022
for those on fedora (36), too lazy to read all that:
sudo ln /usr/lib64/libgtk-3.so.0 /usr/lib64/libgtk-3.so
at least that worked for me to upload files in element, thanks!
github-actions commentedon Oct 5, 2022
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
github-actions commentedon Nov 6, 2022
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.