Repository navigation
Fix concurrent FallbackStorageProvider calls failing after the first success - #22596
Merged
Conversation
maxkatz6
approved these changes
Oct 25, 2026
Collaborator
|
Contributor
Author
|
@cla-avalonia agree |
MrJul
enabled auto-merge
October 25, 2026 16:26
NuGet packagesThe packages for this pull request have been published (workflow run):
|
…erfrompathasync-calls-fail-after-first-success
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 25, 2026
izakusilov
deleted the
22559-concurrent-istorageprovider-trygetfolderfrompathasync-calls-fail-after-first-success
branch
October 25, 2026 22:45
MrJul
pushed a commit
that referenced
this pull request
Nov 2, 2026
…success (#22596) Co-authored-by: Max Katz <maxkatz6@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
Fixes concurrent
IStorageProvidercalls (TryGetFolderFromPathAsync,TryGetFileFromPathAsync, etc.) failing on Linux when the first storage provider in the fallback chain is unavailable, e.g. in a Dev Container without an XDG desktop portal.What is the current behavior?
On X11 and Wayland,
IStorageProvideris aFallbackStorageProviderthat lazily tries a list of provider factories (DBus portal, GTK, managed). It tracks the next factory to try in_nextProviderFactory, but only increments it after the awaited factory completes.When several calls run concurrently, they all await the same factory. If that factory returns
nullasynchronously (the DBus portal does when no portal is running), each caller increments the index when it resumes. The first caller moves on to the next factory, while the others find the index already past the end of the list and returnnull. As a result, one call succeeds and the rest fail:When the first factory does return a provider, concurrent calls add it to the list more than once and skip the factories after it.
What is the updated/expected behavior with this PR?
All concurrent calls see the same providers and succeed.
To test: on Linux without an XDG desktop portal (e.g. the Dev Container from the issue), call
TryGetFolderFromPathAsyncseveral times in parallel. All calls return the folder.How was the solution implemented (if it's not obvious)?
FallbackStorageProvidernow caches the task returned by each factory, so each factory is only invoked once and concurrent callers await the same task instead of advancing a shared index.Resetreplaces the factories and the cache together; an enumeration in progress keeps using the arrays it started with.Added
FallbackStorageProviderTests; the two concurrency tests fail without the fix. Also verified with an X11 app on Xvfb with a DBus session but no desktop portal: without the fix one of three parallelTryGetFolderFromPathAsynccalls fails, with the fix all three succeed.Checklist
Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
Fixes #22559