Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pausing book (local or streamed) randomly chooses where playback will resume (forward or backwards from actual paused point) #804

Closed
1 of 2 tasks
falchonhand opened this issue Jul 24, 2023 · 28 comments
Labels
bug Something isn't working

Comments

@falchonhand
Copy link

Steps to reproduce

  1. Run Docker v. 2.3.2 or 2.3.3
  2. Download a book to selected directory or stream
  3. Pause playback for a random interval (longer is more probable), receive a text, alert, or phone call (doesn't happen every time)
  4. Click play to resume either direct on screen or by bluetooth headset
  5. Play will resume at seemingly random time

Expected behaviour

  • Tell us what should happen
  • Have playback resume reliably in the same manner each time (whether exactly from where paused or 5-10 seconds back or whatever the programmed intended time is) without randomness

Actual behaviour

  • Tell us what happens
  • Random results occur from position pause occurred
  • Position exactly where paused (sometimes mid word)
  • Position 10 seconds back
  • Position roughly 2 minutes - 2 hours prior to pause
  • Position up to 2 minutes ahead of where paused

This issue began to occur after updating docker 2.3.2 (I think) where my entire library vanished and notice on github page instructed to delete file absdatabase. This has occurred on, a book I was in the middle of listening (local download) during both updates, a new book downloaded 4 days ago 7/20/2023, and on a book being streamed (all different books)

Environment data

Audiobookshelf Version:

  • Android App?
  • iOS App?

Android Issue

Android version: 13

Device model: Pixel 6 Pro

Stock or customized system: Stock

iOS Issue

iOS Version:

iPhone model:

@falchonhand falchonhand added the bug Something isn't working label Jul 24, 2023
@advplyr
Copy link
Owner

advplyr commented Jul 24, 2023

With downloaded books the playback position should not be affected by server updates. You can test this by going on airplane mode and playing the downloaded book. When you do that are you still getting this error of the position jumping around?

Also, are these mp3 or m4b or other audio files?

@falchonhand
Copy link
Author

falchonhand commented Jul 24, 2023

Testing Airplane mode now.
1st test, started within 10 seconds of pause point.
2nd test put me 2 minutes ahead of where I paused

I can see where there was a client server time sync issue. Before placing the phone on Airplane, I noticed the server showed I had 3h 14m remaining and the client on my phone reported 2:37 minutes remaining. Coming out of Airplane mode the client and server synced the time remaining.

Uninstalling app, removing cached files, restarting phone, re-installing / configuring app results in no change.

Added test of only streaming (not locally downloaded) and book tends to jump forward apx 30 seconds after being paused while accessing another app. ie: playing game while book playing in background, pause book, let ads roll by on other app, un-pause book and fumble back to locate where I paused the book.

All audiobooks in my collection are m4b.

@kevlp3000
Copy link

kevlp3000 commented Jul 25, 2023

When testing in Airplane mode, playback and pause worked as normal. Pause times were 5, 10 and 30 minutes. Only jumped back to the max of 30 seconds.

When I paused, went back to WiFi and resumed playback all was ok. During lunch I paused again and resumed playback 45 minutes later. I opened the app to go to history and pressed play on my ear bud. Noticed the progress bar jump back a bit. Looked at history and it was an 8 minute jump back.

I have listened off and on since then and of course no jump back.

@kevlp3000
Copy link

Screenshot_20230725_061027_audiobookshelf

The jump back happened again this morning. Was on WiFi. Had opened the app to press play.

@PyroghostX
Copy link

This same issue is happening to me. It's always jumping backwards.
When it happened just now, I paused, went to another app, when it resumed listening 5 minutes later it had went back like 8 minutes

I have the book downloaded
I just removed to book so I'll stream it, see if that helps
The book is 64 mp3 files

@PyroghostX
Copy link

Screenshot_20230726_113834_audiobookshelf

You can see a 9 min seek back at 11:01 I think

@advplyr
Copy link
Owner

advplyr commented Jul 26, 2023

It would be great if we can confirm that this is specific to downloaded books, which I think it is.

Keep in mind that there is an automatic rewind after pausing for X amount of minutes. Some of this sounds like it might be the auto-rewind feature. As of v0.9.65 this is the auto-rewind times for android:

    val time: Long = System.currentTimeMillis() - lastPauseTime
    val seekback: Long
    if (time < 10000) seekback = 0 // 10s or less = no seekback
    else if (time < 60000) seekback = 3000 // 10s to 1m = jump back 3s
    else if (time < 300000) seekback = 10000 // 1m to 5m = jump back 10s
    else if (time < 1800000) seekback = 20000 // 5m to 30m = jump back 20s
    else seekback = 29500 // 30m and up = jump back 30s
    return seekback

You can disable this in the settings, "Disable auto rewind".

@kevlp3000
Copy link

I had disabled the auto rewind after seeing the suggestion yesterday. Since then there has been 3 occasions the jump back occurred. Not sure of the 1st which was late yesterday on another book. But the 2nd and 3rd were on a new book. The 2nd time was 5 minutes jump back. This time was 11 minutes and I was able to take a screenshot. The jump back happened immediately after the Pause event.

The book is a newly downloaded book from this morning. The Pause and Play were via ear bud this time. I can provide logs if wanted but they do not have any errors or show the jump back that I can see.
Screenshot_20230727_093759_audiobookshelf

@PyroghostX
Copy link

PyroghostX commented Jul 27, 2023 via email

@falchonhand
Copy link
Author

I've experienced it with the auto rewind disabled with a downloaded book. I've removed the book and listened to it streaming for 20 hours of the same book and it's not jumped back since moving to streaming.

@Jerk-Solutions
Copy link

I noticed this behavior doesn't happen when I pause from the application. But when I use the lock screen or notification bar to pause the audiobook, it skips back

@falchonhand
Copy link
Author

I generally control my books by bluetooth headset. Not sure if this happens with both or not

@falchonhand
Copy link
Author

I noticed a possible point of issue.
While investigating a different streaming issue for ios, I had the log open from inside ABS and was monitoring. I was using my android device, hit play on my bluetooth headset and it started playback of the current book via stream. The log didn't change (refreshed page, no change). I unlocked my phone and once the app came to the foreground, then, the log acknowledged my playback with "received ping". I then paused again (bluetooth) and closed the player. Reopened player, clicked play from screen, the log provided errors (listed below) but played back, 10 seconds ahead of where I last paused.

2023-07-31 09:53:25 ERROR Api called without a token /items/31f5c29b-4cb9-4f23-aa4a-e07eaf317cdb/play
2023-07-31 09:53:26 ERROR Api called without a token /session/6e29ba13-3fe5-403b-bc88-26ef4ffca9b7/close
2023-07-31 09:53:36 ERROR Api called without a token /session/0bbf273c-42ca-4cf9-aaa3-032d6de13bc1/sync

may be related

@Jerk-Solutions
Copy link

Another likely cause could be that Android Mediaplayer's getcurrentposition API has a known issue where it returns incorrect values

https://issuetracker.google.com/issues/36907697

@souam666
Copy link

I have been having issues as well with proper playback save. if I pause playback by either using the lock screen pause button on my android phone or by turning off my headphones and do not actually go on the app, it seams that for file downloaded locally once I go back on the title, it will start from the last known point on the server and sometime lose a whole listening session. I am going to try and replicate the issue.

@Jerk-Solutions
Copy link

I tried a few more things.

  • Auto scroll back is turned off and doesn't change anything
  • Uninstalling app, removing cached files, restarting phone, re-installing / configuring app results in no change.
  • local books downloaded from the server have the issue. Streaming from the server didn't seem to trigger it
  • pausing from notification bar, lock screen, Bluetooth headphones all trigger the behavior
  • pausing from inside the app doesn't seem to trigger the issue.
  • is not book specific

@toxic0berliner
Copy link

toxic0berliner commented Aug 2, 2023

I have what I believe is the same issue with downloaded books.
My feeling is that some reading sessions get dropped somehow. Last time it happened to me I started listening during my jogging so it was easy to confirm, after the pause mid-run, play again resumed 16 minutes before it should have, exactly the time I had been listening, seems to me it decided to ignore my listening for 15mins and start anew.
I also have speed to 1.2x so I'll try 1.0x to see if this improve anything

@PyroghostX
Copy link

PyroghostX commented Aug 4, 2023 via email

@HStep20
Copy link
Contributor

HStep20 commented Aug 6, 2023

I believe this is the same issue I am experiencing with Downloaded books playing a 1x speed as well.

I will start a downloaded book to fall asleep to, and use the auto sleep timer. When I wake up and resume the book, the position is at the place it was when I started it the first time. Ive seen similar activity in my history as screenshots posted above - but only for downloaded books. I don't seem to see the same behavior when Streaming the book from the server.

@kevlp3000
Copy link

I saw this post https://discord.com/channels/942908292873723984/981321213882282035/1138130906670956636 and went thru the process. The book I am currently listening to had not been downloaded prior. I was streaming it to avoid the jump back.

After setting the server connection back up, I downloaded the book and began listening to it. This was around 12:25 and for most of the afternoon it seemed to have fixed the issue. I had paused and played throughout the afternoon with no jump back and logs were normal.

My last pause was at 16:42. The start for that session was 16:18. In the logs I see that sessions were updated without issue until 16:25:47. Then I see my user go offline and disconnect. But during this time I am still listening to the book. I'm in my office and on wifi was well. In the log after this time the following messages are repeated as progress is updated

08/07/2023 4:25:47 PM
[2023-08-07 16:25:47] DEBUG: [PlaybackSessionManager] Updated session for "Rebel Mage Charlie" (4a833339-0114-47ad-b042-0a0d5aff2ad7) (PlaybackSessionManager.js:150)
08/07/2023 4:25:47 PM
[2023-08-07 16:25:47] DEBUG: [PlaybackSessionManager] Updating progress for "Rebel Mage Charlie" with current time 12102.25 (previously 12082.747) (PlaybackSessionManager.js:165)
08/07/2023 4:25:47 PM
[2023-08-07 16:25:47] DEBUG: [Server] clientEmitter - no clients found for user 8c8f13fe-928e-4b4f-b3b2-335d0d1fbe84 (SocketAuthority.js:51)
08/07/2023 4:26:02 PM
[2023-08-07 16:26:02] DEBUG: [PlaybackSessionManager] Updated session for "Rebel Mage Charlie" (4a833339-0114-47ad-b042-0a0d5aff2ad7) (PlaybackSessionManager.js:150)
08/07/2023 4:26:02 PM
[2023-08-07 16:26:02] DEBUG: [PlaybackSessionManager] Updating progress for "Rebel Mage Charlie" with current time 12121.752 (previously 12102.25) (PlaybackSessionManager.js:165)
08/07/2023 4:26:02 PM
[2023-08-07 16:26:02] DEBUG: [Server] clientEmitter - no clients found for user 8c8f13fe-928e-4b4f-b3b2-335d0d1fbe84 (SocketAuthority.js:51)

Seeing this, before I started playback via bluetooth ear bud, I went into the app on my phone and see a jump back from pause stamp 03:43:58 to the seek stamp 03:21:22 at 16:47 when I got into the app to check.

Screenshot_20230807_165042_audiobookshelf (1)

Logs covering this listening session: https://pastebin.com/PaS2VJJp

@nichwall
Copy link
Contributor

nichwall commented Aug 16, 2023

I listened to a brand new downloaded book using server version 2.3.3 and only one client of Android 0.9.65. I normally wait for the app to finish establishing a connection to the server, but the only time I was able to get the progress to incorrectly reset when I pressed play immediately unlocking my phone (had the app open when it locked).

Here is the gist of my logs during the several days I listened, with notable sections down below (the gist is a TSV so you can download it and open in Excel to see my columns for easier filtering).
https://gist.github.com/nichwall/637470c0cac5cd0dc9207e9469792c98

During playback where the session is still active, I get the following debug logs repeatedly (with the time correctly updating)

DEBUG: [PlaybackSessionManager] Updating progress for "Every Tools a Hammer" with current time 94.412 (previously 79.411) (PlaybackSessionManager.js:165)
DEBUG: [PlaybackSessionManager] Updated session for "Every Tools a Hammer" (6e735d63-a913-4e2b-8355-5cd1dc77f6c8) (PlaybackSessionManager.js:150)

After a period of time, the socket will close as my user goes offline. I don't know if this is due to a timeout or me going into poor cell service. Sometimes the reason is transport close or ping timeout.

INFO: [Server] Socket 4CQAZLmRZzYvUcjLAAAR disconnected from client "chell" after 718695ms (Reason: transport close)
DEBUG: [Server] User Offline chell (SocketAuthority.js:110)

After going offline, I'll get clientEmitter errors for a while until the listening session ends (like kevlp3000). The user hash is the same for all client emitter errors, regardless of session.

DEBUG: [Server] clientEmitter - no clients found for user f9ea8980-cb50-40a2-8ec3-120355322623 (SocketAuthority.js:51)

After my user goes back online, the server does not update the progress of the book, which I think is because I am waiting for the app to finish "Loading server data".

DEBUG: [PlaybackSessionManager] Not updating progress for "Every Tools a Hammer" because it has been updated more recently (PlaybackSessionManager.js:163)

Some noteable lines in the log:

67-74, end of session where clientEmitter errors were occurring, unlocked phone and pressed Play before allowing app to connect to server. Playback reset to last progress update from client (before clientEmitter error), minus the rewind time

687-697, not sure what this error is, but several listening sessions after this which behaved normally.

1674-1692, looks like the progress kept updating even with the clientEmitter. Did not "not updating progress" after reconnection.

2204-2219, looks like there was a disconnection and client emitter errors, and then a reconnection which continued syncing correctly. Not sure if I paused it for a second at that point, or just happened to unlocked my phone immediately after the socket closed.

@nichwall
Copy link
Contributor

I realize this issue got a bit off track from the originally posted issue. Are all of these comments related to #808 and #828?

Also @falchonhand, was the original file you reported this issue with a variable or constant bitrate file? I'm thinking that may be how you ended up skipping forward when resuming, but could be completely wrong.

@falchonhand
Copy link
Author

falchonhand commented Sep 11, 2023

I'm not actually certain how to determine if it is variable or constant. The issue for mine, I only use the android app for listening. Oddly enough, it happened to me on the same book as issue #828 . Though mine doesn't reset to 0%, it just loses random amounts of progress. This also occurred on my wifes iphone, though, it was a different book. If you have a simple method of checking CBR vs VBR I would be glad to test it

@advplyr
Copy link
Owner

advplyr commented Dec 10, 2023

There have been 3 releases since this issue was raised and one of them (0.9.66) fixed a bunch of sync issues. Is this still an issue on the latest app v0.9.68 and server v2.6.0?

@filviu
Copy link

filviu commented Dec 10, 2023

Not the og reporter but I was following this issue because in the past I had similar issues and now got the notification. In the last months I listened to a bunch of audiobooks and had no issues with position sync or jumping between sessions.

I keep versions up to date usually within days of release so for me I can say issues went away some versions ago.

I checked history and I listened to both m4b and mp3 books and also a few streaming and a few downloaded.

@PyroghostX
Copy link

No more issues for me for months, so i would say this is no longer an issue, good to close

@advplyr
Copy link
Owner

advplyr commented Dec 10, 2023

Awesome thanks. 0.9.66 probably fixed this.

@falchonhand
Copy link
Author

not sure why this is still getting action, it was solved a while back. Do I need to do something to close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants