Skip to content

Improve cold start performance#978

Open
skalthoff wants to merge 9 commits intomainfrom
improve-cold-start-performance
Open

Improve cold start performance#978
skalthoff wants to merge 9 commits intomainfrom
improve-cold-start-performance

Conversation

@skalthoff
Copy link
Collaborator

What is the change

  • Switch React Query persister from AsyncStorage to sync MMKV
  • Defer StorageProvider queries and player queue restoration
  • Add skeleton loading UI for home sections

What does this address

Cold start times on servers with large or slow libraries. Cached data now loads synchronously, non-critical queries are deferred, and users see loading skeletons instead of blank screens.

Issue number / link

N/A

Tag reviewers

@anultravioletaurora

- replace AsyncStorage persister with sync MMKV persister for instant cache restoration
- add refetchOnMount: false to recents queries to use cached data on startup
- delay StorageProvider queries until 2s after initial render
- defer player queue restoration with InteractionManager
- add enabled option to download query hooks
- create HomeSectionSkeleton component with animated shimmer
- show skeletons while home data is loading
- add @tanstack/query-sync-storage-persister
- update bundler to 4.0.5
skalthoff and others added 4 commits February 5, 2026 01:10
Keep the query client persister using AsyncStorage to maintain
the existing memory optimization. The sync storage change can
be evaluated separately.
* add letter filter parameters to API fetch functions

Add NameStartsWithOrGreater and NameLessThan parameters to:
- fetchArtists
- fetchAlbums
- fetchTracks

These parameters enable direct letter-based filtering without
fetching all preceding items.

* add flattenWithLetterHeaders utility function

Export helper function for merging bidirectional query data
with letter section headers.

* add letter-anchored hooks for bidirectional navigation

Implement useLetterAnchoredArtists, useLetterAnchoredAlbums,
and useLetterAnchoredTracks hooks that use dual infinite queries:
- Forward query with NameStartsWithOrGreater for items from anchor
- Backward query with NameLessThan for items before anchor

This enables instant letter jumping without paginating through
all preceding items.

* add library cache validation hook

Implement useLibraryCacheValidation hook that validates cached
data on app focus using lightweight Limit=0 count requests.
Invalidates relevant queries when library counts change.

* add letter-anchored list components

Create LetterAnchoredArtists, LetterAnchoredAlbums, and
LetterAnchoredTracks components that use the new bidirectional
hooks and support instant A-Z navigation with smooth scrolling
in both directions.

* update library tabs to use letter-anchored components

Switch ArtistsTab, AlbumsTab, and TracksTab to use the new
letter-anchored components for instant A-Z navigation.

* remove unnecessary memoization

React Compiler handles memoization automatically, so useMemo
and useCallback are not needed in the letter-anchored hooks.

* improve AZ scroller letter distribution across screen sizes

* consolidate LetterFilter type, remove unused import, fix cache validation sharing

- Move duplicated LetterFilter interface to shared src/api/types/letter-filter.ts
- Remove unused flattenWithLetterHeaders import from artist/index.ts
- Use module-level state in useLibraryCacheValidation so multiple
  component instances share the same throttle/mutex
- Replace duplicated year-range building logic in shuffle.ts with
  the existing buildYearsParam utility
- Remove stable function import (triggerHaptic) from useCallback
  dependency arrays in GenreSelection
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.

3 participants