Fix/shuffle queue anchored algorithm#1036
Merged
theovilardo merged 3 commits intomasterfrom Feb 11, 2026
Merged
Conversation
This commit introduces a suspendable shuffle implementation to prevent UI freezes when shuffling very large music queues (e.g., 10,000+ songs). The work is offloaded to the `Default` dispatcher to keep the main thread responsive.
- **Coroutine-based Shuffle:**
- Adds `QueueUtils.buildAnchoredShuffleQueueSuspending`, a new cooperative shuffling function that `yield()`s periodically during its operation. This prevents blocking the calling coroutine for too long.
- Moves heavy shuffle computations in `PlayerViewModel` and `PlaybackStateHolder` to a background thread using `withContext(Dispatchers.Default)`.
- **Shuffle Logic Refinements:**
- Adjusts the logic in `PlaybackStateHolder` to correctly identify the currently playing song's ID and index to anchor it properly during shuffling.
- Ensures that playback is resumed if it was active before the shuffle operation, as replacing the queue can sometimes pause the player.
- Lowers the `SHUFFLE_YIELD_BATCH` size for more frequent yielding, improving cooperativeness.
- **Testing:**
- Adds `QueueUtilsTest` to validate the new suspendable shuffle logic, ensuring it handles large lists without losing items and yields correctly to allow sibling coroutines to run.
- Adds new testing dependencies (`JUnit 5`, `MockK`, `Turbine`, `Truth`) to the Gradle configuration and enables `useJUnitPlatform()` for unit tests.
- Comments out existing, outdated test files (`MusicDaoTest`, `MusicRepositoryImplTest`, `PlayerViewModelTest`) that are being replaced by the new testing infrastructure.
- Remove deprecated implementation plans for Beta 5.1 and 5.2. - Delete local optimization reports and performance analysis documents. - Remove architectural analysis of `PlayerViewModel`. - Delete detailed scan logic implementation and verification guides.
- **UI Components**:
- Replace `AbsoluteSmoothCornerShape` with standard `RoundedCornerShape` in `EnhancedSongListItem` and `QueueBottomSheet` for item and album containers.
- Comment out legacy smooth corner shape implementations.
- Temporarily disable explicit shape application on the queue surface.
- **Interaction**:
- Update `SwipeToDismissBoxState` positional threshold from 0.28f to 0.18f in the queue list for more sensitive dismissal triggers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.