[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15418004#comment-15418004 ] Jason Ginchereau commented on CB-7862: -- [~tl274n] Yes, please open a new bug, and feel free to submit a PR. I agree with the fix. Note since the bug is in the JS code I think the issue is not iOS-specific. > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15417828#comment-15417828 ] Tony Leung commented on CB-7862: Now that the chunk size is - FileReader.READ_CHUNK_SIZE = 256*1024; I found a bug on iOS that readAsDataURL in CDVFile.m, converting it to Base64 will not work because the chunk size 262144 is not dividable by 3. The quick fix will be FileReader.READ_CHUNK_SIZE = (256*1024) - 1 Should I open a bug for that? > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15189728#comment-15189728 ] ASF GitHub Bot commented on CB-7862: Github user asfgit closed the pull request at: https://github.com/apache/cordova-plugin-file/pull/168 > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15189726#comment-15189726 ] ASF subversion and git services commented on CB-7862: - Commit 3eae249cca98de6793ed8af314a89952a912c464 in cordova-plugin-file's branch refs/heads/master from [~jasongin] [ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file.git;h=3eae249 ] CB-7862: FileReader reads large files in chunks with progress. This closes #168 > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186230#comment-15186230 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55457515 --- Diff: www/FileReader.js --- @@ -96,6 +106,78 @@ function initRead(reader, file) { } /** + * Callback used by the following read* functions to handle incremental or final success. + * Must be bound to the FileReader's this along with all but the last parameter, + * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate) + * @param readType The name of the read function to call. + * @param encoding Text encoding, or null if this is not a text type read. + * @param offset Starting offset of the read. + * @param totalSize Total number of bytes or chars to read. + * @param accumulate A function that takes the callback result and accumulates it in this._result. + * @param r Callback result returned by the last read exec() call, or null to begin reading. + */ +function readSuccessCallback(readType, encoding, offset, totalSize, accumulate, r) { +if (this._readyState === FileReader.DONE) { +return; +} + +if (typeof r !== "undefined") { +accumulate(r); +this._progress = Math.min(this._progress + FileReader.READ_CHUNK_SIZE, totalSize); + +if (typeof this.onprogress === "function") { +this.onprogress(new ProgressEvent("progress", {loaded:this._progress, total:totalSize})); +} +} + +if (typeof r === "undefined" || this._progress < totalSize) { +var execArgs = [ +this._localURL, +offset + this._progress, +offset + this._progress + Math.min(totalSize - this._progress, FileReader.READ_CHUNK_SIZE)]; +if (encoding) { --- End diff -- Sure, that works. I just thought it was unclear why you were inserting an argument in this way > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186219#comment-15186219 ] ASF GitHub Bot commented on CB-7862: Github user jasongin commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55456235 --- Diff: www/FileReader.js --- @@ -96,6 +106,78 @@ function initRead(reader, file) { } /** + * Callback used by the following read* functions to handle incremental or final success. + * Must be bound to the FileReader's this along with all but the last parameter, + * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate) + * @param readType The name of the read function to call. + * @param encoding Text encoding, or null if this is not a text type read. + * @param offset Starting offset of the read. + * @param totalSize Total number of bytes or chars to read. + * @param accumulate A function that takes the callback result and accumulates it in this._result. + * @param r Callback result returned by the last read exec() call, or null to begin reading. + */ +function readSuccessCallback(readType, encoding, offset, totalSize, accumulate, r) { +if (this._readyState === FileReader.DONE) { +return; +} + +if (typeof r !== "undefined") { +accumulate(r); +this._progress = Math.min(this._progress + FileReader.READ_CHUNK_SIZE, totalSize); + +if (typeof this.onprogress === "function") { +this.onprogress(new ProgressEvent("progress", {loaded:this._progress, total:totalSize})); +} +} + +if (typeof r === "undefined" || this._progress < totalSize) { +var execArgs = [ +this._localURL, +offset + this._progress, +offset + this._progress + Math.min(totalSize - this._progress, FileReader.READ_CHUNK_SIZE)]; +if (encoding) { --- End diff -- See the doc-comment for the encoding param. > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186136#comment-15186136 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on the pull request: https://github.com/apache/cordova-plugin-file/pull/168#issuecomment-194033408 LGTM. Tested on Marshmallow device and KitKat emulator > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186114#comment-15186114 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55451426 --- Diff: www/FileReader.js --- @@ -96,6 +106,78 @@ function initRead(reader, file) { } /** + * Callback used by the following read* functions to handle incremental or final success. + * Must be bound to the FileReader's this along with all but the last parameter, + * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate) + * @param readType The name of the read function to call. + * @param encoding Text encoding, or null if this is not a text type read. + * @param offset Starting offset of the read. + * @param totalSize Total number of bytes or chars to read. + * @param accumulate A function that takes the callback result and accumulates it in this._result. + * @param r Callback result returned by the last read exec() call, or null to begin reading. + */ +function readSuccessCallback(readType, encoding, offset, totalSize, accumulate, r) { +if (this._readyState === FileReader.DONE) { +return; +} + +if (typeof r !== "undefined") { +accumulate(r); +this._progress = Math.min(this._progress + FileReader.READ_CHUNK_SIZE, totalSize); + +if (typeof this.onprogress === "function") { +this.onprogress(new ProgressEvent("progress", {loaded:this._progress, total:totalSize})); +} +} + +if (typeof r === "undefined" || this._progress < totalSize) { +var execArgs = [ +this._localURL, +offset + this._progress, +offset + this._progress + Math.min(totalSize - this._progress, FileReader.READ_CHUNK_SIZE)]; +if (encoding) { --- End diff -- Nitpick: It would be nice to have a comment explaining that you only insert the encoding when reading as text > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186025#comment-15186025 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55443925 --- Diff: tests/tests.js --- @@ -2382,12 +2383,53 @@ exports.defineAutoTests = function () { expect(true).toFailWithMessage('Platform does not supported this feature'); done(); } -runReaderTest('readAsArrayBuffer', true, done, function (evt, fileData, fileDataAsBinaryString) { +runReaderTest('readAsArrayBuffer', true, done, null, function (evt, fileData, fileDataAsBinaryString) { expect(arrayBufferEqualsString(evt.target.result, fileDataAsBinaryString.slice(0, -1))).toBe(true); done(); }, 0, -1); }); -}); +it("file.spec.94.5 should read large file in multiple chunks, readAsArrayBuffer", function (done) { +// Skip test if ArrayBuffers are not supported (e.g.: Android 2.3). +if (typeof window.ArrayBuffer == 'undefined') { +expect(true).toFailWithMessage('Platform does not supported this feature'); --- End diff -- A, I guess leave it as is and we can correct it all at once later > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186023#comment-15186023 ] ASF GitHub Bot commented on CB-7862: Github user jasongin commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55443750 --- Diff: tests/tests.js --- @@ -2382,12 +2383,53 @@ exports.defineAutoTests = function () { expect(true).toFailWithMessage('Platform does not supported this feature'); done(); } -runReaderTest('readAsArrayBuffer', true, done, function (evt, fileData, fileDataAsBinaryString) { +runReaderTest('readAsArrayBuffer', true, done, null, function (evt, fileData, fileDataAsBinaryString) { expect(arrayBufferEqualsString(evt.target.result, fileDataAsBinaryString.slice(0, -1))).toBe(true); done(); }, 0, -1); }); -}); +it("file.spec.94.5 should read large file in multiple chunks, readAsArrayBuffer", function (done) { +// Skip test if ArrayBuffers are not supported (e.g.: Android 2.3). +if (typeof window.ArrayBuffer == 'undefined') { +expect(true).toFailWithMessage('Platform does not supported this feature'); --- End diff -- This is copied from a bunch of other tests. Should I update all of those too? > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186019#comment-15186019 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55443467 --- Diff: tests/tests.js --- @@ -2382,12 +2383,53 @@ exports.defineAutoTests = function () { expect(true).toFailWithMessage('Platform does not supported this feature'); done(); } -runReaderTest('readAsArrayBuffer', true, done, function (evt, fileData, fileDataAsBinaryString) { +runReaderTest('readAsArrayBuffer', true, done, null, function (evt, fileData, fileDataAsBinaryString) { expect(arrayBufferEqualsString(evt.target.result, fileDataAsBinaryString.slice(0, -1))).toBe(true); done(); }, 0, -1); }); -}); +it("file.spec.94.5 should read large file in multiple chunks, readAsArrayBuffer", function (done) { +// Skip test if ArrayBuffers are not supported (e.g.: Android 2.3). +if (typeof window.ArrayBuffer == 'undefined') { +expect(true).toFailWithMessage('Platform does not supported this feature'); --- End diff -- supported -> support > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186020#comment-15186020 ] ASF GitHub Bot commented on CB-7862: Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55443526 --- Diff: tests/tests.js --- @@ -2382,12 +2383,53 @@ exports.defineAutoTests = function () { expect(true).toFailWithMessage('Platform does not supported this feature'); done(); } -runReaderTest('readAsArrayBuffer', true, done, function (evt, fileData, fileDataAsBinaryString) { +runReaderTest('readAsArrayBuffer', true, done, null, function (evt, fileData, fileDataAsBinaryString) { expect(arrayBufferEqualsString(evt.target.result, fileDataAsBinaryString.slice(0, -1))).toBe(true); done(); }, 0, -1); }); -}); +it("file.spec.94.5 should read large file in multiple chunks, readAsArrayBuffer", function (done) { +// Skip test if ArrayBuffers are not supported (e.g.: Android 2.3). +if (typeof window.ArrayBuffer == 'undefined') { +expect(true).toFailWithMessage('Platform does not supported this feature'); --- End diff -- Also, shouldn't this just be pending? > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186005#comment-15186005 ] ASF GitHub Bot commented on CB-7862: Github user jasongin commented on the pull request: https://github.com/apache/cordova-plugin-file/pull/168#issuecomment-194003277 @rakatyal or @riknoll please review > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-7862) FileReader reads large files in a single chunk causing OOM exceptions
[ 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 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org