Skip to content

fix(portal): avoid circular portal wait during FileChooser cold activation - #2024

Merged
l0gicgate merged 4 commits into
lgse:mainfrom
ToghrolTP:fix/2023-portal-cold-activation-deadlock
Nov 2, 2026
Merged

l0gicgate merged 4 commits into
lgse:mainfrom
ToghrolTP:fix/2023-portal-cold-activation-deadlock

Conversation

@ToghrolTP

Copy link
Copy Markdown
Contributor

Description

When third-party applications (such as Telegram, browsers, or other desktop apps) trigger a file or folder picker dialog, xdg-desktop-portal invokes org.freedesktop.impl.portal.FileChooser.OpenFile on Strata's portal backend. If Strata is cold-activated via D-Bus (or after its 120-second idle timeout), GTK's initialization synchronously queries xdg-desktop-portal for desktop settings while xdg-desktop-portal is blocked waiting on Strata's OpenFile implementation. This circular dependency causes the portal request to hang until the 25-second D-Bus call timeout expires.

This change extends the existing GDK_DEBUG=no-portals restart mitigation used by --gapplication-service to LaunchMode::Portal (strata --portal), preventing GTK from attempting circular portal queries during backend activation while preserving child process and user settings behavior.

Visual evidence

N/A. This is an internal IPC / startup timing fix for D-Bus portal backend activation; visual UI appearance remains unchanged.

How to test

  1. Terminate any running portal backend: pkill -f "strata --portal" || true
  2. From an external application (e.g. Telegram or a web browser), click an action that opens a system file or folder chooser dialog (such as sending a file or clicking "Open folder").
  3. Observe the dialog appearance time.

Expected result:

The Strata file chooser dialog opens immediately without incurring a 25-second D-Bus timeout delay.

Related issue

Closes #2023

…ation

When an application requests a file chooser dialog, xdg-desktop-portal calls org.freedesktop.impl.portal.FileChooser.OpenFile on Strata's portal backend. When Strata is activated via D-Bus for this call, GTK's startup initialization synchronously queries xdg-desktop-portal for desktop settings. Because xdg-desktop-portal is blocked waiting on the OpenFile backend response, a circular deadlock occurs until the 25-second D-Bus call times out.

Apply the existing GDK_DEBUG=no-portals restart mitigation used by --gapplication-service to LaunchMode::Portal as well, preventing GTK from querying the portal during backend activation.

Closes lgse#2023
@github-actions github-actions Bot added the fix label Nov 2, 2026
…oss both services

Drop the test-only file_manager_debug_environment alias, fold the duplicated
--portal debug-flag test into the service activation table, and describe the
FileChooser backend alongside FileManager1 in the packaging notes.
@l0gicgate

Copy link
Copy Markdown
Contributor

Reviewed, merged main (5e8a942) and pushed two commits to this branch.

What changed beyond the merge (1498a14)

  • Dropped the #[cfg(test)] file_manager_debug_environment alias; the tests call service_debug_environment directly.
  • Folded the new --portal test into the existing debug-flag test as a second row of a table, and renamed both tests to service_activation_*, since they now cover both D-Bus services.
  • docs/packaging.md: the section now describes the FileChooser backend alongside FileManager1 instead of only deleting the sentence that said --portal never acquires the override. Same wording touch-up in the child_environment module doc.

Manual verification of the built binary, strata --portal under a private Xvfb and dbus-run-session, reading the surviving process's /proc/<pid>/environ:

  • GDK_DEBUG unset → re-executed with GDK_DEBUG=no-portals, STRATA_ORIGINAL_GDK_DEBUG= (empty).
  • GDK_DEBUG=misc,portals → GDK_DEBUG=misc,portals:no-portals, original preserved for child processes.
  • GDK_DEBUG=no-portals already set → no second re-exec.
  • GTK_THEME=Adwaita set → one re-exec that both drops the theme override and adds no-portals.

Scoped tests run locally: tests::service_activation_*, child_environment::, and tests::a_gvfs_probe_after_preferences_created_the_default_vfs_is_rejected (the probe still runs after the re-exec check, before anything loads GIO). fmt and clippy clean. CI is green on the new head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(portal): avoid circular portal wait during FileChooser cold activation

2 participants