Tell us which versions you are using:
Images are returned from the following API call, similar to how they are on iOS.
return ImagePicker.openPicker({
multiple: true,
mediaType: 'photo',
includeBase64: true,
});
When adding many items (reliably crashes with 10+ on Samsung Galaxy S7), the app pauses for a moment and then crashes to the menu.
07-12 17:25:46.744 4205-4275/com.myappnamegoeshere W/art: Throwing OutOfMemoryError "Failed to allocate a 150583044 byte allocation with 16777216 free bytes and 24MB until OOM"
07-12 17:25:46.878 4205-4275/com.myappnamegoeshere W/art: Throwing OutOfMemoryError "Failed to allocate a 150583044 byte allocation with 16777216 free bytes and 24MB until OOM"
--------- beginning of crash
07-12 17:25:46.879 4205-4275/com.myappnamegoeshere E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.myappnamegoeshere, PID: 4205
java.lang.OutOfMemoryError: Failed to allocate a 150583044 byte allocation with 16777216 free bytes and 24MB until OOM
at java.util.Arrays.copyOf(Arrays.java:3352)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:417)
at java.lang.StringBuffer.append(StringBuffer.java:237)
at java.io.StringWriter.write(StringWriter.java:101)
at java.io.StringWriter.append(StringWriter.java:143)
at com.facebook.react.devsupport.JSDebuggerWebSocketClient.executeJSCall(JSDebuggerWebSocketClient.java:133)
at com.facebook.react.devsupport.WebsocketJavaScriptExecutor.executeJSCall(WebsocketJavaScriptExecutor.java:181)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:199)
Update: I've tried adding android:largeHeap="true" to my AndroidManifest.xml, as per https://stackoverflow.com/a/42212814
This results in the Promise throwing an error: length=1; index=1
Is this an issue for android? I run this code on Nexus 6 (3GB ram)
ImagePicker.openPicker({
multiple: true,
maxFiles: 15,
includeBase64: true,
mediaType: 'photo'
}).then(res => {
console.log('res', res);
})
choose about 7 photo (about 16MB) and my app crash showing out of memory
but on ios it works fine
Update, fixed!!
when picking multiple, remember don't set this lineincludeBase64: true in openPicker
this will cause outofMemory issue on Android
if you need base64 data, use sth like FileSystem.readFile(image.path, 'base64') in .then()
Anyway hope this will be fixed soon
Most helpful comment
Update, fixed!!
when picking multiple, remember don't set this line
includeBase64: truein openPickerthis will cause outofMemory issue on Android
if you need base64 data, use sth like
FileSystem.readFile(image.path, 'base64')in.then()Anyway hope this will be fixed soon