numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leaks with `backgroundUpload` causing crashes

GunnarAK opened this issue · comments

Current behavior

Uploading 69 video files ranging from 12 MB to 170 MB (using an asyncqueue with concurrency limit of 5) will cause to increase the memory usage on iOS Simulator easily to 4 GB without releasing memory after a successful upload. Unmounting the uploading logic in JS will also not release memory.

I have received various crash reports from Firebase Crashlytics about iPhones experiencing crashes due to this.

Expected behavior

After an upload is done the memory should be released from that task.

Platform

  • Android
  • iOS

With an Simulator running iOS 16.4 I'm able to reproduce this 100% of the time.
Simulator running iOS 17.4 does not report this issue with the Performance Monitor
On real devices it appears to happen on iOS 18 as well. And don't recall with certainty, but also iOS 17 on real devices.

React Native Version

0.73.2

React Native Compressor Version

1.8.24

Reproducible Steps And Demo

  1. Have a large set of video files (any multitude of the concurrency limit)
  2. Optional: Write async queue logic with concurrency limit of 5
  3. Upload multiple files to a (local) server
  4. Check RAM usage before and after uploading

Video demo

https://mega.nz/file/J4kDTJbT#Tf_zWMLtmg98Ax921nRlCkxh2YnouabflKnk0G-PgUE

I've also tried 'cancelling' an upload after its done, hoping it would collect the garbage. But unfortunately it does nothing.

@numandev1 hey man, hope you're doing well!

Are you able to reproduce this?