react-native-fs
react-native-fs copied to clipboard
RNFS.downloadFile is blocking the UI thread, Cannot do any action or navigation.
Having this issue too. Any ideas?
Don't know if it's the same bug but I've found something there https://github.com/itinance/react-native-fs/issues/920#issue-686529931
Can you verify whether this pull request works [#794 (pull request)]
@uday5162 will try it today and this weekend. Thanks!
@uday5162 I tried it and it worked perfectly on Android.
But on iOS, I cannot link my pods to my xCode project. It seems that you're PR is using version 2.16.1 and there is a bug with importing #import <React/RCTImageLoaderProtocol.h> because I am using React-Native 0.60.6 and not >= 0.61
You're PR should be a fix to all versions of RNFS. So my options are to use your PR and apply a patch after, or installing the right RNFS version to my project and apply your PR as a patch.
I'm seeing this issue as well. It's especially bad on Android. I tried patching with the changes in https://github.com/itinance/react-native-fs/pull/794 but it didn't help.
Try passing a value for the progressInterval param, e.g. 100.
From what I can tell, because the default value is 0 RNFS invokes the progress callback function every time it receives a bit of data, and that can overwhelm the UI thread (even though the downloader itself runs in its own thread).
P.S. The PR mentioned above deals with the proper cleaning up of callbacks and such. Thread spawning for downloads is already part of the current RNFS codebase.
P.P.S. Alternately, pass a value for progressDivider (say, 5) instead of progressInterval.
I guess I solved my problem. Indeed passing progressInterval value helped, but also I found some errors in my code that could have solved my problem.
@idrm it looks like the progressInterval and progressDivider params are only used when a progress callback is provided. Unfortunately I'm seeing UI blocking even without a progress callback, so specifying those params didn't solve the problem for me. This issue is most noticeable when trying to download a bunch of files at once, in my case I'm trying to download ~10 images.
https://github.com/itinance/react-native-fs/blob/f2f8f4a058cd9acfbcac3b8cf1e08fa1e9b09786/android/src/main/java/com/rnfs/Downloader.java#L119-L137
Try passing a value for the
progressIntervalparam, e.g. 100.From what I can tell, because the default value is 0 RNFS invokes the progress callback function every time it receives a bit of data, and that can overwhelm the UI thread (even though the downloader itself runs in its own thread).
P.S. The PR mentioned above deals with the proper cleaning up of callbacks and such. Thread spawning for downloads is already part of the current RNFS codebase.
P.P.S. Alternately, pass a value for
progressDivider(say, 5) instead ofprogressInterval.
Thanks bro, It solve my problem!!!
Try passing a value for the
progressIntervalparam, e.g. 100.From what I can tell, because the default value is 0 RNFS invokes the progress callback function every time it receives a bit of data, and that can overwhelm the UI thread (even though the downloader itself runs in its own thread).
P.S. The PR mentioned above deals with the proper cleaning up of callbacks and such. Thread spawning for downloads is already part of the current RNFS codebase.
P.P.S. Alternately, pass a value for
progressDivider(say, 5) instead ofprogressInterval.
Thanks mate. Been struggling with this for a whole day
Any update?
I am having the same problem! Does anyone know if this issue has been fixed?