react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Use react-native-fs download a mp4 file,is very slow

Open ghost opened this issue 8 years ago • 11 comments

the mp4 is 698K but download it,is very slow,very very slow.

Do you have this question?

ghost avatar Jan 07 '17 02:01 ghost

same issue... an audio file of few mb takes minutes of time to download.

navsaini53 avatar Jan 07 '17 08:01 navsaini53

me too.

kaola8246 avatar Feb 03 '17 10:02 kaola8246

Are you running your app in Debug mode or Release?

airman00 avatar Feb 17 '17 15:02 airman00

release

On Fri, Feb 17, 2017 at 8:32 PM, Eric Forkosh [email protected] wrote:

Are you running your app in Debug mode or Release?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/johanneslumpe/react-native-fs/issues/230#issuecomment-280673288, or mute the thread https://github.com/notifications/unsubscribe-auth/AHcOS50TfpAqsgqrdWqv6rCK4EGlW-c0ks5rdbadgaJpZM4LdS4T .

navsaini53 avatar Feb 20 '17 13:02 navsaini53

iOS or Android or both?

itinance avatar Apr 28 '17 22:04 itinance

Under the hood this Lib uses native methods to manage network requests:

iOS: NSUrlSessionDownloadTask Android: HttpUrlConnection

But, on Android the Buffer-Size is very small (8 kb). You might want to increase the buffer-size for testing purposes and make a suggestion if you could speed up the download process then?

Change these both lines for testing with a higher buffer size (maybe 64 kb or more):

  1. https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/Downloader.java#L103
  2. https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/Downloader.java#L106

Don't forget to restart the packager after modification of native library code and to recompile/reinstall the app then. Let me know if you could speed it up pls.

itinance avatar May 04 '17 09:05 itinance

Hello @itinance, I have the same problem on iOS, how can I solve it?

Thank you, Marco

marf avatar Apr 06 '18 12:04 marf

slow? you setState prograss?

a812975315 avatar Apr 17 '18 01:04 a812975315

did anyone solve this?

sebqq avatar Mar 01 '19 13:03 sebqq

Same problem. rn-fetch-blob has (had, before parallel download broke) much better download performance.

schumannd avatar Apr 03 '19 14:04 schumannd

In my case changing the background property from false to true solved the speed issue.

const progress = RNFS.downloadFile({
background: false, // if true, download is going to be very slow on iOS.
begin: file => (contentLength = file.contentLength),
discretionary: true,
fromUrl: url,
progressDivider: 5,
toFile: localUrl,
progress: res => {
  let progress = (res.bytesWritten / res.contentLength) * 100
  progress = parseInt(progress?.toFixed(2))
  console.log(progress)
  }
})

bilal-korir avatar Mar 12 '24 14:03 bilal-korir