react-native-fetch-blob has memory leak during update download progress
pengcao1 opened this issue · 0 comments
Hi ! Thank you for reporting an issue, but we would like to remind you, we have a trouble shooting page in our wiki.
You may want to take a look on that page or find issues tagged "trouble shooting" :p
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-fetch-blob": "0.10.8"
OOM stack:
com.RNFetchBlob.Response.RNFetchBlobFileResp$ProgressReportingSource.read (RNFetchBlobFileResp.java:81)
okio.Buffer.writeAll (Buffer.java:1005)
okio.RealBufferedSource.readByteArray (RealBufferedSource.java:107)
okhttp3.ResponseBody.bytes (ResponseBody.java:135)
com.RNFetchBlob.RNFetchBlobReq.done (RNFetchBlobReq.java:513)
com.RNFetchBlob.RNFetchBlobReq.access$100 (RNFetchBlobReq.java:60)
com.RNFetchBlob.RNFetchBlobReq$3.onResponse (RNFetchBlobReq.java:423)
okhttp3.RealCall$AsyncCall.execute (RealCall.java:135)
okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32)
` this.downloadTask = RNFetchBlob.config({
fileCache: true,
path: this.getDownloadDir(urlObject) + this.getFileName(urlObject),
}).fetch("GET", urlObject.url, {});
this.downloadTask
.progress((received: any, total: any) => {
if (urlObject.name === "audioUrlRemote") {
const progress = received / total;
this.currentDownloadItem.downloadedWeight = WEIGHT_MAIN_AUDIO * progress;
this.setState({ ...this.state, refreshTrigger: !this.state.refreshTrigger });
}
if (
this.currentDownloadItem.downloadStatus === DownloadStatus.PAUSE ||
this.currentDownloadItem.downloadStatus === DownloadStatus.NotDownload
) {
this.downloadTask.cancel(() => {});
}
})
.then((res: any) => {
// for bug fixing on android
if (this.currentDownloadItem.downloadStatus !== DownloadStatus.Downloading) {
return;
}
// console.log("save file to: " + res.path());
this.onDownloadComplete(urlObject, res.path(), urls);
})
.catch(() => {
NetInfo.isConnected.fetch().then((isConnected) => {
if (!isConnected) {
this.props.dispatch!(
addNotification({
type: ErrorTypes.NETWORK_ERROR,
msg: "error on catch",
}),
);
pauseAllDownload(this.props.downloadInfo, this.props.dispatch!);
}
});
});
};`