Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Remove noisy per-tick Battery debug logs, keep state-change logs

Nathan Poulson5ac22109ac65
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index 8df1a170..f3bbb1e1 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -344,7 +344,6 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
- debugPrint('[Battery] AppShell lifecycle: $state (playing=${AudioPlayerService().isPlaying})');
if (state == AppLifecycleState.resumed) {
context.read<LibraryProvider>().onAppForegrounded();
SleepTimerService().onAppForegrounded();
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index a1928bc9..86d272f7 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -82,8 +82,6 @@ class AudioPlayerHandler extends BaseAudioHandler with SeekHandler {
final elapsed = now.difference(_lastPlaybackStateUpdate);
if (playingChanged || processingChanged || elapsed.inSeconds >= 5) {
- final reason = playingChanged ? 'play/pause' : processingChanged ? 'procState=${_player.processingState}' : '5s tick';
- debugPrint('[Battery] PlaybackState pushed ($reason, pos=${_player.position.inSeconds}s)');
playbackState.add(state);
_lastPlaybackStateUpdate = now;
_lastPlaying = _player.playing;
@@ -1822,8 +1820,6 @@ class AudioPlayerService extends ChangeNotifier {
}
int _lastSyncSecond = -1;
- int _posStreamTickCount = 0;
- DateTime _lastPosStreamLog = DateTime.now();
StreamSubscription? _eqSessionSub;
@@ -1874,7 +1870,6 @@ class AudioPlayerService extends ChangeNotifier {
// listener saves every 5s; this only matters when that stream goes silent.
debugPrint('[Battery] bgSaveTimer STARTED (60s interval)');
_bgSaveTimer = Timer.periodic(const Duration(seconds: 60), (_) async {
- debugPrint('[Battery] bgSaveTimer TICK (playing=${_player?.playing}, item=$_currentItemId)');
if (_currentItemId == null || _player == null || !_player!.playing) return;
final pos = position;
final posSec = pos.inMilliseconds / 1000.0;
@@ -1904,8 +1899,6 @@ class AudioPlayerService extends ChangeNotifier {
debugPrint('[Player] processingState stream error: $e');
_attemptStreamRetry(e);
});
-
- debugPrint('[Battery] positionStream SUBSCRIBED');
_syncSub = _player?.positionStream.listen((trackRelativePos) async {
// Reset retry counter on successful position updates
_streamRetryCount = 0;
@@ -1914,15 +1907,6 @@ class AudioPlayerService extends ChangeNotifier {
final sec = absolutePos.inSeconds;
final posSec = absolutePos.inMilliseconds / 1000.0;
- // [Battery] Heartbeat: log position stream activity every 30s
- _posStreamTickCount++;
- final now = DateTime.now();
- if (now.difference(_lastPosStreamLog).inSeconds >= 30) {
- debugPrint('[Battery] positionStream heartbeat: $_posStreamTickCount ticks in ${now.difference(_lastPosStreamLog).inSeconds}s, pos=${posSec.toStringAsFixed(1)}s');
- _posStreamTickCount = 0;
- _lastPosStreamLog = now;
- }
-
// ─── Position-reset guard ────────────────────────────
// ExoPlayer can seek to 0 on STATE_ENDED. If we were near the end
// and suddenly jump to near 0 without a user seek, treat it as
@@ -2070,7 +2054,6 @@ class AudioPlayerService extends ChangeNotifier {
debugPrint('[Battery] stuckCheckTimer STARTED (10s interval)');
_stuckCheckTimer = Timer.periodic(const Duration(seconds: 10), (_) async {
- debugPrint('[Battery] stuckCheckTimer TICK (playing=${_player?.playing})');
// Only check while actively playing
if (_player == null || !_player!.playing) {
_stuckCheckLastPosition = -1;
@@ -2225,7 +2208,6 @@ class AudioPlayerService extends ChangeNotifier {
Future<void> _saveProgressLocal(Duration pos) async {
if (_currentItemId == null) return;
final ct = pos.inMilliseconds / 1000.0;
- debugPrint('[Battery] _saveProgressLocal: ${ct.toStringAsFixed(1)}s');
// Use compound key for podcast episodes
final progressKey = _currentEpisodeId != null
? '$_currentItemId-$_currentEpisodeId'
@@ -2331,7 +2313,6 @@ class AudioPlayerService extends ChangeNotifier {
debugPrint('[Battery] bgSaveTimer RESTARTED (play)');
_bgSaveTimer?.cancel();
_bgSaveTimer = Timer.periodic(const Duration(seconds: 60), (_) async {
- debugPrint('[Battery] bgSaveTimer TICK (playing=${_player?.playing}, item=$_currentItemId)');
if (_currentItemId == null || _player == null || !_player!.playing) return;
final pos = position;
final posSec = pos.inMilliseconds / 1000.0;
diff --git a/lib/services/home_widget_service.dart b/lib/services/home_widget_service.dart
index 402800ef..fe7d21b3 100644
--- a/lib/services/home_widget_service.dart
+++ b/lib/services/home_widget_service.dart
@@ -295,15 +295,12 @@ class HomeWidgetService {
void _startProgressTimer() {
if (_progressTimer?.isActive == true) return;
- debugPrint('[Battery] HomeWidget progressTimer STARTED (60s interval)');
_progressTimer = Timer.periodic(const Duration(seconds: 60), (_) {
- debugPrint('[Battery] HomeWidget progressTimer TICK');
_scheduleUpdate();
});
}
void _stopProgressTimer() {
- if (_progressTimer != null) debugPrint('[Battery] HomeWidget progressTimer STOPPED');
_progressTimer?.cancel();
_progressTimer = null;
}
diff --git a/lib/widgets/card_edge_progress_bar.dart b/lib/widgets/card_edge_progress_bar.dart
index 6f9af422..af094431 100644
--- a/lib/widgets/card_edge_progress_bar.dart
+++ b/lib/widgets/card_edge_progress_bar.dart
@@ -120,13 +120,11 @@ class _CardEdgeProgressBarState extends State<CardEdgeProgressBar>
void _syncTicker() {
final shouldRun = _isPlaying && (widget.isActive || _isCastMode) && !_backgrounded;
if (shouldRun && _smoothTicker == null) {
- debugPrint('[Battery] CardEdgeProgressBar ticker STARTED (playing=$_isPlaying, active=${widget.isActive}, bg=$_backgrounded)');
_smoothTicker = Timer.periodic(const Duration(milliseconds: 100), (_) {
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
_tickNotifier.notifyListeners();
});
} else if (!shouldRun && _smoothTicker != null) {
- debugPrint('[Battery] CardEdgeProgressBar ticker STOPPED (playing=$_isPlaying, active=${widget.isActive}, bg=$_backgrounded)');
_smoothTicker!.cancel();
_smoothTicker = null;
}
diff --git a/lib/widgets/card_progress_bar.dart b/lib/widgets/card_progress_bar.dart
index 5ab4514f..30735bd0 100644
--- a/lib/widgets/card_progress_bar.dart
+++ b/lib/widgets/card_progress_bar.dart
@@ -91,13 +91,11 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with WidgetsB
void _syncTicker() {
final shouldRun = _isPlaying && (widget.isActive || _isCastMode) && !_backgrounded;
if (shouldRun && _smoothTicker == null) {
- debugPrint('[Battery] CardDualProgressBar ticker STARTED (playing=$_isPlaying, active=${widget.isActive}, bg=$_backgrounded)');
_smoothTicker = Timer.periodic(const Duration(milliseconds: 100), (_) {
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
_tickNotifier.notifyListeners();
});
} else if (!shouldRun && _smoothTicker != null) {
- debugPrint('[Battery] CardDualProgressBar ticker STOPPED (playing=$_isPlaying, active=${widget.isActive}, bg=$_backgrounded)');
_smoothTicker!.cancel();
_smoothTicker = null;
}