Skip to content

PickPhotosAsync throws exception if image is modified. #32408

@JPfahl

Description

@JPfahl

Description

If you call the new PickPhotosAsync method with MediaPickerOptions that limit the size or compression value so that the image will be modified within the call, the method throws an ObjectDisposedException. It works if you don't supply options.

Steps to Reproduce

try { List<FileResult> fileResults = await MediaPicker.Default.PickPhotosAsync(new() { MaximumHeight = 1920, MaximumWidth = 1920 }); } catch (Exception exception) { Sys.Log(exception); //use your own logging. }

Link to public reproduction project repository

No response

Version with bug

10.0.0-rc.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

No response

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 11

Did you find any workaround?

No response

Relevant log output

Exception thrown: 'System.ObjectDisposedException' in System.Private.CoreLib.dll
[2025-11-05 11:34:44.17][Error][Test] Exception=System.ObjectDisposedException
Message=Cannot access a closed Stream.
ObjectName=
TargetSite=Void ThrowObjectDisposedException_StreamClosed(System.String)
Source=System.Private.CoreLib
HResult=-2146232798
StackTrace=   at System.IO.MemoryStream.CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at Microsoft.Maui.Media.MediaPickerImplementation.PickAsync(MediaPickerOptions options, Boolean photo)
   at Microsoft.Maui.Media.MediaPickerImplementation.PickMultipleAsync(MediaPickerOptions options, Boolean photo)
   at MauiDev.ViewModels.MainPageViewModel.<>c.<<get_Test>b__271_0>d.MoveNext()

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions