[go: up one dir, main page]

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

fix: revert required portal version for file chooser dialogs #44426

Merged
merged 7 commits into from
Nov 15, 2024

Conversation

deepak1556
Copy link
Member
@deepak1556 deepak1556 commented Oct 28, 2024

Description of Change

  1. Revert the version bump to 3, to help address [Bug]: Electron 32.1 does not use the portals inside a flatpak application #43819
  2. Provide xdg-portal-required-version flag for application developers to control the portal usage (ex: requires support of current_folder)
  3. If portal code path is used and a call to dialog api with default_path is performed then log a warning pointing to the above flag.

Release Notes

Notes: fix file chooser dialogs for flaptak applications

@deepak1556 deepak1556 added semver/minor backwards-compatible functionality target/33-x-y PR should also be added to the "33-x-y" branch. target/34-x-y PR should also be added to the "34-x-y" branch. labels Oct 28, 2024
@deepak1556 deepak1556 requested a review from a team as a code owner October 28, 2024 12:29
@electron-cation electron-cation bot added api-review/requested 🗳 new-pr 🌱 PR opened in the last 24 hours labels Oct 28, 2024
ckerr
ckerr previously requested changes Oct 28, 2024
Copy link
Member
@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to tweak the lambda capture to fix a the build, but otherwise looks good

2024-10-28T16:06:16.0232728Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:304:26: error: variable 'xdg_portal_required_version' cannot be implicitly captured in a lambda with no capture-default specified
2024-10-28T16:06:16.0234398Z   304 |                          xdg_portal_required_version) {
2024-10-28T16:06:16.0235038Z       |                          ^
2024-10-28T16:06:16.0236274Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:279:18: note: 'xdg_portal_required_version' declared here
2024-10-28T16:06:16.0237693Z   279 |     unsigned int xdg_portal_required_version) {
2024-10-28T16:06:16.0238343Z       |                  ^
2024-10-28T16:06:16.0239107Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:11: note: lambda expression begins here
2024-10-28T16:06:16.0257715Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0258347Z       |           ^
2024-10-28T16:06:16.0259550Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by value
2024-10-28T16:06:16.0260754Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0261332Z       |            ^
2024-10-28T16:06:16.0261795Z       |            xdg_portal_required_version
2024-10-28T16:06:16.0263318Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by reference
2024-10-28T16:06:16.0264786Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0265383Z       |            ^
2024-10-28T16:06:16.0265861Z       |            &xdg_portal_required_version
2024-10-28T16:06:16.0266833Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by value
2024-10-28T16:06:16.0267775Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0268299Z       |            ^
2024-10-28T16:06:16.0268662Z       |            =
2024-10-28T16:06:16.0269428Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by reference
2024-10-28T16:06:16.0270436Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0271011Z       |            ^
2024-10-28T16:06:16.0271410Z       |            &
2024-10-28T16:06:16.0273104Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:311:68: error: variable 'xdg_portal_required_version' cannot be implicitly captured in a lambda with no capture-default specified
2024-10-28T16:06:16.0275101Z   311 |             VLOG(1) << "File chooser portal expected version: " << xdg_portal_required_version;
2024-10-28T16:06:16.0276082Z       |                                                                    ^
2024-10-28T16:06:16.0277430Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:279:18: note: 'xdg_portal_required_version' declared here
2024-10-28T16:06:16.0278864Z   279 |     unsigned int xdg_portal_required_version) {
2024-10-28T16:06:16.0279470Z       |                  ^
2024-10-28T16:06:16.0280276Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:11: note: lambda expression begins here
2024-10-28T16:06:16.0281219Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0281756Z       |           ^
2024-10-28T16:06:16.0282850Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by value
2024-10-28T16:06:16.0283949Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0284514Z       |            ^
2024-10-28T16:06:16.0284949Z       |            xdg_portal_required_version
2024-10-28T16:06:16.0286220Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by reference
2024-10-28T16:06:16.0287410Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0287985Z       |            ^
2024-10-28T16:06:16.0288440Z       |            &xdg_portal_required_version
2024-10-28T16:06:16.0289419Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by value
2024-10-28T16:06:16.0290697Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0291290Z       |            ^
2024-10-28T16:06:16.0291669Z       |            =
2024-10-28T16:06:16.0292501Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by reference
2024-10-28T16:06:16.0293563Z   291 |           [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0294133Z       |            ^
2024-10-28T16:06:16.0294535Z       |            &
2024-10-28T16:06:16.0294919Z 2 errors generated.


Sets the minimum required version of XDG portal implementation to `version`
inorder to use the portal backend for file dialogs on linux. Current
default is set to `4`.
Copy link
Member
@samuelmaddock samuelmaddock Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is the intended consumer for this switch? Application developers, users, or both? For the recent bump to v4, is this so application users can switch back the behavior if they require it?

I also wonder if we should consider reverting the default to v3. #43570 contained an undocument breaking change in behavior that application developers may not be expecting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should revert the default, since it looks like the change was accepted upstream (see https://chromium-review.googlesource.com/c/chromium/src/+/5786982), but we probably should document this as a breaking change, at least retroactively, so people know

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VerteDinde I do think (in agreement w/ deepak below) that we should change back the default, since as of now v4 is so rarely available that every app might be required to float this flag for potentially years.

@deepak1556
Copy link
Member Author

Sorry for the delay, I was testing some idea to see if we can repurpose the function SelectFileDialogLinuxPortal::CheckPortalAvailabilityOnBusThread to not only check for portal availability but also ensure the option current_folder is available on the relevant interfaces but I couldn't find a way to probe it without making the actual method call.

Rethinking this PR, based on the conversations from #43819 it seems the affected scenarios with the portal version bump is harder to recover (generic filechooser inside the flatpak application is opened without read/write access to any file on the host) than the scenario with defaultPath #43310. Thoughts on the following next steps,

  1. Revert the version bump to 3, to help address [Bug]: Electron 32.1 does not use the portals inside a flatpak application #43819
  2. Provide xdg-portal-required-version flag for application developers to control the portal usage (ex: requires support of current_folder)
  3. If portal code path is used and a call to dialog api with default_path is performed then log a warning pointing to the above flag.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Nov 4, 2024
@deepak1556 deepak1556 force-pushed the robo/support_configuring_xdg_portal_version branch from ebc72ab to ee73cf9 Compare November 5, 2024 13:08
@deepak1556 deepak1556 changed the title feat: add support for configuring xdg portal version at runtime fix: revert required portal version for file chooser dialogs Nov 5, 2024
Copy link
Member
@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

Copy link
Member
@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

Have a question for clarity, but won't block merging this.

docs/api/command-line-switches.md Outdated Show resolved Hide resolved
+// Version 4 includes support for current_folder option to the OpenFile method via
+// https://github.com/flatpak/xdg-desktop-portal/commit/71165a5.
+constexpr int kXdgPortalRequiredVersion = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a suggestion in the GH issue about querying for the available portal version rather than hardcoding to 3 or 4. Would that be a viable approach?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SelectFileDialogLinuxPortal::CheckPortalAvailabilityOnBusThread already performs this check, the hardcoded value is the minimum value we check against to use the portal path. The issue is we don't know if a version of portal supports the feature on an interface by querying and this availability check is performed once when the application initializes.

Copy link
Member
@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM, just a small grammar correction and I also wonder if we should be more explicit about explaining that the portal version needs to be 4 or greater to use defaultPath.

docs/api/dialog.md Outdated Show resolved Hide resolved
@deepak1556 deepak1556 added the target/32-x-y PR should also be added to the "32-x-y" branch. label Nov 13, 2024
@@ -181,6 +191,11 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
The `filters` specifies an array of file types that can be displayed, see
`dialog.showOpenDialog` for an example.

**Note:** On Linux `defaultPath` is not supported when using portal file chooser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultPath is only unsupported on versions <4 for open dialogs - save dialogs work as expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching.

For reference, flatpak/xdg-desktop-portal#796

docs/api/dialog.md Outdated Show resolved Hide resolved
@codebytere
Copy link
Member

@deepak1556 i think a rebase should fix windows

@deepak1556 deepak1556 force-pushed the robo/support_configuring_xdg_portal_version branch from 097811d to fde1bdc Compare November 13, 2024 16:42
Copy link
Member
@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more grammar nit.

docs/api/command-line-switches.md Outdated Show resolved Hide resolved
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
@jkleinsc jkleinsc dismissed ckerr’s stale review November 15, 2024 14:31

Concerns were addressed.

@jkleinsc jkleinsc merged commit 4fb5aab into main Nov 15, 2024
54 checks passed
@jkleinsc jkleinsc deleted the robo/support_configuring_xdg_portal_version branch November 15, 2024 14:31
Copy link
release-clerk bot commented Nov 15, 2024

Release Notes Persisted

fix file chooser dialogs for flaptak applications

@trop
Copy link
Contributor
trop bot commented Nov 15, 2024

I was unable to backport this PR to "33-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/33-x-y PR should also be added to the "33-x-y" branch. label Nov 15, 2024
@trop
Copy link
Contributor
trop bot commented Nov 15, 2024

I was unable to backport this PR to "32-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/33-x-y needs-manual-bp/32-x-y and removed target/32-x-y PR should also be added to the "32-x-y" branch. labels Nov 15, 2024
@trop
Copy link
Contributor
trop bot commented Nov 15, 2024

I have automatically backported this PR to "34-x-y", please check out #44681

@trop trop bot added in-flight/34-x-y merged/34-x-y PR was merged to the "34-x-y" branch. and removed target/34-x-y PR should also be added to the "34-x-y" branch. in-flight/34-x-y labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review/approved ✅ merged/34-x-y PR was merged to the "34-x-y" branch. needs-manual-bp/32-x-y needs-manual-bp/33-x-y semver/minor backwards-compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants