Skip to content

Fix/queue issues#1033

Merged
theovilardo merged 4 commits intomasterfrom
fix/queue-issues
Feb 11, 2026
Merged

Fix/queue issues#1033
theovilardo merged 4 commits intomasterfrom
fix/queue-issues

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

No description provided.

… loading

- **Favorites & Paging**:
    - Implements Room-level pagination for "Liked Songs" using `PagingSource` to handle large libraries efficiently.
    - Moves favorite songs sorting and filtering to the database level, replacing in-memory transformations.
    - Adds `getFavoriteSongCountFlow` and `getPaginatedFavoriteSongs` to `MusicRepository`.

- **Performance & Memory**:
    - Adds `SEARCH_RESULTS_LIMIT` to search queries to prevent memory issues with large result sets.
    - Updates `PlayerViewModel` to load songs for daily mixes, random playback, and shuffle on-demand from the DB instead of maintaining permanent in-memory subscriptions to the entire library.
    - Replaces `allSongs.find` scans with direct Room queries via `observeSong(id)`.

- **Data Consistency**:
    - Synchronizes favorite status between Room database and `DataStore` preferences.
    - Refactors favorite toggling logic into a unified `setFavoriteStatusEverywhere` method to ensure consistency across the UI and notification service.

- **UI & ViewModels**:
    - Updates `LibraryScreen` and `LibraryFavoritesTab` to use `LazyPagingItems` for the Liked Songs tab.
    - Polishes UI components in `LibraryScreen` with better scrollbar padding and transition handling.
    - Refines folder navigation and multi-selection logic for better responsiveness.
- **Performance & Animations**:
    - Implement a "drag pipeline" with frame-paced updates using `withFrameNanos` and `MonotonicFrameClock` to coalesce high-frequency drag deltas.
    - Transition from `IntOffset` to `graphicsLayer { translationY = ... }` for sheet movement to avoid frequent recompositions and layout passes.
    - Refine expansion/collapse animation durations and easing based on travel fraction for smoother tactile feedback.
    - Reduce full-player rescaling depth from `0.95f` to `0.972f` to minimize layout pressure.

- **Queue Bottom Sheet**:
    - Refactor `QueueBottomSheet` to use direct queue indexing instead of a paginated `QueueUiItem` wrapper, significantly reducing memory overhead on large queues.
    - Optimize song list rendering by using `subList` and `RandomAccess` to avoid unnecessary list copying.
    - Implement a local `reorderPreviewOrder` state to handle drag-and-drop reordering smoothly without immediate source-of-truth updates.
    - Replace custom `swipeable` implementation with Material 3 `SwipeToDismissBox` for song removal.
    - Improve auto-scroll behavior to jump (instead of animate) to the current song for large index gaps.

- **State Management**:
    - Move `castSheetOpenFraction` and `queueVisualOpenFraction` to `animateFloatAsState` within dedicated state holders to decouple UI animations from parent recomposition loops.
    - Simplify `SheetOverlayState` logic for calculating visibility and expansion fractions.
```
perf: optimize queue management for large collections and refine UI reordering

- **Performance & Scalability**:
    - Implement `QueueUtils.buildAnchoredShuffleQueueSuspending` to prevent UI freezes (ANRs) when shuffling large queues (10,000+ songs) by yielding to the dispatcher.
    - Introduce `BULK_REPLACE_THRESHOLD` in `PlaybackStateHolder` to switch from individual `moveMediaItem` IPC calls to a single `setMediaItems` call for large queues.
    - Standardize shuffle logic across `QueueStateHolder` to use Fisher-Yates via `QueueUtils` for better randomness.

- **Queue UI Refinements**:
    - Implement stable key tracking in `QueueBottomSheet` to prevent row state recycling glitches and "snapping" during reorders.
    - Add a "grace update" mechanism to keep local reorder previews active until upstream data propagation is confirmed.
    - Improve reordering animations using `Modifier.animateItem` with tuned spring specs.
    - Revamp "Swipe to Dismiss" in the queue with a custom reveal background, haptic feedback triggers for activation thresholds, and better state synchronization.
- **Queue Management**:
    - Update `playerViewModel` calls to use `showAndPlaySong` for unified behavior when triggering playback from overlays and the queue.
    - Optimize `remapCommittedKeysForDisplay` in `QueueBottomSheet` with a fast-path for common queue-skip scenarios (suffix matching) to maintain stable keys.
    - Refine `displaySongsSignature` calculation to include `queueIndexOffset` and use identity hashing for more accurate state tracking.

- **UI & Animations**:
    - Distinguish between reordering and general list updates in `QueueBottomSheet` to apply context-aware animations.
    - Use `spring` specs during active reordering for responsiveness and `tween` specs for standard list changes (fade in/out) to improve visual smoothness.
    - Defer expensive ID mapping in `LaunchedEffect` to avoid unnecessary computations during rapid queue updates.
@theovilardo theovilardo merged commit 1a7b087 into master Feb 11, 2026
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.

1 participant