Exigerr opened a new pull request, #923: URL: https://github.com/apache/cordova-plugin-camera/pull/923
### Platforms affected Android ### Motivation and Context Changes from #906 resulted in all gallery picker results being read in full into a byte array. See [this line](https://github.com/apache/cordova-plugin-camera/pull/906/files#diff-96b84e501d011b0ecc5db8468a5ec6a08b919be8bcc731eaf5df174ea6cbf574R767). Reading in the data fully into memory works generally fine when dealing with images. When handling larger files (videos for example), it will nearly always result in an out of memory error (reading too much data in one go). With videos no transformation is required, the URI simply need to be returned. Steps to recreate issue: * On Android, trigger `camera.getPicture` with * `destinationType` as `Camera.DestinationType.FILE_URI` * `mediaType` as `Camera.MediaType .VIDEO` * `sourceType` as `Camera.PictureSourceType.PHOTOLIBRARY` * Select a large video (typically > 200mb will do it for most devices) * App will crash due to an Out of Memory exception * Similar to > AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 268435472 byte allocation with 100663296 free bytes and 123MB until OOM, target footprint 239130480, growth limit 268435456 ### Description Re-ordered and cleaned up the code for `processResultFromGallery` to only read the file data when required. If its a video or MIME type which it cannot transform, then simply return the URI. Similarly if the special case for just returning the path without scaling is met, avoid reading in any data. ### Testing * Tested image selection from gallery on Pixel 6a (Android 14 & Android 15) and Samsung S10 (Android 12) devices. * Range of different sized (MB) images. * Tested video selection from gallery on Pixel 6a (Android 14 & Android 15) and Samsung S10 (Android 12) devices. * Range of different sized (MB) videos (10MB - 1GB). No issues spotted. Images and videos were selected and saved into application storage without issue. ### Checklist - [ ] I've run the tests to see all new and existing tests pass - [ ] I added automated test coverage as appropriate for this change - [x] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) - [ ] I've updated the documentation if necessary -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org