Skip to content

MediaPicker.PickPhotos fails to modify image, tries to load original source, fails to load source on Android 9.0 #34889

Description

@beeradmoore

Description

When calling MediaPicker.PickPhotosAsync( on an Andriod 9.0 device you are not able to call OpenReadAsync on the FileResult object. This results in an except getting the first result we are unable to

System.UnauthorizedAccessException: Access to the path '/storage/emulated/0/Download/IMG_6481.PNG' is denied.

I tried with a different image and I got the same result (for a different path).

Access to the path '/storage/emulated/0/Pictures/Bicho-preguiça_3.jpg' is denied.

There is also an odd issue here. If I am applying the below properties why is is it tyring to load the image from source instead of the one that should be saved into cache (as observed on other OS versions)

// Optional processing for images
MaximumWidth = 1024,
MaximumHeight = 768,
CompressionQuality = 85,
RotateImage = true,
PreserveMetaData = true,

I used this source image from Wikipedia just to confirm that a resize should happen.

EDIT: Not shown in this sample, take photo also fails but works on Android 10.0

Steps to Reproduce

  1. Run the SelectImageTest app
  2. Click the button to select an image from the gallery
  3. Either the size of the image in bytes will be written in the text below, or the exception message will be displayed.

Link to public reproduction project repository

https://github.com/beeradmoore/maui-MediaPickerAndroidCrash

Version with bug

10.0.51, 10.0.60

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 9 (but likely below)

Did you find any workaround?

Nope

Relevant log output

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions