Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.86k stars 2.16k forks source link

[Android] OutOfMemory in BitmapLoadUtils.transformBitmap with version 2.2.6-native on a Samsung S5 #722

Open MikeOsborn opened 3 years ago

MikeOsborn commented 3 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? The com.yalantis.ucrop.UCropActivity does not display an image taken from the camera or a library to be cropped.

What is the expected behavior? The com.yalantis.ucrop.UCropActivity displays an image from the camera or library to be cropped.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. I'm currently writing a react-native application with the library react-native-image-crop-picker which includes this library as a dependency. Here is the relevant code that is executed. This bug happens when I take a photo with the camera or when I pick a photo I have previously taken with the camera on a Samsung S5. The OutOfMemoryError happens in BitMapLoadUtils.transformBitmap. I'm not having trouble with newer devices.

Please attach any image files, URL and stack trace that can be used to reproduce the bug.

11-17 09:40:16.847 6019-6105 E/art: Throwing OutOfMemoryError "Failed to allocate a 63489036 byte allocation with 16777120 free bytes and 34MB until OOM" 11-17 09:40:16.857 6019-6105 E/BitmapLoadUtils: transformBitmap: java.lang.OutOfMemoryError: Failed to allocate a 63489036 byte allocation with 16777120 free bytes and 34MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:939) at android.graphics.Bitmap.createBitmap(Bitmap.java:912) at android.graphics.Bitmap.createBitmap(Bitmap.java:843) at com.yalantis.ucrop.util.BitmapLoadUtils.transformBitmap(BitmapLoadUtils.java:46) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:140) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:36) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)

Which versions of uCrop, and which Android API versions are affected by this issue? Did this work in previous versions of uCrop? uCrop: 2.2.6-native uCrop Previous Versions: Not Tested Android API: 21 Phone: Samsung S5

andrewsdv commented 3 years ago

Looks like I have the same issue on HTC device with Android 5.1 (API 21): Throwing OutOfMemoryError "Failed to allocate a 16777228 byte allocation with 6875104 free bytes and 6MB until OOM"

Get the error with 1.8 Mb file, 1.1 Mb. 156 Kb works fine.