[PR #1749] [MERGED] feat: implement download queue on iOS #1679

Closed
opened 2026-04-25 00:00:34 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf-app/pull/1749
Author: @danyhoron
Created: 12/10/2025
Status: Merged
Merged: 2/10/2026
Merged by: @advplyr

Base: masterHead: master


📝 Commits (2)

  • 68afba4 feat: implement download queue on iOS
  • 9d5cbd3 Merge branch 'advplyr:master' into master

📊 Changes

1 file changed (+99 additions, -33 deletions)

View changed files

📝 ios/App/App/plugins/AbsDownloader.swift (+99 -33)

📄 Description

Brief summary

I tried to download a 3GB (90+ files) on my iPhone, and the phone started to get hot and after a few minutes the app crashed.
I implemented a download queue, to only get 3 files at a time, and not all of the files in the list.

Which issue is fixed?

I have not seen an issue reported.

Pull Request Type

it affects iOS

In-depth Description

Problem:
When downloading large library items with many files (90+ audio files), the iOS app would attempt to download all files simultaneously. This caused:

  • Excessive memory usage and CPU load
  • Device overheating
  • App crashes within minutes
  • Poor user experience for large downloads

Solution:
Implemented a download queue system with concurrent download limiting:

  • Downloads are now queued in a pendingDownloadTasks array
  • A maximum of 3 downloads run concurrently (maxConcurrentDownloads = 3)
  • Thread-safe queue management using NSLock (downloadQueueLock)
  • Active downloads are tracked in an activeDownloadTasks set
  • When a download completes, the next queued download automatically starts

How have you tested this?

  1. Large Audiobook Test:

    • Downloaded a 1GB audiobook with 70+ audio files
    • Monitored download progress in console logs showing "X active, Y pending" status
    • Verified phone remained cool throughout the download
    • Confirmed app remained stable with no crashes
  2. Concurrent Download Verification:

    • Observed logs showing max 3 downloads active at any time
    • Confirmed downloads queued properly and started automatically as others completed
  3. Smaller Downloads:

    • Tested with smaller items (3-5 files) to ensure no regression
    • Verified downloads still complete successfully
  4. Edge Cases:

    • Single file downloads work as expected
    • Podcast episode downloads function correctly
    • Cover and ebook file downloads queue properly

Screenshots


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf-app/pull/1749 **Author:** [@danyhoron](https://github.com/danyhoron) **Created:** 12/10/2025 **Status:** ✅ Merged **Merged:** 2/10/2026 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`68afba4`](https://github.com/advplyr/audiobookshelf-app/commit/68afba45bc4f519b7b6828d6324ccdd07e53cf55) feat: implement download queue on iOS - [`9d5cbd3`](https://github.com/advplyr/audiobookshelf-app/commit/9d5cbd37c80c596e64d2b1be90ead18c6fc89d93) Merge branch 'advplyr:master' into master ### 📊 Changes **1 file changed** (+99 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `ios/App/App/plugins/AbsDownloader.swift` (+99 -33) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary I tried to download a 3GB (90+ files) on my iPhone, and the phone started to get hot and after a few minutes the app crashed. I implemented a download queue, to only get 3 files at a time, and not all of the files in the list. <!-- Please provide a brief summary of what your PR attempts to achieve. --> ## Which issue is fixed? <!-- Which issue number does this PR fix? Ex: "Fixes #1234" --> I have not seen an issue reported. ## Pull Request Type it affects iOS <!-- Does this affect only Android, only iOS, or both? Does this change the frontend or the backend of the apps? --> ## In-depth Description **Problem:** When downloading large library items with many files (90+ audio files), the iOS app would attempt to download all files simultaneously. This caused: - Excessive memory usage and CPU load - Device overheating - App crashes within minutes - Poor user experience for large downloads **Solution:** Implemented a download queue system with concurrent download limiting: - Downloads are now queued in a `pendingDownloadTasks` array - A maximum of 3 downloads run concurrently (`maxConcurrentDownloads = 3`) - Thread-safe queue management using `NSLock` (`downloadQueueLock`) - Active downloads are tracked in an `activeDownloadTasks` set - When a download completes, the next queued download automatically starts <!-- Describe your solution in more depth. How does it work? Why is this the best solution? Does it solve a problem that affects multiple users or is this an edge case for your setup? --> ## How have you tested this? 1. **Large Audiobook Test:** - Downloaded a 1GB audiobook with 70+ audio files - Monitored download progress in console logs showing "X active, Y pending" status - Verified phone remained cool throughout the download - Confirmed app remained stable with no crashes 2. **Concurrent Download Verification:** - Observed logs showing max 3 downloads active at any time - Confirmed downloads queued properly and started automatically as others completed 3. **Smaller Downloads:** - Tested with smaller items (3-5 files) to ensure no regression - Verified downloads still complete successfully 4. **Edge Cases:** - Single file downloads work as expected - Podcast episode downloads function correctly - Cover and ebook file downloads queue properly <!-- Please describe in detail with reproducible steps how you tested your changes. --> ## Screenshots <!-- If your PR includes any changes to the front-end, please include screenshots or a short video from before and after your changes. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:00:34 +02:00
adam closed this issue 2026-04-25 00:00:34 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#1679