Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add alpha debug logs to verify recent fixes

Barnabas72bfc435b22b
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index d0fe2b8e..259337e9 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -113,6 +113,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
/// Subscribe to the active screen's barsVisibleNotifier when on Home or
/// Library tab, and ensure the nav bar is visible on all other tabs.
void _syncNavBarListener(int index) {
+ debugPrint('[NavBar] _syncNavBarListener(index=$index) ctrl=${_navBarAnimController.value.toStringAsFixed(2)}');
_detachNavBarListener();
ValueNotifier<bool>? notifier;
if (index == 0) {
@@ -131,11 +132,13 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
};
notifier.addListener(_navBarListener!);
_navBarListener!();
+ debugPrint('[NavBar] Attached listener to tab=$index notifier.value=${notifier.value} ctrl=${_navBarAnimController.value.toStringAsFixed(2)}');
} else {
// Not a scroll-hide tab - force nav bar visible immediately.
// Use .value to snap instead of animate, avoiding races where
// the controller gets stuck mid-animation.
_navBarAnimController.value = 1.0;
+ debugPrint('[NavBar] Snap to 1.0 for non-scroll tab=$index');
}
}
diff --git a/lib/screens/library_screen.dart b/lib/screens/library_screen.dart
index 2073e0c6..dd5d9a95 100644
--- a/lib/screens/library_screen.dart
+++ b/lib/screens/library_screen.dart
@@ -594,6 +594,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
// Client-side filters (e.g. hide-ebook-only) reduce _items below total,
// which would leave _hasMore permanently true and the loader spinning.
_hasMore = results.length >= _pageSize;
+ debugPrint('[LibPage] page=${_page - 1} results=${results.length} pageSize=$_pageSize filtered=${_items.length} total=$total hideEbook=$_hideEbookOnly hasMore=$_hasMore');
_isLoadingPage = false;
});
} else if (mounted && gen == _loadGeneration) {
diff --git a/lib/services/sleep_timer_service.dart b/lib/services/sleep_timer_service.dart
index 76e52caa..1c2718e1 100644
--- a/lib/services/sleep_timer_service.dart
+++ b/lib/services/sleep_timer_service.dart
@@ -480,6 +480,8 @@ class SleepTimerService extends ChangeNotifier {
}
void _onSettingsUpdated() {
+ final s = _autoSleepSettings;
+ debugPrint('[SleepTimer] _onSettingsUpdated enabled=${s?.enabled} window=${s?.startLabel}-${s?.endLabel} mode=${s?.useEndOfChapter == true ? "chapter" : "${s?.durationMinutes}m"} autoStarted=$_autoStarted isActive=$isActive');
// Cancel stale boundary timer — it was for the old window
_windowBoundaryTimer?.cancel();
_windowBoundaryTimer = null;
@@ -517,9 +519,13 @@ class SleepTimerService extends ChangeNotifier {
Future<void> checkAutoSleep() async {
if (_autoSleepSettings == null) await loadAutoSleepSettings();
final settings = _autoSleepSettings;
- if (settings == null || !settings.enabled) return;
+ if (settings == null || !settings.enabled) {
+ debugPrint('[SleepTimer] checkAutoSleep: disabled or no settings');
+ return;
+ }
final inWindow = settings.isInWindow();
+ debugPrint('[SleepTimer] checkAutoSleep: inWindow=$inWindow isActive=$isActive dismissed=$_autoSleepDismissed autoStarted=$_autoStarted');
// If we just left the window, reset the dismiss flag for next entry
if (!inWindow && _wasInWindow) {
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index bab6a57c..d4992061 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -92,6 +92,8 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
}
Future<void> _loadItem() async {
+ debugPrint('[BookDetail] _loadItem start item=${widget.itemId}');
+ final loadStart = DateTime.now();
// Force re-derivation of cover scheme on reload (cover may have changed).
_coverSchemeUrl = null;
final auth = context.read<AuthProvider>();
@@ -102,6 +104,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
if (api != null && !lib.isOffline) {
try {
final item = await api.getLibraryItem(widget.itemId);
+ debugPrint('[BookDetail] server fetch done in ${DateTime.now().difference(loadStart).inMilliseconds}ms (item=${item != null ? "ok" : "null"})');
if (item != null && mounted) {
// Apply local metadata overrides
final overrideService = MetadataOverrideService();
@@ -201,9 +204,15 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
void _deriveCoverScheme() {
final url = _coverUrl;
- if (url == null) return;
+ if (url == null) {
+ debugPrint('[BookDetail] _deriveCoverScheme skipped (no cover url)');
+ return;
+ }
// Skip if the scheme was already derived from this exact URL.
- if (url == _coverSchemeUrl) return;
+ if (url == _coverSchemeUrl) {
+ debugPrint('[BookDetail] _deriveCoverScheme skipped (cached for this url)');
+ return;
+ }
_coverSchemeUrl = url;
final brightness = Theme.of(context).brightness;
final ImageProvider provider;
@@ -213,15 +222,19 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
final lib = context.read<LibraryProvider>();
provider = CachedNetworkImageProvider(url, headers: lib.mediaHeaders);
}
+ final t0 = DateTime.now();
+ debugPrint('[BookDetail] _deriveCoverScheme start url=$url');
PaletteGenerator.fromImageProvider(provider, maximumColorCount: 16)
.then((palette) {
+ debugPrint('[BookDetail] PaletteGenerator ok in ${DateTime.now().difference(t0).inMilliseconds}ms');
final seedColor = palette.vibrantColor?.color
?? palette.dominantColor?.color
?? palette.colors.firstOrNull;
if (seedColor == null || !mounted) return;
setState(() => _coverScheme = ColorScheme.fromSeed(
seedColor: seedColor, brightness: brightness));
- }).catchError((_) {
+ }).catchError((e) {
+ debugPrint('[BookDetail] PaletteGenerator error after ${DateTime.now().difference(t0).inMilliseconds}ms: $e');
if (!mounted) return;
setState(() {
_coverSchemeUrl = null;
diff --git a/lib/widgets/episode_detail_sheet.dart b/lib/widgets/episode_detail_sheet.dart
index cf4a1f5b..58294671 100644
--- a/lib/widgets/episode_detail_sheet.dart
+++ b/lib/widgets/episode_detail_sheet.dart
@@ -95,14 +95,18 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
// collapsed after tab transition races with sheet pop animations.
final rootNav = Navigator.of(context, rootNavigator: true);
final rootContext = rootNav.context;
+ debugPrint('[PodcastPlay] Popping stacked sheets before playItem (item=$_itemId episode=$_episodeId)');
rootNav.popUntil((route) => route.isFirst);
+ debugPrint('[PodcastPlay] Sheets popped, calling playItem');
+ final t0 = DateTime.now();
final error = await AudioPlayerService().playItem(
api: api, itemId: _itemId, title: _episodeTitle, author: _showTitle,
coverUrl: api.getCoverUrl(_itemId), totalDuration: _duration, chapters: _chapters,
episodeId: _episodeId,
episodeTitle: _episodeTitle,
);
+ debugPrint('[PodcastPlay] playItem returned in ${DateTime.now().difference(t0).inMilliseconds}ms (error=${error ?? 'none'})');
if (error != null && rootContext.mounted) {
showErrorSnackBar(rootContext, error);
}