Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

New Features:

  • N/A

Improvements:

  • Thread lifecycle management for CDN downloads: Track spawned download threads via Arc<Mutex<Vec<JoinHandle<()>>>> in StreamedFile. Prevents unbounded thread accumulation and ensures graceful cleanup on drop.
    • Periodic cleanup of finished threads before spawning new ones
    • Drop implementation waits for all downloads to complete with debug logging
    • Removes untracked thread spawning (TODO at line 252)

Bug Fixes:

  • N/A

Next Steps:

  • Consider adding configurable thread pool with concurrency limits for download operations

    ~ ⋖,^><

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Work on TODO: We spawn threads here without any accounting. Seems wrong. (from psst-core/src/player/file.rs)

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: isaaclins <104733575+isaaclins@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix thread accounting in player file handling Add thread accounting for CDN download workers Nov 12, 2025
Copilot AI requested a review from isaaclins November 12, 2025 15:21
@isaaclins
Copy link
Owner

@copilot Explain on a High level what exactly happens with this change in a way that a non-developer would understand.

Copy link
Author

Copilot AI commented Nov 12, 2025

@copilot Explain on a High level what exactly happens with this change in a way that a non-developer would understand.

Think of it like a restaurant kitchen managing delivery drivers:

Before this change:
When the app needed to download parts of a song from Spotify's servers, it would send out "delivery drivers" (background workers) to fetch the data. However, the kitchen manager wasn't keeping track of which drivers were out, which had returned, or how many were working at once. Drivers would just disappear after completing their job.

After this change:
Now the kitchen manager keeps a list of all active drivers. When a driver finishes their delivery, they're removed from the list. When the restaurant closes (the song file is no longer needed), the manager waits for all drivers to return home before shutting down completely.

Why this matters:

  • Prevents the app from creating too many workers and wasting system resources
  • Ensures proper cleanup when switching songs or closing the app
  • Provides visibility into what's happening (the manager knows how many drivers are out)
  • No more "ghost workers" that stick around after they're no longer needed

Copy link
Owner

@isaaclins isaaclins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested e2e and approve.

@isaaclins isaaclins marked this pull request as ready for review November 12, 2025 19:55
@isaaclins isaaclins merged commit ff92fe7 into dev Nov 12, 2025
1 check passed
@isaaclins isaaclins deleted the copilot/fix-thread-accounting-issue branch November 12, 2025 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants