Closed ozster123 closed 1 year ago
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 https://github.com/ozster123/FilePickerTest.
I switched back to Visual Studio Community 2022 for Mac Version 17.3.8 (build 5)
Runtime .NET 6.0.5 (64-bit) Architecture: X64
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. MacOS 13 x64; VS for Mac 2022 17.4 .net SDK 7.0.100; App target platform .net 6; build for MacCatalyst
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 FilePicker.PickMultipleAsync
on Mac shows the Open dialog. However before user has anything to do with the dialog, the code jumps to the next instruction right away (my code has await).
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:
var result = await FilePicker.Default.PickAsync();
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? Currently the FilePicker on macOS is unusable.
I have hit the same issue. Quite unexpected.
Testing with the latest commit of the main
branch, it looks to me that it works on macOS in Essentials samples. See:
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?
I have never contributed to MS's repo before though, so I will need to get myself familiar with it.
It's just creating a PR really.
Though I wonder if we do get a PR, how long until they release such a fix?
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:
(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.
I am having a similar problem. The FilePicker was working fine on MacOS (as well as the other platforms) but it suddenly stopped working on just this one platform. Hopefully https://github.com/dotnet/maui/pull/13814 will fix this. Thanks @MartyIX !
@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 just tried on Monterey 12.6.3 and it seems to work.
I copied the snippet of code from this issue and no hangs and gets the result.
What happens if you create a blank app and put the code in some button click?
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.
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.
@mattleibow
I just tried on Monterey 12.6.3 and it seems to work.
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 dotnet --info
and dotnet workload --info
?
I am testing this on my mac, but I am assuming something else is different with the SDK and/or something in my test app.
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 ...
Do you have any third party things that pop up dialogs?
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