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
[Bug]: Improve Linux XDG FileChooser implementation #31258
Comments
X |
Same problem for me on various Ubuntu systems with Electron 14 and 15, even with forcing |
The XDG Picker seems to work properly for me on Arch Linux with the |
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 |
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
|
And here is the
|
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 So that's something I guess. |
Hey that is awesome. Not sure what would have changed beyond that PR last week. |
Yeah me neither, hopefully other apps update soon to 16 so it can be confirmed to work. |
VSCode is working on it, but there are still a couple of blockers. Will be cool when it does. |
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? |
I would think the VSCode flatpak has filesystem=host permissions. VSCode mainly just wants ability to pick file chooser at the moment. |
Yeah, hopefully eventually they can move away from those static |
The document portal can be used to get access to directories with a file chooser already. What’s missing is things like knowing the real path of the file or directory (flatpak/xdg-desktop-portal#475) and getting properly notified when files are changed by another program (flatpak/xdg-desktop-portal#567). |
EDIT: Ignore this. I thought the previous message was something on flatpak/xdg-desktop-portal#463 that was arguing against it being necessary. |
No, I don’t consider that optimal! My list of things missing wasn’t meant to be exhaustive. What you’re asking for is flatpak/xdg-desktop-portal#463. Though there are also editors that expect to have access to .editorconfig and .git in parent folders when opening a single file, and a portal that merely allows opening neighbouring files wouldn’t be enough for that (since .editorconfig and .git could be in parent folders rather than the same folder). So some cases might still require having the user select a directory rather than a file, even when they’d prefer to select only a file. |
@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. |
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 Debian, meanwhile, packages libgtk as
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): sudo ln /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 /usr/lib/x86_64-linux-gnu/libgtk-3.so 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 |
Fedora 36 does not ship |
For Ubuntu this trick works too, thanks!
So maybe we can improve this on Electron side, to detect |
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. |
for those on fedora (36), too lazy to read all that: at least that worked for me to upload files in element, thanks! |
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. |
Preflight Checklist
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.
See discussion on what likely is a symptom of this issue:
squalou/google-chat-linux#38 flathub/com.mattermost.Desktop#39
This is not a regression. Worst case the old file chooser will be used, but that’s what’s been the behaviour for years anyway.
The text was updated successfully, but these errors were encountered: