react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Error when reading large file on Android

Open mannok opened this issue 6 years ago • 28 comments

I am trying to read 2xxmb crypt12 file from FS. When I trying to run await RNFS.readFile(${RNFS.ExternalStorageDirectoryPath}/Whatsapp/Databases/msgstore.db.crypt12), it prompts up

Could not invoke RNFSManager.readFile

null

Failed to allocate a 536870928 byte allocation with 25165824 free bytes and 248MB until OOM, max allowed footprint 301365936, growth limit 536870912

I have already set android:hardwareAccelerated="false" and android:largeHeap="true" in AndroidManifest.xml but no luck.

How can I solve it? Thank you

mannok avatar Dec 16 '18 07:12 mannok

Well, such things happen when you are blowing your devices memory with such a big file. It was never a good practice to load a file completely into memory. You should treat this instead on a chunk-by-chunk basis. Best thing here would be to find a library, that is capable of decrypting the crypt12-file. Then you can load this database (assuming it is Sqlite3 based) with react-native-sqlite-storage to dig trough the data.

There is little chance, that whatsapp is using sqlite-cipher for encyrption (DYOR pls). Then this issue should give you help: https://github.com/craftzdog/react-native-sqlite-2/issues/32

itinance avatar Dec 20 '18 07:12 itinance

same issue, I tried to upload 30 sec video

lyudad avatar Apr 30 '20 13:04 lyudad

同样的问题,我尝试上传30秒的视频

Did you solve this problem later

same issue, I tried to upload 30 sec video

Did you solve this problem later

sej1228 avatar May 06 '20 09:05 sej1228

I have tried rn-fetch-blob library instead and it work for me

lyudad avatar May 07 '20 08:05 lyudad

I have tried rn-fetch-blob library instead and it work for me

RNFetchBlob.fs.readStream?

sej1228 avatar May 07 '20 09:05 sej1228

no const data = RNFetchBlob.wrap(localPath) RNFetchBlob.fetch('POST', url, { 'Content-Type': 'multipart/form-data' }, [ { name: 'file', filename: 'test', data, type: this.mediaMimeType } ]) but I have found that it's slower than send data in base64. So I still looking for faster solution

lyudad avatar May 08 '20 20:05 lyudad

Hi, Any update about this issue? I have the same issue.

shengliZh avatar Jun 04 '20 07:06 shengliZh

Same issue

RahulkrishnanSpericorn avatar Jun 18 '20 07:06 RahulkrishnanSpericorn

I am having the same issue any solution??

prafulla-codes avatar Jun 28 '20 07:06 prafulla-codes

Same here

dolphinflow86 avatar Sep 22 '20 07:09 dolphinflow86

Same here

SamiChab avatar Feb 12 '21 16:02 SamiChab

Getting same error. Device is fresh android emulator with android 11, lots of free space and 800mb free memory so that shouldn't be problem. Error doesn't happen everytime tho, with small files never, ~10mb file, sometimes/often, bigger than that, always.

aalhitennf avatar Aug 30 '21 18:08 aalhitennf

Any update on this issue?

AliRehman7141 avatar Sep 18 '21 06:09 AliRehman7141

+1

Marbos21 avatar Jul 11 '22 16:07 Marbos21

+1

ghost avatar Jan 30 '23 08:01 ghost

Any update on this issue?

CrisRondaS avatar Jan 30 '23 17:01 CrisRondaS

Same here

adrienGzc avatar Feb 03 '23 14:02 adrienGzc

Hello, any help with this error?

jjmayorgaq avatar Mar 08 '23 23:03 jjmayorgaq

Same issue here. I am using the read() method to chunk 5Mb segments of a 1Gb file and can process about 300Mb before this fails.

jim-jigx avatar May 23 '23 17:05 jim-jigx

same here. any update with this issue ?

dzakki avatar Dec 19 '23 11:12 dzakki

+1

AlexAJ9 avatar Jan 10 '24 10:01 AlexAJ9

+1

favaztechcurve avatar Feb 05 '24 12:02 favaztechcurve

same here. any update with this issue ?

@dzakki did you find the issue?

favaztechcurve avatar Feb 05 '24 13:02 favaztechcurve

same here. any update with this issue ?

@dzakki did you find the issue?

I haven't identified the issue yet

dzakki avatar Feb 05 '24 14:02 dzakki

still facing a similar issue when using RNFS.read with a reasonable chunk size, it looks like it tried to allocate memory larger than the chunk size requested.

7adidaz avatar Mar 31 '24 19:03 7adidaz