[ 
https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15174226#comment-15174226
 ] 

Jason Ginchereau commented on CB-7862:
--------------------------------------

I reproduced this problem and looked into the cause. The problem is that the 
Cordova file plugin's implementation of FileReader.readAsArrayBuffer() and 
other FileReader.readAs* methods will always try to read the whole file in a 
single chunk. So if the file is large then the app is likely to crash with an 
out-of-memory exception when it fails to allocate many megabytes of contiguous 
memory.

It should be straightforward to fix the FileReader implementation to read large 
files in smaller chunks. The FileReader API is already designed for that 
anyway, with its onprogress callback.

I've raised the priority to Critical because I think it's a pretty important 
thing to fix (and surprising that it has been broken so long).

> crash when copying big file from html file input with 
> ------------------------------------------------------
>
>                 Key: CB-7862
>                 URL: https://issues.apache.org/jira/browse/CB-7862
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 4.0.0
>         Environment: Android
>            Reporter: shenzhuxi
>            Priority: Critical
>              Labels: Android
>
> In Android, I tried to copy a 14MB file from html file input with 
> org.apache.cordova.file 1.3.1. The App crashed and a 0 byte file was copied. 
> I use http://ngcordova.com/ and here is my code 
> https://github.com/shenzhuxi/readiator/blob/master/src/js/cordova-index.js. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to