apache / apache/cordova-plugin-file-transfer
Downloading a lot of big files in parallel leads to stack overflows (Range Error)
- Dominant language
- JavaScript
- Stars
- 606
- Forks
- 874
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Problem
Downloading a lot (10) big files in parallel leads to stack overflows (Range Error)
### What is expected to happen?
It should download without creating stack overflows
### What does actually happen?
This is the interesting part:
When the plugin does some transfer, it generate a lot of progress messages between the plugin native part and its js part.
Those events generates nested calls for cordova callbacks for the Js part to interpret the native events.
Those nested calls become so long that they just stack overflow..

## Information
I've tested it on Android (chased for days)
### Command or Code
Just download 10 big files in parallel on a not so fast phone (tested on an emulator but hinted by production crashs)
### Environment, Platform, Device
Nexus 7 API 29 emulator
### Version information
Latest version of all.
## Possible Solution
Add an additional parameter to hint not to send back progress event.
Propagate this param to the Android / iOS parts and do not construct/send progress events
It would have the side effect of preventing the `onprogress` to work.
## Checklist
- [X] I searched for existing GitHub issues
- [X] I updated all Cordova tooling to most recent version
- [X] I included all the necessary information above
Contributor guide
Research direction
Start by reproducing the RangeError with 10 large parallel downloads on the Android emulator, then trace the JavaScript-to-native progress callback path described in the report on Android and iOS. Done means parallel downloads no longer overflow the stack, with the effect on onprogress and any opt-out behavior explicitly verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, ios, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100