chore(flutter): drop success-path diagnostic prints

Cleanup pass on the noisy debugPrints we added during the recent
debugging sessions. Remaining prints are error-path only:
- AlbumCoverCache fetch failed
- album/playlist cold-cache fetch failed
- audio_handler playbackEventStream error
- audio_handler queue supersession (rare race)
- audio_handler forward/backward fill failed
- artist_detail play failed
- cacheFirst fetchAndPopulate failed (only when tag is set)

Removed per-event chatter:
- audio_handler player-state and processingState subscribers
- audio_handler timing measurements (built initial / setAudioSources
  / forward fill / backward fill)
- audio_handler cache hit/miss per-track (fired N times per play)
- audio_handler register stream cache (verifiable via Settings)
- audio_handler.configure log
- albumProvider step-by-step lines (drift miss / online / drift hit /
  album hit but no tracks)
- playlistDetailProvider step-by-step lines (calling get / drift
  write done / 404 evicted / drift hit / playlist hit but no tracks)
- playlistsListProvider wire returned + drift rows lines
- playTracks stage timings (serverUrl / token / configure / setQueue
  / play returned)
- metadataPrefetcher warming N artists
- artist_detail play tapped — N tracks success log
- cacheFirst step-by-step (drift hit / drift miss / online / done)

`tag` parameter on cacheFirst preserved for ad-hoc instrumentation.
This commit is contained in:
2026-05-11 23:16:42 -04:00
parent ab62a3d118
commit e856172d60
7 changed files with 10 additions and 109 deletions
+2 -43
View File
@@ -33,15 +33,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
// the index and the eviction loop can't reclaim them.
_player.bufferedPositionStream
.listen((_) => unawaited(_maybeRegisterStreamCache()));
// Diagnostic: log every player-state transition so silent stops
// surface as something we can read in the log.
_player.playerStateStream.listen((s) {
debugPrint(
'audio_handler: state playing=${s.playing} processing=${s.processingState}');
});
_player.processingStateStream.listen((ps) {
debugPrint('audio_handler: processingState=$ps');
});
}
final AudioPlayer _player = AudioPlayer();
@@ -100,10 +91,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
_token = token;
if (coverCache != null) _coverCache = coverCache;
if (audioCacheManager != null) _audioCacheManager = audioCacheManager;
debugPrint('audio_handler.configure: baseUrl="$baseUrl" '
'tokenPresent=${token != null && token.isNotEmpty} '
'coverCachePresent=${_coverCache != null} '
'audioCachePresent=${_audioCacheManager != null}');
}
Future<void> setQueueFromTracks(List<TrackRef> tracks, {int initialIndex = 0}) async {
@@ -127,10 +114,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
queue.add(items);
mediaItem.add(items[clampedInitial]);
debugPrint('audio_handler.setQueueFromTracks: '
'_baseUrl="$_baseUrl" trackCount=${tracks.length} gen=$myGen');
final sw = Stopwatch()..start();
// Fast path: build only the initial source so the player can
// start. Remaining sources stream in via _fillRemainingSources()
// in the background — addAudioSource for next/auto-advance
@@ -140,13 +123,8 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
debugPrint('audio_handler: superseded before setAudioSources (gen=$myGen)');
return;
}
debugPrint('audio_handler: built initial source in '
'${sw.elapsedMilliseconds}ms');
sw.reset();
sw.start();
await _player.setAudioSources([initial], initialIndex: 0);
debugPrint('audio_handler: setAudioSources(1) ${sw.elapsedMilliseconds}ms');
unawaited(_loadArtForCurrentItem());
unawaited(_fillRemainingSources(tracks, clampedInitial, myGen));
@@ -166,12 +144,8 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
/// addAudioSource calls from this stale fill.
Future<void> _fillRemainingSources(
List<TrackRef> tracks, int initialIndex, int gen) async {
final sw = Stopwatch()..start();
for (var i = initialIndex + 1; i < tracks.length; i++) {
if (gen != _queueGeneration) {
debugPrint('audio_handler: forward fill aborted (gen=$gen, current=$_queueGeneration)');
return;
}
if (gen != _queueGeneration) return;
try {
final src = await _buildAudioSource(tracks[i]);
if (gen != _queueGeneration) return;
@@ -180,18 +154,11 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
debugPrint('audio_handler: forward fill failed for ${tracks[i].id}: $e');
}
}
debugPrint('audio_handler: forward fill (${tracks.length - initialIndex - 1}) '
'${sw.elapsedMilliseconds}ms');
if (initialIndex > 0) {
sw.reset();
sw.start();
_suppressIndexUpdates = true;
try {
for (var i = 0; i < initialIndex; i++) {
if (gen != _queueGeneration) {
debugPrint('audio_handler: backward fill aborted (gen=$gen, current=$_queueGeneration)');
return;
}
if (gen != _queueGeneration) return;
final src = await _buildAudioSource(tracks[i]);
if (gen != _queueGeneration) return;
await _player.insertAudioSource(i, src);
@@ -203,8 +170,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
// newer setQueueFromTracks already reset it for itself.
if (gen == _queueGeneration) _suppressIndexUpdates = false;
}
debugPrint('audio_handler: backward fill ($initialIndex) '
'${sw.elapsedMilliseconds}ms');
}
}
@@ -234,7 +199,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
if (mgr != null) {
final path = await mgr.pathFor(t.id);
if (path != null) {
debugPrint('audio_handler: cache hit for track.id=${t.id} → file://$path');
return AudioSource.uri(Uri.file(path));
}
}
@@ -260,15 +224,12 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
if (mgr != null) {
_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
return LockCachingAudioSource(parsed,
headers: headers, cacheFile: cacheFile);
}
// 3. No manager configured: plain network source (legacy path).
debugPrint('audio_handler: no cache manager; track.id=${t.id} → "$url"');
return AudioSource.uri(parsed, headers: headers);
}
@@ -344,8 +305,6 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
_streamCacheRegistered.add(trackId);
await mgr.registerStreamCache(trackId, path, size);
debugPrint(
'audio_handler: registered stream cache for $trackId ($size bytes)');
}
void _onCurrentIndexChanged(int? idx) {
@@ -1,5 +1,4 @@
import 'package:audio_service/audio_service.dart';
import 'package:flutter/foundation.dart' show debugPrint;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../api/endpoints/radio.dart';
@@ -54,22 +53,8 @@ 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)
@@ -79,11 +64,8 @@ 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 {