-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
area-essentials-filepickeri/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionregressed-in-9.0.50s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
When using FilePicker.PickAsync in a .NET MAUI application, if the user cancels the file picker (either by using "Cancel" button or swiping down the picker), the task does not complete and remains in a hanging state. This behavior prevents proper handling of cancellation and leaves tasks in an incomplete state.
Steps to Reproduce
- Create a new MAUI app.
- Update the following code on MainPage.xaml.cs
// MainPage.xaml.cs
private readonly List<Task<FileResult?>> _tasks = [];
private async void CounterBtn_Clicked(object sender, EventArgs e)
{
var completedTasks = _tasks.Where(t => t.IsCompleted).Count();
var inProgressTasks = _tasks.Where(t => !t.IsCompleted).Count();
Console.WriteLine($"Picked tasks: {completedTasks}, Hanging tasks: {inProgressTasks}");
var fileResultTask = FilePicker.PickAsync(new PickOptions
{
PickerTitle = "Please select a file"
});
_tasks.Add(fileResultTask);
var fileResult = await fileResultTask;
if (fileResult == null)
{
Console.WriteLine("No file selected");
return;
}
Console.WriteLine($"Selected file name: {fileResult.FileName}");
}
Expected behavior when user cancels the picker: Hanging tasks should be 0.
Actual behavior when user cancels the picker: Hanging tasks count keeps growing for each button tap.
Link to public reproduction project repository
https://github.com/tharindup/FilePickerCancelBug
Version with bug
9.0.70 SR7
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
9.0.40 SR4
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
Metadata
Metadata
Assignees
Labels
area-essentials-filepickeri/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionregressed-in-9.0.50s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done