rafidgotit / media_picker_widget

A widget that picks media files from storage and allows you to place anywhere in the widget tree.
MIT License
13 stars 14 forks source link

Java.lang.OUtOfMEmoryError: Failed To allocate a ... byte allocation with ... bytes and 70mb until OOM #2

Closed amrsunja closed 1 year ago

amrsunja commented 2 years ago

In my xiaomi phone I was received this failure when I try to get images and videos from gallery

XuanTung95 commented 1 year ago

Currently, this library read bytes of all media files, causing OOM when the file is too big. Should only load the thumbnail to display.

Future<Media> convertToMedia({required AssetEntity media}) async {
  Media convertedMedia = Media();
  convertedMedia.file = await media.file;
  convertedMedia.mediaByte = await media.originBytes; // <-- here
  convertedMedia.thumbnail =
      await media.thumbnailDataWithSize(ThumbnailSize(200, 200));
  convertedMedia.id = media.id;
  convertedMedia.size = media.size;
  convertedMedia.title = media.title;
  convertedMedia.creationTime = media.createDateTime;

  MediaType mediaType = MediaType.all;
  if (media.type == AssetType.video) mediaType = MediaType.video;
  if (media.type == AssetType.image) mediaType = MediaType.image;
  convertedMedia.mediaType = mediaType;

  return convertedMedia;
}
XuanTung95 commented 1 year ago

Hello @rafid08 I think your package is awesome, but I noticed some problems:

rafidgotit commented 1 year ago

Hey @XuanTung95 Thank you so much for your valuable suggestions. Also I'm extremely sorry for the issue you're facing. The thing is, the time when I developed this package, I was not that expert in flutter. Now I really want to refactor the whole project but I'm currently so busy with some of my other projects. I'm not getting that much time to refactor the project. I'd be glad if you would like do some contributions to this project...

XuanTung95 commented 1 year ago

Hi @rafid08, I would love to contribute to this project. Let me see what I can do.

reliance-engineer commented 1 year ago

Hi, I'm having this same issue, will be a solution for this soon??

rafidgotit commented 1 year ago

This issue is solved in the last update of 1.0.1 I'm extremely sorry for being late solving this major issue.