Skip to content
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

MediaPicker CapturePhotoAsync broken on Android in nightly builds #19821

Closed
StefanCuypers opened this issue Jan 11, 2024 · 5 comments · Fixed by #19844 or #19936
Closed

MediaPicker CapturePhotoAsync broken on Android in nightly builds #19821

StefanCuypers opened this issue Jan 11, 2024 · 5 comments · Fixed by #19844 or #19936
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! fixed-in-8.0.7 fixed-in-8.0.10 fixed-in-8.0.14 fixed-in-8.0.40 fixed-in-9.0.100-preview.1.9973 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@StefanCuypers
Copy link

StefanCuypers commented Jan 11, 2024

Description

We switched to a nightly build to fix a problem described in #17861.
In this build however the CapturePhotoAsync call fails with a NullReferenceException.

Steps to Reproduce

  1. Create new MAUI App .Net 8.0
  2. Change OnCounterClicked to 'private async void ...'
  3. Add line to OnCounterClicked: var photo = await MediaPicker.Default.CapturePhotoAsync();
  4. Add permissions and queries required for CapturePhotoAsync on Android.
  5. Run the program in an Android emulater (I'm using Pixel 5 - API 33)
  6. Click on the 'Click me' button
  7. Shows the camera and allows you to take a photo - no problem.
  8. Edit the project file and move to the nightly build: add <MauiVersion>8.0.6-nightly.9839</MauiVersion>
  9. Reload the project.
  10. Run the program again.
  11. Click on the 'Click me' button
  12. Shows the camera and allows you to take a photo, but as soon as you confirm you get a NullReferenceException.

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.5

Affected platforms

Android

Affected platform versions

Android 13.0 and 14.0

Did you find any workaround?

No response

Relevant log output

If we add a try/catch we can see the callstack:
   at Microsoft.Maui.Storage.FileSystemUtils.EnsurePhysicalPath(Uri uri, Boolean requireExtendedAccess) in D:\a\_work\1\s\src\Essentials\src\FileSystem\FileSystemUtils.android.cs:line 58
   at Microsoft.Maui.Media.MediaPickerImplementation.<>c__DisplayClass7_0.<CaptureAsync>g__OnResult|0(Intent intent) in D:\a\_work\1\s\src\Essentials\src\MediaPicker\MediaPicker.android.cs:line 96
   at Microsoft.Maui.ApplicationModel.IntermediateActivity.OnActivityResult(Int32 requestCode, Result resultCode, Intent data) in D:\a\_work\1\s\src\Essentials\src\Platform\IntermediateActivity.android.cs:line 85
--- End of stack trace from previous location ---
   at Microsoft.Maui.Media.MediaPickerImplementation.CaptureAsync(MediaPickerOptions options, Boolean photo) in D:\a\_work\1\s\src\Essentials\src\MediaPicker\MediaPicker.android.cs:line 100
   at TestCamera.MainPage.OnCounterClicked(Object sender, EventArgs e) in C:\t\TestCamera\TestCamera\MainPage.xaml.cs:line 16
@StefanCuypers StefanCuypers added the t/bug Something isn't working label Jan 11, 2024
@jfversluis jfversluis added area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jan 11, 2024
@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Jan 11, 2024
@ghost
Copy link

ghost commented Jan 11, 2024

Hi @StefanCuypers. 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.

@Redth
Copy link
Member

Redth commented Jan 11, 2024

Seeing the same error here, investigating...

@Redth
Copy link
Member

Redth commented Jan 11, 2024

#18620 seems like the likely cause

@Redth Redth added i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jan 11, 2024
@StefanCuypers
Copy link
Author

Yes, I think those changes cause it. I've copied the previous version of the code directly into my project (and some code from internal functions in other objects called by it) and that code works fine. So #18620 seems to have broken the functionality.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Jan 11, 2024
@Redth
Copy link
Member

Redth commented Jan 12, 2024

#19862 was created to track some additional UI and/or Manual test coverage for these scenarios.

@PureWeen PureWeen added the p/0 Work that we can't release without label Jan 12, 2024
@PureWeen PureWeen added this to the .NET 8 SR2 milestone Jan 12, 2024
@samhouts samhouts added the fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! label Jan 31, 2024
@samhouts samhouts modified the milestones: .NET 8 SR2, .NET 8 SR1 Jan 31, 2024
@samhouts samhouts added fixed-in-8.0.7 fixed-in-9.0.100-preview.1.9973 and removed fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! labels Feb 27, 2024
@samhouts samhouts modified the milestones: .NET 8 SR1, .NET 8 SR2 Feb 27, 2024
@samhouts samhouts added the fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! label Feb 27, 2024
@samhouts samhouts modified the milestones: .NET 8 SR2, .NET 8 SR1 Feb 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2024
@samhouts samhouts modified the milestones: .NET 8 SR1, .NET 8 SR2 Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! fixed-in-8.0.7 fixed-in-8.0.10 fixed-in-8.0.14 fixed-in-8.0.40 fixed-in-9.0.100-preview.1.9973 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
Status: Done
5 participants