-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
FilePicker on MacOS does not always return the file picked #11088
Comments
Hi @ozster123. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I have created a minimal example I switched back to Runtime This shows the problem usually first or second select. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Thanks for adding the repro! |
I have the same issue as #11462, FilePicker.Default.PickAsync always returns null and is not being awaited by caller. I tried to use Task.Result instead of await, but it stalls the app and never brings up the file dialog at all. |
Yep, I encountered it as well (see the closed duplicate issue #11574 ). Calling |
I have a similar issue, although in my case the method doesn't even return null. If I set a breakpoint on a call such as:
The code never reaches the next line where I evaluate the result for null. The OS file picker does launch, but after selecting the file, the method has already terminated. No exceptions are generated, and I can see threads starting and stopping in the Application Output. But that's it. If I re-run the method, it works successfully the second time. |
Any status updates for this item? |
I have hit the same issue. Quite unexpected. |
Testing with the latest commit of the
It would be great if somebody could verify it as well. |
It seems if I remove all breakpoints and let it run, sometimes the issue doesn't happen. But most of the time, the FilePicker is unusable in its current state. |
For me it's more like "almost never picks the file and occasionally it does" so time is important. I guess the code does not wait for something. |
I wrote this package to "fix" these problems in the mean time: datvm/LukeMauiFilePicker. Basically I re-implement them on platforms that the official APIs are having trouble with. Also support a Save Picker. |
@datvm So maybe you can fix the MAUI's macOS implementation for everyone to benefit? :))) |
@MartyIX sure that's a great suggestion, I guess I could try. I have never contributed to MS's repo before though, so I will need to get myself familiar with it. Though I wonder if we do get a PR, how long until they release such a fix? |
It's just creating a PR really.
IMO there is no definitive answer to that. I would be hopeful that it would take a month. However, once the fix is merged, one can use it thanks to https://github.com/dotnet/maui/blob/main/.github/DEVELOPMENT.md#testing-branch-against-your-project (I use it quite often for macOS but that's just me). |
On my macOS Ventura, I can see that this is the culprit: maui/src/Essentials/src/FilePicker/FilePicker.ios.cs Lines 41 to 45 in ae20455
(Deleting the code seems to fix the issue) The two delegates compete with each other and if this delegate wins, then no file is picked. |
@cdavidyoung What is your macOS version please? I wonder if the issue manifests only on the newest macOS releases or whether it affects even older ones. |
Ventura 13.2.1 |
I tried it on Monterey 12.6.3 on a 2014 Intel Core i5 Mac Mini as well and FilePicker hangs there as well. |
I have already tried it on the standard Maui app. When I clicked the button it was able to pick correctly. As I mentioned before this used to work with my app as well. I think it must be some sort of race condition that makes it stop working in some cases. |
I have already described the race here. |
Is it possible that the bug manifests only on macOS Ventura? |
I have tried my app on both Ventura and Monterey. The FilePicker hangs in both cases. |
@cdavidyoung can you attach a sample of this happening? And also the results of When you say "hang", you mean the await never returns or the app freezes? |
Hang means in my app it does not return from the call to FilePicker. I can't provide a sample of this happening because it works fine in the standard Maui app. I wish I could. It only happens in my app. |
Do you have any third party things that pop up dialogs? If you move this code to say a blank page in your app does it happen? Or if you swap out the main page in the app for a blank one does it happen? It clearly is affecting things, but it seems that something else may be breaking us. We can see about the PR, but that may hide other issues. |
Not a question for me but ...
I don't use any 3rd party things. I have a pure MAUI application and on mac arm64 Ventura, the issue is very easy to reproduce as the bug manifests almost always (say 4 times out of 5 attempts). So that might be an easy thing to try. |
As another data point, I just recreated my project from scratch starting with the standard Maui app. I then copied and merged all my project files. This fixed the FilePicker problem that I was having with the Mac version. It runs perfectly on my Mac except that there is some kind of provisioning problem when I try to upload the release version to the App Store. So, if you are having a problem with the FilePicker recreating your project from scratch may fix it. CacheAll is the name of the app if you want to check it out for Android (Galaxy Store), iOS, and Windows. |
Well after like an hour of me thinking I am stupid and doing something wrong, I can confirm I have this issue as well. Running the file picker twice will result it in running the second time. Seems like the first delegate is hanging as mentioned by @MartyIX |
Same thing is happening on iOS 16.1.1 & VS 2022 17.6.1. Sometimes selecting a file works, sometimes it doesn't (returns null). Super frustrating. |
I also have this issue on MacOS, it works in dev, but not when deployed via TestFlight.. works fine on windows and after deployed via the Windows store. Is there a definitive fix for this? |
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you! |
Description
While using FilePicker on MacOS it will regularly return null for the FileResult when a file is chosen. Code below. After a few selects it works. No exceptions or crashes.
Any ideas?
Version 17.4 Preview (17.4 build 2366)
Runtime
.NET 6.0.9 (64-bit)
Architecture: X64
Steps to Reproduce
Create a new .net Maui App
Add a button.
Add a relay command for the button.
Use code above to select a file.
Link to public reproduction project repository
n/a
Version with bug
7.0 Release Candidate 2
Last version that worked well
Unknown/Other
Affected platforms
macOS
Affected platform versions
macOS 12, 13
Did you find any workaround?
No
Relevant log output
The text was updated successfully, but these errors were encountered: