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:
@@ -80,12 +80,18 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
|
||||
|
||||
debugPrint('audio_handler.setQueueFromTracks: '
|
||||
'_baseUrl="$_baseUrl" trackCount=${tracks.length}');
|
||||
final sw = Stopwatch()..start();
|
||||
final sources = await Future.wait(tracks.map(_buildAudioSource));
|
||||
debugPrint('audio_handler: built ${sources.length} sources in '
|
||||
'${sw.elapsedMilliseconds}ms');
|
||||
sw.reset();
|
||||
sw.start();
|
||||
|
||||
await _player.setAudioSources(
|
||||
sources,
|
||||
initialIndex: initialIndex,
|
||||
);
|
||||
debugPrint('audio_handler: setAudioSources ${sw.elapsedMilliseconds}ms');
|
||||
|
||||
// Kick the cover fetch for the initial item — async, doesn't block
|
||||
// playback. Subsequent track changes are handled by the
|
||||
@@ -143,8 +149,8 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
|
||||
// pin / Download buttons cover the index path; LockCaching handles
|
||||
// the network optimization.
|
||||
if (mgr != null) {
|
||||
final cacheDir = await getApplicationCacheDirectory();
|
||||
final cacheFile = File('${cacheDir.path}/audio_cache/${t.id}.mp3');
|
||||
_cacheDirPath ??= (await getApplicationCacheDirectory()).path;
|
||||
final cacheFile = File('${_cacheDirPath!}/audio_cache/${t.id}.mp3');
|
||||
debugPrint('audio_handler: cache miss for track.id=${t.id}, '
|
||||
'using LockCachingAudioSource → ${cacheFile.path}');
|
||||
// ignore: experimental_member_use
|
||||
|
||||
Reference in New Issue
Block a user