diag(flutter): instrument playTracks + cache appdir; fix CI
CI fixes: - artist_detail_screen.dart: drop unnecessary foundation import (debugPrint comes from material) and unused metadata_prefetcher import. Playback timing visibility (so we can stop guessing where the lag lives): - playTracks now logs serverUrl / token / configure / setQueue / play() returned, each stage in milliseconds. The next time you tap play, we'll see exactly where the seconds go. - setQueueFromTracks adds two more measurements: total source-build time across all tracks, and setAudioSources duration. Small concrete win: - audio_handler caches the application cache dir path on first use (already cached in _maybeRegisterStreamCache; now also used in _buildAudioSource for the LockCachingAudioSource path). One less platform channel hit per track on cache-miss queue builds. Once we see real numbers we can decide whether the fix is to build sources lazily (initial source first → play → background-add the rest), pre-warm the audio handler at app start so playTracks skips serverUrl + token reads entirely, or something else.
This commit is contained in:
@@ -53,8 +53,22 @@ class PlayerActions {
|
||||
final Ref _ref;
|
||||
|
||||
Future<void> playTracks(List<TrackRef> tracks, {int initialIndex = 0}) async {
|
||||
// Stage-by-stage timing so we can see exactly where the
|
||||
// "tap → audio" delay lives. Look for "playTracks: ..." lines
|
||||
// in the next log capture; each stage label is followed by its
|
||||
// elapsed millis since the previous stage.
|
||||
final sw = Stopwatch()..start();
|
||||
int lap() {
|
||||
final ms = sw.elapsedMilliseconds;
|
||||
sw.reset();
|
||||
sw.start();
|
||||
return ms;
|
||||
}
|
||||
|
||||
final url = await _ref.read(serverUrlProvider.future);
|
||||
debugPrint('playTracks: serverUrl ${lap()}ms');
|
||||
final token = await _ref.read(secureStorageProvider).read(key: 'session_token');
|
||||
debugPrint('playTracks: token ${lap()}ms');
|
||||
final cache = _ref.read(albumCoverCacheProvider);
|
||||
final audioCache = _ref.read(audioCacheManagerProvider);
|
||||
final h = _ref.read(audioHandlerProvider)
|
||||
@@ -64,8 +78,11 @@ class PlayerActions {
|
||||
coverCache: cache,
|
||||
audioCacheManager: audioCache,
|
||||
);
|
||||
debugPrint('playTracks: configure ${lap()}ms');
|
||||
await h.setQueueFromTracks(tracks, initialIndex: initialIndex);
|
||||
debugPrint('playTracks: setQueue (${tracks.length} tracks) ${lap()}ms');
|
||||
await h.play();
|
||||
debugPrint('playTracks: play() returned ${lap()}ms');
|
||||
}
|
||||
|
||||
Future<void> playNext(TrackRef track) async {
|
||||
|
||||
Reference in New Issue
Block a user