advplyr / audiobookshelf-app

Mobile application for Audiobookshelf
https://audiobookshelf.org
GNU General Public License v3.0
1.25k stars 169 forks source link

Local play progress gets overwritten from server after the app closes #74

Closed tvories closed 2 years ago

tvories commented 2 years ago

My local play progress seems to be overwritten every so often with the server sync. In addition (this may be a separate issue), the currently playing book changes to the last played book on the web version. I have two books I've started playing, one on the web, one on the phone. Whenever the phone app closes (from idle?) and I re-open it, I get the web player book as the "now playing" instead of the book I was last listening to on the phone app.

My last local progress is also overwritten from whatever was last synced to the server.

Steps to reproduce

  1. Download a file locally and play local.
  2. Pause the book after making progress.
  3. Let the app timeout or force close it.
  4. Re-open the app and the last sync time from the server will overwrite progress.

Expected behaviour

Actual behaviour

Environment data

Audiobookshelf Version: v1.6.49 (docker)

Android Issue

Android version: 0.9.35-beta

Device model: Pixel 3aXL

Stock or customized system: Stock

iOS Issue

iOS Version:

iPhone model:

advplyr commented 2 years ago

I found a bug with local audiobook progress that I will push a fix for in the next release. Downloaded audiobooks are not syncing with the server in the current version.

Your issue though is partially by design I think. Streams are managed per account, not per device. There is going to be an issue with opening 2 different streams using the same account. Only 1 stream will be transcoded and stored at a time. This needs to be updated but I'm not sure what is the ideal behavior.

My idea was that if you start streaming a book in the web app, then open up the mobile app, it should open the web app stream wherever you left off. And vice verse with mobile to the web app.

tvories commented 2 years ago

I tested the new version of the server you released (v1.6.53) and I'm still having this issue. Local playback sync is not working properly.

I understand what you're saying about the per-user streams. To clarify, I played a book once from my web browser as a test, and no matter how many times I played another book on my phone, it always kept that book from the web UI as my "last" played. That does seem to have gone away since I finished my last book. I'm playing only a single book now, and I'm not having a problem with it picking the old book I played once on the web UI.

I am still having issues with my local file not syncing properly, though.

advplyr commented 2 years ago

The way the local file sync is supposed to work is that if you are listening to a downloaded audiobook while connected to your server it should be syncing progress every 5 seconds. If you have listened offline, then when you connect a request is sent to your server with all your local audiobook progress and the server updates each audiobook progress if the last update time is greater.

When listening to the local audiobook are the updates getting sent to your server at all? Just seeking around the audiobook you can watch the progress bar on the cover in the web app. There are no logs during this process, except if you have debug logs on you will see when the database is updated every 5 seconds. "[DB] Update entity user: 1"

tvories commented 2 years ago

I'm still suffering from this every once in a while. I have enabled debug logging on my server to hopefully capture it when it happens.

tvories commented 2 years ago

I haven't been able to re-create it on demand, but it seems to be this issues occurs when I am on my local network accessing my reverse proxy vs when I disconnect from my local wifi and hit it from the external IP. I wonder if the local session is having issues.

Is there a known list of reverse proxy configuration?

ChiefMedicalOfficer commented 2 years ago

Completely anecdotal but since the push was fixed for my issue linked above I haven't had a problem with current location at all (nothing that causes any playback problems anway). Neither has my friend. We've both listened to around 8 books in that period.

I also move between local network and mobile while playing and haven't noticed this happening.

I use Nginx-Proxy-Manager for reverse proxy if that helps.

tvories commented 2 years ago

I am on the latest server (1.6.60) and app (0.9.38-beta) and I've still been dealing with this. In fact, I had one book that I finished and then started a new book. Each time I would pause the app from my headset (without waking the phone) and then resume it after having woken the phone, it would re-start the book I had recently finished.

I don't know if it's an issue of the reverse proxy or of the server overwriting my local progress.

advplyr commented 2 years ago

I think I know what is happening and have an update in the works. Basically syncing local audiobook progress to the server when the phone is asleep is not yet implemented.

It has to do with webview closing when the phone is asleep and the original logic relying entirely on webview to send progress syncs. So I am moving progress syncs to be handled natively. This is done for streaming audiobooks already but not yet for local.

tvories commented 2 years ago

That would make sense, and while I can't always duplicate the issue, that would go along with what I've observed when it happens.

advplyr commented 2 years ago

v0.9.39-beta is live on the play store. This also requires a server update to v1.6.61.

When you are playing downloaded audiobooks while logged into your server the progress will sync every 5s whether the phone is awake or not.

tvories commented 2 years ago

Testing it out! Thanks for the update

tvories commented 2 years ago

So far this is looking good. I have noticed that my latest book didn't show up under "Continue Reading" a few times, but it did keep the correct position! I'll close the issue for now and reply back if I see any further issues. Thanks for the fix!