You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reading with FileReader.readAsArrayBuffer a chunk of a very large file (2Gb+) causes OutOfMemory on Android (not tested on iOS).
What is expected to happen?
Reading a 5Mb chunk, using FileReader.readAsArrayBuffer on a sliced portion ( FileEntry.slice(x,y) ) of a very large file (2Gb+) should happen without any error, since the file is large, but the chunk is small.
What does actually happen?
The read operation actually causes an OutOfMemory exception.
Information
The final goal of this is to upload large files to our server. We do it chunking the file for many reason (upload time, resuming, memory problems, etc.). The whole file was read correctly, until it reached a certain point and the app crashed with OutOfMemory exception. Reading any part prior to that point seems to work fine.
I found some issues like this around the net, but none could help me.
I even tried applying THIS fix but to no avail.
Command or Code
I created a test project to test this, which you can download HERE.
It is built in Ionic4 and uses this plugin (cordova-plugin-file) and cordova-plugin-filechooser to choose the file.
NOTE: To execute this project you need ionic4 and cordova installed on your computer.
To run it:
Download zip
Extract zip
open CMD, get into the project folder
run npm install
run ionic cordova run android
attach your android device or run an android emulator
run ionic cordova run android
Once in the project, tap the only button; a file chooser should open
choose a file larger then 2050Mb (the larger the better)
the app should crash; if you look ad adb logcat you should see an OutOfMemory error
Feel free to play with the partStart and partEnd const to try reading other parts of the file.
It reads the file from the provided URL using resolveLocalFileSystemUrl, then uses slice on the "file" object in the returned FileEntry. The sliced blob (wich is an IFile with adjusted start and end, AFAIK) is then passed to the readAsArrayBuffer function.
Bug Report
Problem
Reading with
FileReader.readAsArrayBuffer
a chunk of a very large file (2Gb+) causes OutOfMemory on Android (not tested on iOS).What is expected to happen?
Reading a 5Mb chunk, using
FileReader.readAsArrayBuffer
on a sliced portion (FileEntry.slice(x,y)
) of a very large file (2Gb+) should happen without any error, since the file is large, but the chunk is small.What does actually happen?
The read operation actually causes an OutOfMemory exception.
Information
The final goal of this is to upload large files to our server. We do it chunking the file for many reason (upload time, resuming, memory problems, etc.). The whole file was read correctly, until it reached a certain point and the app crashed with OutOfMemory exception. Reading any part prior to that point seems to work fine.
I found some issues like this around the net, but none could help me.
I even tried applying THIS fix but to no avail.
Command or Code
I created a test project to test this, which you can download HERE.
It is built in Ionic4 and uses this plugin (cordova-plugin-file) and cordova-plugin-filechooser to choose the file.
NOTE: To execute this project you need ionic4 and cordova installed on your computer.
To run it:
npm install
ionic cordova run android
ionic cordova run android
adb logcat
you should see an OutOfMemory errorFeel free to play with the
partStart
andpartEnd
const to try reading other parts of the file.It reads the file from the provided URL using
resolveLocalFileSystemUrl,
then usesslice
on the "file" object in the returned FileEntry. The sliced blob (wich is an IFile with adjusted start and end, AFAIK) is then passed to thereadAsArrayBuffer
function.The following is the code that reads the file:
Environment, Platform, Device
This was tested on an android emulator with these specs:
-Based on Pixel 2 device
-API level : 29 (Android Q)
-Graphics: Hardware - GLES 2.0
-Multi-Core CPU: 4
-RAM : 2048 Mb
-VM heap : 256 Mb
-Internal Storage: 10240 Mb
-SD card: Studio-managed 512 Mb
Version information
Ionic:
Ionic CLI : 5.4.11
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 6 other plugins)
Utility:
cordova-res : 0.11.0
native-run : 0.2.7
System:
Android SDK Tools : 26.1.1
NodeJS : v10.13.0
npm : 6.4.1
OS : Windows 10
The text was updated successfully, but these errors were encountered: