jamesmontemagno / MediaPlugin

Take & Pick Photos and Video Plugin for Xamarin and Windows
MIT License
712 stars 357 forks source link

Picking multiple large images crashes app #908

Open shaileylalwani opened 3 years ago

shaileylalwani commented 3 years ago

Hello, I'm using this plugin in my application and when I pick multiple large images such as 44 MB + 25+MB etc. from photo gallery and the application crashes. The stacktrace for the crash is attached herewith if that could help. IOS-227-iYQrsSvAorjVkBERw_k0-callstack.txt

MatthewKapteyn commented 3 years ago

This may not be a permanent solution but the multi-image picker can be a heavy handed on memory when the post-image processing options are enabled. I use these options for smallest memory overhead

// Get photos from library/gallery
List<MediaFile> ChosenLibraryPhotos = await CrossMedia.Current.PickPhotosAsync(new PickMediaOptions
{
    RotateImage = false,
    PhotoSize = PhotoSize.Full,
    CompressionQuality = 100
})
shaileylalwani commented 3 years ago

Thanks for the solution @MatthewKapteyn but it is not working

MatthewKapteyn commented 3 years ago

Nuts. I took a closer look at the stacktrace and it's running into memory problems as soon as it tries to read the selected image into memory.

At this point, there's two forks of this plugin that use drastically different picker controllers that might be more memory friendly and cause less problems for you.

https://github.com/bpater-tp/MediaPlugin

Replaces the ELC controller completely with GMImagePicker

https://github.com/matthewkapteyn/MediaPlugin

Uses ELC Controller for iOS 13 and below, PHPicker for iOS 14 and up.