cordova-plugin-file-transfer icon indicating copy to clipboard operation
cordova-plugin-file-transfer copied to clipboard

Add throttling to download progress events

Open KleggerKoder opened this issue 4 years ago • 1 comments

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

  • [ ] I've run the tests to see all new and existing tests pass
  • [ ] I added automated test coverage as appropriate for this change
  • [ ] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [ ] I've updated the documentation if necessary

KleggerKoder avatar Nov 27 '20 16:11 KleggerKoder

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.

wilk-polarny avatar Jan 10 '23 14:01 wilk-polarny