dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.84k stars 1.67k forks source link

iOS - MediaPicker.PickPhotoAsync() doesn't pick Photo in second attempt, if Limited permission is given to Gallery #20311

Open MGohil opened 5 months ago

MGohil commented 5 months ago

Description

When we are giving the "Limit Access" permission while picking Photos from Gallery in iOS platform, it seems to work first time, but in 2nd attempt it is not picking the single selected image.

I have already raised this as a comment on one similar issue at #14973 and "Picking photo from Gallery feature" is not yet fully working even in .NET Maui Version 8.0.6 after such a long time.

After selecting photos to allow my app to have access to, through Limit Access, it works fine first time, but after killing the app and opening again and then if we try to pick image from gallery, it keeps asking for multiple image selection which is actually an intended behaviour for giving access of selected photos to the app. But it is not showing the single image selection from my previously selected photos which my app has access to.

Following is my code to pick the file from Gallery and display it on the screen.

App.Current.Dispatcher.Dispatch(async () =>
{
    PermissionStatus status = await CheckAndRequestPhotosPermission();
    if (status == PermissionStatus.Granted || status == PermissionStatus.Limited)
    {
        var imageFile = await MediaPicker.PickPhotoAsync();
        image.Source = ImageSource.FromStream(() => imageFile.OpenReadAsync().Result);
    }
 });

public async Task<PermissionStatus> CheckAndRequestPhotosPermission()
{
    PermissionStatus status = await Permissions.CheckStatusAsync<Permissions.Photos>();
    if (status == PermissionStatus.Granted)
    {
        return status;
    }
    if (status == PermissionStatus.Denied && DeviceInfo.Platform == DevicePlatform.iOS)
    {
        // Prompt the user to turn on in settings On iOS once a
        // permission has been denied it may not be requested again from
        // the application
        return status;
    }
    if (Permissions.ShouldShowRationale<Permissions.Photos>())
    {
    }
    status = await Permissions.RequestAsync<Permissions.Photos>();
    return status;
}

I have attached the video recording of this behaviour.

https://github.com/dotnet/maui/assets/16605284/e65f5f93-93cb-4290-bfd5-38aafb4e74a4

It would be great if Maui team fix this on priority as this is really a basic feature which app needs to have.

Thank you.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.6

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

ghost commented 5 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

davibittencourtome commented 3 months ago

I'm facing the same problem, when limited permission is given and the photos are selected, the next screen doesn't open, and shows the error in the output:

Attempt to present <UIImagePickerController: 0x10d824800> on <Microsoft_Maui_Platform_PageViewController: 0x12663f720> which is waiting for a delayed presentation of <UIImagePickerController: 0x1146d4800> to complete.

nethusan commented 3 months ago

I've encountered a similar issue and created a new repository with just the image upload code using the latest MAUI version, 8.0.14, but the problem persists. The same error occurs as mentioned by @davibittencourtome.

@MGohil For reference, here's my repository URL: https://github.com/nethusan/mediaPickerExample, which might be helpful for further analysis or if anyone wants to use it as a reference for reproducing the issue. (@MGohil I used your code above in this repo, hope that was ok)

This issue prevent us going to production right now, I hope this can be fixed asap, since this is basic functionality.

kimhongka commented 3 months ago

Im also getting the same issue with MAUI MediaPicker.PickPhotoAsync() on iOS. Only it works with Full access permission.

alzubitariq commented 2 months ago

Any updates ?

fusionconsulting commented 2 months ago

Seeing this issue here and it's holding back a release. Any updates?

gautambjain commented 1 month ago

Please. This is a very common functionality and should be given a very high priority. Please fix.

MGohil commented 1 month ago

@jfversluis May I please request to move this to a priority bug? This is really holding us back since quite a long time now. I hope this issue will soon be addressed by Microsoft.

Thank you for your continuous support.

rdurish commented 1 month ago

Same here issue here, this issue definitely hurts/hinders the app experience.

letscodewithkalyan commented 1 month ago

Any Updated Maui Team ?

ThinhKVT commented 1 month ago

We encountered the same issue on our MAUI project on IOS. Have any solution for the problem ?

samhouts commented 3 weeks ago

We agree that this is an important issue. As our roadmap indicates, for the near future, we are focused on:

I am marking this as a p/2 issue because it does not meet our focus areas right now, but we are constantly revisiting the backlog for important issues to address as time allows. Thank you for your patience and understanding!

kimhongka commented 2 weeks ago

I ended up added another compromised workaround solution that showing a prompt to ask user to manually change the permisstion to full if the detected permission is Limted one.. sad, another workaround.

