This is problematic because _realReader is set as this._realReader = origFileReader ? new origFileReader() : {};, and I have no idea how to access that for debugging.
Do you have any idea what might be going on here? Is it a memory issue on iOS? Does Cordova timeout over multiple repeated requests?
Something to note, the full list download works fine every time on the iOS xCode simulator. This is leading me to believe it might be a memory issue, but I'm not sure.
EDIT: I now see that the error is happening in the Ionic plugin (though this still might be an issue with the way Blobs are maintained in a Cordova environment)
I put some logging into the Ionic File plugin writeFileInChunks method. It became clear that the plugin, for whatever reason, error'd during a slice step.
SIZE OF FILE AT START: 34012899
CALCULATED SIZE: 1048576
SIZE OF CHUNK TO WRITE: 0
On retry:
SIZE OF FILE AT START: 34012899
CALCULATED SIZE: 1048576
SIZE OF CHUNK TO WRITE: 1048576
CALCULATED SIZE: 1048576
SIZE OF CHUNK TO WRITE: 1048576
...
...
...
CALCULATED SIZE: 458467
SIZE OF CHUNK TO WRITE: 458467
So for whatever reason, after a large number of previous downloads, that file.slice step results in an empty/corrupted blob.
The problem as the user sees it:
What I'm seeing as a developer:
this.file.writeFile(directoryPath, fileName, blob, {replace: true})
Which is not super helpful.
My debugging has led me to observe that the download fails in FileReader.js (which is called as part of the FileWriter step) with the line
return this._realReader.readAsArrayBuffer(file);
https://github.com/apache/cordova-plugin-file/blob/4a92bbbea755aa9e5bf8cfd160fb9da1cd3287cd/www/FileReader.js#L287This is problematic because _realReader is set as
this._realReader = origFileReader ? new origFileReader() : {};
, and I have no idea how to access that for debugging.To make matters worse, when I put a debugging statement here: https://github.com/apache/cordova-plugin-file/blob/4a92bbbea755aa9e5bf8cfd160fb9da1cd3287cd/www/FileWriter.js#L125, the error just prints out as an empty hash, telling me nothing.
Do you have any idea what might be going on here? Is it a memory issue on iOS? Does Cordova timeout over multiple repeated requests?
Something to note, the full list download works fine every time on the iOS xCode simulator. This is leading me to believe it might be a memory issue, but I'm not sure.
EDIT: I now see that the error is happening in the Ionic plugin (though this still might be an issue with the way Blobs are maintained in a Cordova environment)
I put some logging into the Ionic File plugin
writeFileInChunks
method. It became clear that the plugin, for whatever reason, error'd during aslice
step.The output for the failed document:
On retry:
So for whatever reason, after a large number of previous downloads, that file.slice step results in an empty/corrupted blob.
Any ideas on how to correct this?
Ran another test with some expanded logging:
Output came to:
Further confirming the issue