[
https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15185867#comment-15185867
]
ASF GitHub Bot commented on CB-7862:
------------------------------------
GitHub user jasongin opened a pull request:
https://github.com/apache/cordova-plugin-file/pull/168
CB-7862: FileReader reads large files in chunks with progress
I added support in FileReader for reading large files in chunks and
reporting progress for each chunk. Previously, the Cordova FileReader would
always read files as a single chunk (resulting in OOM exceptions for files > 10
MB or so), and would NEVER invoke the onprogress callback. With this change,
it's possible to read files with sizes up to the actual available application
memory: I have verified with files over 500 MB.
The default chunk size of 256 KB is based on some non-scientific timing
tests I did: it yields only minor overhead from multiple exec() calls while
still providing frequent-enough progress reports for large files. Much smaller
chunk sizes could cause large file reads to take significantly longer due to
the numerous exec() calls (and progress callbacks).
The FileReader.READ_CHUNK_SIZE value is exposed and may be adjusted by app
code, though I don't expect that is something that would need to be changed
normally so I didn't add it to the plugin documentation. The added test case
however does use that capability so that it can verify chunking and progress
behavior without having to generate a very large file.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jasongin/cordova-plugin-file CB-7862
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-plugin-file/pull/168.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #168
----
commit 30f4a8810586dd048e17311f991a9b29315e7fde
Author: Jason Ginchereau <[email protected]>
Date: 2016-03-08T21:11:21Z
CB-7862: FileReader reads large files in chunks with progress
----
> FileReader reads large files in a single chunk causing OOM exceptions
> ---------------------------------------------------------------------
>
> 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
> Assignee: Jason Ginchereau
> Priority: Critical
>
> 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]