There are too many bugs... only about 50 bug fixes per month. At this speed, it will take another 2 years to be stable. I cannot believe this is considered a production-ready product and killed XF without a plan.

It's been more than 2 years trying to make the CollectionView work, and the priority is still said to be fixing the CollectionView and its layout.

We have converted a few XF apps to MAUI apps so far, with a LOT of workarounds. If we keep going "workaround" and around in this cycle, we will be stuck in an infinite bug loop.

We found another bug on the Tabbed Page where it selects the wrong tab at inital loading in Android when select 4th tab directly, out of 5 tabs if it has some controls like stacklayout etc. We are at a stage where we don’t even bother to report a bug anymore since only an AI bot seems to reply or park it to backlog. We have 3 more apps to convert to MAUI.

Please, please make it work. Don't add any new features or Don't mention about Blazor or Don't make a youtube that PM said MAUI is great, we all know it is not yet there and face the reality. Just make MAUI at least as stable as XF.

Why are we going back to the early XF era when it was introduced from Xamarin Native? It was the era of bugs... we have been there, right?

I appreciate your hard work. The new change is better than a stagnation with old version. Water that doesn't flow becomes stagnant; change is essential to survive, we know that as developer. Yet, it is really painful to use a half-baked product.

Sorry to bring up this negativness. I'm really trying to believe Maui is going to be better. Thank you, please take a look...

khalil2099 commented 1 week ago

I ended up added another compromised workaround solution that showing a prompt to ask user to manually change the permisstion to full if the detected permission is Limted one.. sad, another workaround.

There are too many bugs... only about 50 bug fixes per month. At this speed, it will take another 2 years to be stable. I cannot believe this is considered a production-ready product and killed XF without a plan.

It's been more than 2 years trying to make the CollectionView work, and the priority is still said to be fixing the CollectionView and its layout.

We have converted a few XF apps to MAUI apps so far, with a LOT of workarounds. If we keep going "workaround" and around in this cycle, we will be stuck in an infinite bug loop.

We found another bug on the Tabbed Page where it selects the wrong tab at inital loading in Android when select 4th tab directly, out of 5 tabs if it has some controls like stacklayout etc. We are at a stage where we don’t even bother to report a bug anymore since only an AI bot seems to reply or park it to backlog. We have 3 more apps to convert to MAUI.

Please, please make it work. Don't add any new features or Don't mention about Blazor or Don't make a youtube that PM said MAUI is great, we all know it is not yet there and face the reality. Just make MAUI at least as stable as XF.

Why are we going back to the early XF era when it was introduced from Xamarin Native? It was the era of bugs... we have been there, right?

I appreciate your hard work. The new change is better than a stagnation with old version. Water that doesn't flow becomes stagnant; change is essential to survive, we know that as developer. Yet, it is really painful to use a half-baked product.

Sorry to bring up this negativness. I'm really trying to believe Maui is going to be better. Thank you, please take a look...

no other workaround other than asking the user to give full permission ?

rdurish commented 1 week ago

I ended up added another compromised workaround solution that showing a prompt to ask user to manually change the permisstion to full if the detected permission is Limted one.. sad, another workaround. There are too many bugs... only about 50 bug fixes per month. At this speed, it will take another 2 years to be stable. I cannot believe this is considered a production-ready product and killed XF without a plan. It's been more than 2 years trying to make the CollectionView work, and the priority is still said to be fixing the CollectionView and its layout. We have converted a few XF apps to MAUI apps so far, with a LOT of workarounds. If we keep going "workaround" and around in this cycle, we will be stuck in an infinite bug loop. We found another bug on the Tabbed Page where it selects the wrong tab at inital loading in Android when select 4th tab directly, out of 5 tabs if it has some controls like stacklayout etc. We are at a stage where we don’t even bother to report a bug anymore since only an AI bot seems to reply or park it to backlog. We have 3 more apps to convert to MAUI. Please, please make it work. Don't add any new features or Don't mention about Blazor or Don't make a youtube that PM said MAUI is great, we all know it is not yet there and face the reality. Just make MAUI at least as stable as XF. Why are we going back to the early XF era when it was introduced from Xamarin Native? It was the era of bugs... we have been there, right? I appreciate your hard work. The new change is better than a stagnation with old version. Water that doesn't flow becomes stagnant; change is essential to survive, we know that as developer. Yet, it is really painful to use a half-baked product. Sorry to bring up this negativness. I'm really trying to believe Maui is going to be better. Thank you, please take a look...

no other workaround other than asking the user to give full permission ?

Would love to see your solution if you're willing to share with the community.