advplyr / audiobookshelf-app

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

Problem Downloading big Audiobooks #1167

Open Maxklos opened 6 months ago

Maxklos commented 6 months ago

Steps to reproduce

  1. Download a big Audiobook
  2. Wait for download

Expected behaviour

Download would complete.

Actual behaviour

I use ABS for a while now and most of the times i don't encounter this problem. Now i have a Audiobook (533 Chapters -> 533 m4b files, ~43h, 2,45gb) I can listen to it fine when using the "Stream" Option or the Webinterface. When i try to download it, it takes a looong time (around 1h) then the app just hangs at "Downloading... Processing" indefinitely. When i change apps and come back the download is complete gone. I tried manually putting the files in the correct folder on my Phone but the same problems occur. It doesn't matter if i download to the internal App Storage or a custom folder on the device. Changing the Energy saving settings to "unrestricted" didn't help.

I looked at a couple of Issues here on Github which are similar: https://github.com/advplyr/audiobookshelf-app/issues/816 -> Same Problem, but i don't use trafik https://github.com/advplyr/audiobookshelf-app/issues/956 -> Would probaly help the download side

Environment data

Audiobookshelf Version: 0.9.73-beta Server Version: v2.8.1

Android Issue

Android version: 13 / 14

Device model:

Stock or customized system: Stock

advplyr commented 6 months ago

Are you downloading using a local ip address or a reverse proxy?

Maxklos commented 6 months ago

Ah sorry, i forgot. ABS is running on a Ubuntu Server and accessed through Cloudflaretunnel. I tested it with another server and direct IP access, it worked once but not reliable.

Another update. While writing the Issue I tested it again but with the screentimeout of my Phone set to 30min. With that the download worked and also the processing finished (processing was around 15min). With the same Audiobook converted to mp3 (3.50GB) the process is faster.

I think its an Problem with m4b files and the Socket disconnect if the Phonescreen locks / changes

bwprog commented 5 months ago

I think I'm experiencing the same issue. Android 14 Pixel 8 0.9.73-beta ABS 2.8.1 and now 2.9.0 on Docker Linux NPM latest or Caddy latest on docker linux -- I've tried going back and forth with same issue but both worked with same image/config a month ago.

Downloading books onto the android app used to take less than 30 seconds back on ABS 2.7.2. It now takes 20 minutes if it completes at all. I have to keep the app on top and keep the screen from locking to keep the download going. What is frustrating is that there is no pause/resume to the downloads so when it hangs from opening another app or screen locks, I have to force quit ABS and then start the download over from scratch. I've also tried clearing all cache and downloads on the app which has not helped.

I have tried downloading the same file using firefox on my desktop going through reverse proxy and it takes a long time there too at ~400K/s. If I try connecting directly to my library on internal network, I can download the same audibook in 5 seconds at ~14MB/s. I double-checked with speedtest and my upload is still over 700mb/s so I'm not throttled. While the issue appears to be with the reverse proxy, neither NPM nor Caddy have updated this year and the problem for me started maybe a month ago after upgrading ABS, so I don't know how both reverse proxies that used to work are causing this slowdown.

If I set the android app to use the internal IP of the ABS docker image, the book downloads work at the same speed they used to when using the reverse proxy. If I need to switch internal/external going forward, it would be nice if the user/pwd could be cached when switching servers.

15sawyer commented 4 months ago

I experience much the same. Downloading anything has become very frustrating. My device has to be kept from closing. Otherwise, some files hang or it may abort completely. I have also seen the app hanging at the 'Processing' step. Speed isn't as fast as I would expect from my setup, but it is okay. My ABS is behind a Traefik reverse proxy.

The app could really benefit from a resume-download functionality.

troy117 commented 4 months ago

I am having the same issue. I really want to be able to download the books to my phone, but it will randomly stop. I also can't cancel it out and restart either, its just stuck at whatever percent it died at. So I'm stuck with streaming... I am running my server on a seedbox that has great upload, and using an android phone over my wifi.

Maxklos commented 4 months ago

Currently it takes a long time for the download, but with the screen timeout set to 30min, it completes the download. I can see the files in the right folder of the device. But currently it hangs at the "processing" part, even after another 30min it's still there.... After a long wait the app just crashes. It doesn't matter if it is a m4b or mp3 file.

Maxklos commented 4 months ago

@advplyr can you please give us some insight of what is happening at the "processing" Stage and what file format should be used to minimize the processing time?

troy117 commented 3 months ago

I installed android studio, cloned the repository, and emulated my phone a Pixel 6 Pro and was able to successfully download many large audiobooks without issues from my seedbox server. However, using my phone the file download randomly will stop, once once it does it will not resume. Closing the app out and re-opening it I will have to re-start the download from 0% and once again it never completes.

I am including the logcat from where the download gets frozen. Hopefully this will help.
Screenshot 2024-06-04 152033

troy117 commented 2 months ago

@Maxklos @bwprog @15sawyer I was having the same issue on two of my devices. I fixed the issue and and posted two pull requests with the code corrections. If you're able to compile my repo and verify that the downloads work it might help get my pull requests approved. I don't know how to reproduce the error that is causing the downloads to freeze up during simulation, but was able to verify that it works by actually downloading my audiobooks on my devices.
Because I am new to GitHub I posted it as two different pull requests #1230 &#1231. The repo is: https://github.com/troy117/audiobookshelf-app