cordova-plugin-file
cordova-plugin-file copied to clipboard
Low performance when read large file with cordova-plugin-file
am creating a hybrid app with Angular 7, Ionic 4 and Cordova.
I need to read a large file (> 1GB) located on Android file system but i am facing a performance issue. With the current implementation i have a speed about 2.5 MB/sec.
Is it an issue with the plugin itself or the implementation ?
I tried to modify BLOB_SIZE but the maximum speed i obtained was 2.5 MB/s.
const BLOB_SIZE = 1024*1024;
usbRead(fileEntry: FileEntry) {
fileEntry.file((file) => {
const reader = new FileReader();
reader.onload = () => {
const buffer = new Uint8Array(reader.result as ArrayBuffer);
readCounter += buffer.byteLength;
console.log(textDecoder.decode(buffer));
offset += BLOB_SIZE;
if (offset >= file.size) {
console.log('end');
return;
}
const slice = file.slice(offset, offset + BLOB_SIZE);
reader.readAsArrayBuffer(slice);
};
reader.readAsArrayBuffer(file.slice(0, BLOB_SIZE));
});
});
}
I tested on Xiaomi Redmi Note 7 with Android 9
My package.json has the following plugin version :
@ionic-native/file": "^5.12.0"
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
hey i am also faceing same issue you got any solution please share with me
I noticed similar issue with 10 - 20 MB files (read was unexpectly slow) - I have increase speed of reading (25%) by changing READ_CHUNK_SIZE in FileReader.js - currently it is set to 256KB - when you adjust it, you should notice some improvements.
thanks to giving replay but its not solve my problem its take more time to read bloab
On Sun, Mar 8, 2020 at 3:18 PM Marcin [email protected] wrote:
I noticed similar issue with 10 - 20 MB files (read was unexpectly slow) - I have increase speed of reading (25%) by changing READ_CHUNK_SIZE in FileReader.js - currently it is set to 256KB - when you adjust it, you should notice some improvements.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apache/cordova-plugin-file/issues/341?email_source=notifications&email_token=ANBLVRRY77577AU72VP2V6DRGNSVFA5CNFSM4ISDHPKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOERIQI#issuecomment-596186177, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBLVRXMMPL7E473YRSN3NTRGNSVFANCNFSM4ISDHPKA .
@Jeremy38100 / @Avinash9100
did you found any solution for this?
only what I found currently is : https://stackoverflow.com/questions/54946864/out-of-memory-error-when-calling-readasarraybuffer-method-on-filereader-of-the-c