apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
598 stars 885 forks source link

Add throttling to download progress events #292

Open KleggerKoder opened 3 years ago

KleggerKoder commented 3 years ago

Platforms affected

iOS and Android

Motivation and Context

Way too many progress events being fired and makes all the application side progress indicators bounce around and sometimes crash the app. I believe download speeds may have affected the number of updates as well.

Description

Added some throttling to reduce message rate to 1/100th what it use to.

Testing

1/100th seemed reasonable for downloading a variety of small and large files on fast connections. Your experience may vary depending on connection speeds.

Checklist

wilk-polarny commented 1 year ago

Hi, I would like to suggest a different approach, since fixing the underlying Cordova issue is arduous. Rather than always skipping 100 elements, I would suggest to:

a) Only emit computable events b) compute and track the progress and only emit an event if the current progress changed significantly. For example, computer the progress %, and only emit an event every 1% - or once a certain amount of transferred bytes has been reached - based on the content length.