perf: reduce UI jank via memoization, compute isolates, SQL-backed playlist picker, and viewport-aware image caching

- Move explore JSON decode/encode to compute() isolate to avoid blocking main thread
- Memoize search sort results (artists/albums/playlists/tracks) in HomeTab; invalidate on new query
- Extract _DownloadedOrRemoteCover StatefulWidget with proper embedded-cover lifecycle management
- Replace O(playlists x tracks) in-memory playlist picker check with SQL loadPlaylistPickerSummaries query
- Add FutureProvider.family (libraryPlaylistPickerSummariesProvider) invalidated on all playlist mutations
- Memoize _buildQueueHistoryStats, localPathMatchKeys, and localSingleItems in QueueTab
- Add coverCacheWidthForViewport util; apply memCacheWidth/cacheWidth based on real DPR across all album/playlist/track screens
- Convert sync file ops in TrackMetadataScreen to async; use mtime+size as validation token
- Fetch Deezer album nb_tracks in parallel via fetchAlbumTrackCounts
This commit is contained in:
zarzet
2026-04-03 22:31:04 +07:00
parent 1248270fb4
commit 030f44a444
13 changed files with 927 additions and 352 deletions
+12
View File
@@ -0,0 +1,12 @@
import 'package:flutter/widgets.dart';
int coverCacheWidthForViewport(
BuildContext context, {
double widthMultiplier = 1.0,
int min = 320,
int max = 2048,
}) {
final dpr = MediaQuery.devicePixelRatioOf(context);
final logicalWidth = MediaQuery.sizeOf(context).width * widthMultiplier;
return (logicalWidth * dpr).round().clamp(min, max);
}