kesha-antonov / react-native-background-downloader

About A library for React-Native to help you download large files on iOS and Android both in the foreground and most importantly in the background.
https://www.npmjs.com/package/@kesha-antonov/react-native-background-downloader
Other
26 stars 3 forks source link

rev: New version problems and code revision. #20

Open HyopeR opened 2 weeks ago

HyopeR commented 2 weeks ago

Hello. I was using old versions of this package in my projects in my broadcast environment. However, I could not find a solution to the slow download speeds I recently observed on the Android platform and decided to switch to the updated version you published.

On the Android side, DownloadManager started to be used instead of Fetch 2, and this gave really good results in download speeds. However, I observe memory leaks in the android side logs with new codes.

I've been following this project for a long time and have already submitted a few fixes. I worked on the project a bit to fix most of the bugs I could find in the new version.

Thanks for protecting this project.

What was done:

Android:

  1. Min SDK 21 compatibility will be maintained. Fixed dependency and SDK 21 compatible functions.
  2. Codes have been edited. More readable.
  3. Memory leaks have been fixed.
  4. Event broadcasts have been extended to external functions.
  5. The folder structure has been slightly edited.
  6. Module structure similar to the iOS side.

Ios:

  1. Fixed dependencies.
  2. The error encountered after hot reload has been fixed. Issue: https://github.com/kesha-antonov/react-native-background-downloader/issues/4
  3. Similar module structure with Android side.

Typescript:

  1. Metadata error related to DownloadTask type has been corrected. Issue: https://github.com/kesha-antonov/react-native-background-downloader/issues/1
  2. Type error regarding the setConfig function has been corrected. Issue: https://github.com/kesha-antonov/react-native-background-downloader/issues/8 Issue: https://github.com/kesha-antonov/react-native-background-downloader/issues/11
  3. Type errors related to the DownloadTask class have been resolved.
  4. The type error regarding DownloadTaskState has already been corrected. This PR should be closed. Issue: https://github.com/kesha-antonov/react-native-background-downloader/issues/3

Error log on Android:

ss
kesha-antonov commented 2 weeks ago

Hi!

Wow, thanks for huge updates, I'll check it

relaxxpls commented 5 days ago

@kesha-antonov I hope you're doing well! Have you had a chance to review it yet?

kesha-antonov commented 4 days ago

@kesha-antonov I hope you're doing well! Have you had a chance to review it yet?

Hi Yes, I'll have time on this week for this PR 🙌

HyopeR commented 2 days ago

Hello again. The issues I mentioned below are only related to the Android platform.

I've been testing on real Android devices for 2 days. I performed the tests for the following. 1- In the released version. 3.1.3 2- In the pull request version.

The results are as follows: 1- The released version contains memory leaks for Android on both simulators and real devices. 2- The pull request version no memory leaks are observed in the simulators. On real devices, it seems like there are still things to be solved.

I'm currently looking at what I can do to fix this problem. Please feel free to share with me if you have any ideas before combining. The error I observed on real devices is as follows.

05-16 19:29:11.467   487   487 E ActivityThread: Service com.android.providers.downloads.DownloadJobService has leaked ServiceConnection android.media.MediaScannerConnection@7c89f84 that was originally bound here
05-16 19:29:11.467   487   487 E ActivityThread: android.app.ServiceConnectionLeaked: Service com.android.providers.downloads.DownloadJobService has leaked ServiceConnection android.media.MediaScannerConnection@7c89f84 that was originally bound here
05-16 19:29:11.467   487   487 E ActivityThread:    at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1538)
05-16 19:29:11.467   487   487 E ActivityThread:    at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1430)
05-16 19:29:11.467   487   487 E ActivityThread:    at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1622)
05-16 19:29:11.467   487   487 E ActivityThread:    at android.app.ContextImpl.bindService(ContextImpl.java:1574)
05-16 19:29:11.467   487   487 E ActivityThread:    at android.content.ContextWrapper.bindService(ContextWrapper.java:697)
05-16 19:29:11.467   487   487 E ActivityThread:    at android.media.MediaScannerConnection.connect(MediaScannerConnection.java:122)
05-16 19:29:11.467   487   487 E ActivityThread:    at com.android.providers.downloads.DownloadScanner.requestScan(DownloadScanner.java:130)
05-16 19:29:11.467   487   487 E ActivityThread:    at com.android.providers.downloads.DownloadScanner.requestScanBlocking(DownloadScanner.java:85)
05-16 19:29:11.467   487   487 E ActivityThread:    at com.android.providers.downloads.DownloadThread.run(DownloadThread.java:817)
05-16 19:29:11.493   487  5124 E MediaScannerService: Exception in handleMessage
05-16 19:29:11.493   487  5124 E MediaScannerService: java.lang.NullPointerException: url
05-16 19:29:11.493   487  5124 E MediaScannerService:   at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:128)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at android.content.ContentResolver.delete(ContentResolver.java:1635)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at com.android.providers.downloads.DownloadScanner.onScanCompleted(DownloadScanner.java:174)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at android.media.MediaScannerConnection$1.scanCompleted(MediaScannerConnection.java:55)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at com.android.providers.media.MediaScannerService$ServiceHandler.handleMessage(MediaScannerService.java:420)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at android.os.Handler.dispatchMessage(Handler.java:105)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at android.os.Looper.loop(Looper.java:164)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at com.android.providers.media.MediaScannerService.run(MediaScannerService.java:318)
05-16 19:29:11.493   487  5124 E MediaScannerService:   at java.lang.Thread.run(Thread.java:764)