Skip to content

Optim/optimize resource consumption#1037

Merged
theovilardo merged 2 commits intomasterfrom
optim/optimize-resource-consumption
Feb 11, 2026
Merged

Optim/optimize resource consumption#1037
theovilardo merged 2 commits intomasterfrom
optim/optimize-resource-consumption

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

No description provided.

- **Memory & Resource Management**:
    - Implement bounded caches for `AiPlaylistGenerator`, and `LyricsRepositoryImpl` using `LinkedHashMap` to prevent unbounded growth and potential memory leaks.
    - Explicitly nullify callbacks and providers in `AiStateHolder`'s `onCleared` method to break reference cycles.
    - Add a comprehensive `onCleared` method to `CastTransferStateHolder` to cancel jobs, unregister listeners, and nullify callbacks, preventing memory leaks.
    - Resolve a duplicate call to `listeningStatsTracker.onCleared()` and add a missing `castTransferStateHolder.onCleared()` in `PlayerViewModel`.
    - Ensure `DualPlayerEngine` removes its listener and abandons audio focus upon release.
    - Manage the `refreshRoutesJob` in `CastStateHolder` by canceling any existing job before starting a new one and on clear.

- **Performance & Bug Fixes**:
    - **Music Repository**: Optimize `getSongsByIds` by directly querying the DAO with a list of IDs instead of loading all songs into memory for filtering. This significantly improves performance for large libraries.
    - **Artist Image Prefetch**: Simplify the artist image prefetch logic by removing an unnecessary, manually-created coroutine scope.
    - **Widget Updates**: Refactor `WidgetUpdateReceiver` to use `goAsync()` and a dedicated coroutine scope, ensuring long-running update operations don't get terminated by the system.
    - **Sleep Timer**: Remove a redundant `delay`-based coroutine meant to clear UI state, as this is now handled more reliably by the `AlarmManager` broadcast.

- **Code Cleanup**:
    - Simplify log messages in `LogUtils.kt` by removing method and line number details, making them cleaner.
- **Performance**:
    - Add explicit `key` to `LazyColumn` and `LazyRow` items across multiple screens (`LibraryScreen`, `ArtistDetailScreen`, `QuickFillScreen`, `FetchLyricsDialog`, `ChangelogBottomSheet`) to improve list stability and recomposition performance.
    - Implement `derivedStateOf` for `collapseFraction` in `ArtistDetailScreen` to minimize unnecessary recompositions during scroll.
    - Optimized `AsyncImage` in `ArtistDetailScreen` by setting a fixed request size instead of `Size.ORIGINAL`.

- **UI/UX**:
    - Add horizontal padding to the navigation icon in `QuickFillScreen` for better alignment.
    - Clean up redundant `derivedStateOf` usage and unused imports.
@theovilardo theovilardo merged commit 982858e 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