audiobookshelf-app icon indicating copy to clipboard operation
audiobookshelf-app copied to clipboard

[Bug]: download complete but cant create library item (ios)

Open xanthos84 opened this issue 1 year ago • 28 comments

Describe the issue

downloading items does not work on last version ios 0.9.67 / 0.9.68

Steps to reproduce the issue

  1. open app
  2. download item for offline listening
  3. items download progresses until 100%
  4. error msg „download complete but cant create library item“

Audiobookshelf version

2.5 server 0.9.67/0.9.68 ios

How are you running audiobookshelf?

Docker

xanthos84 avatar Nov 27 '23 06:11 xanthos84

Have you tried with several different books of different formats? What format is the book you are trying? Are you using your local network or a proxy?

advplyr avatar Nov 27 '23 10:11 advplyr

different books / "hörbücher" , all in mp3 files... what you mean with format of the book?

its on my server which i access through a reverse proxy.

github-e51 avatar Nov 27 '23 10:11 github-e51

Have you tried downloading on your local ip address instead of through the proxy?

advplyr avatar Nov 27 '23 10:11 advplyr

well i can try it, but i need to adjust my network settings - as the server is not directly accessable (only through reverse proxy)

github-e51 avatar Nov 27 '23 10:11 github-e51

okay i tried with direct access without reverse proxy involved, same error! its downloading.. but on 100% its complaining about creating library item..

github-e51 avatar Nov 27 '23 10:11 github-e51

What iOS device are you using and what version? Is it stock? and do you have another device you can test on?

advplyr avatar Nov 27 '23 10:11 advplyr

I already tested on my two iOS devices... a iPhone 14 Pro 17.1.1 and iPad Pro 11" 2021 M1 model with 17.1

xanthos84 avatar Nov 27 '23 10:11 xanthos84

maybe to add, they are both self-signed versions of the app as there is no free slot on the testflight beta

xanthos84 avatar Nov 27 '23 10:11 xanthos84

report: tried 0.9.68 but same error after downloading...

xanthos84 avatar Nov 27 '23 17:11 xanthos84

Are you able to open the browser and download successfully from the website?

advplyr avatar Nov 27 '23 19:11 advplyr

Are you able to open the browser and download successfully from the website?

yes that works fine for single files and for complete packages (zip).

xanthos84 avatar Nov 27 '23 19:11 xanthos84

When you press download in the mobile app you should see a bunch of logs in the server that your user is downloading files.

[LibraryItemController] User "${req.user.username}" requested file download at "${libraryFile.metadata.path}"

Check if you see a log like that on your server.

advplyr avatar Nov 27 '23 19:11 advplyr

When you press download in the mobile app you should see a bunch of logs in the server that your user is downloading files.

[LibraryItemController] User "${req.user.username}" requested file download at "${libraryFile.metadata.path}"

Check if you see a log like that on your server.

yes, looks like:

audiobookshelf-audiobookshelf-1 | [2023-11-27 20:01:10] INFO: [LibraryItemController] User "xanthos" requested file download at "/audiobooks/2023/Louise Hay - Affirmationen - Die lebensverändernde Kraft deiner Gedanken/16 - Kapitel 16.mp3" audiobookshelf-audiobookshelf-1 | [2023-11-27 20:01:10] INFO: [LibraryItemController] User "xanthos" requested file download at "/audiobooks/2023/Louise Hay - Affirmationen - Die lebensverändernde Kraft deiner Gedanken/28 - Kapitel 28.mp3" audiobookshelf-audiobookshelf-1 | [2023-11-27 20:01:10] INFO: [LibraryItemController] User "xanthos" requested file download at "/audiobooks/2023/Louise Hay - Affirmationen - Die lebensverändernde Kraft deiner Gedanken/13 - Kapitel 13.mp3" but ends with that line above..

xanthos84 avatar Nov 27 '23 20:11 xanthos84

A user of mine is also getting this error on Android. Download completed, but cannot create a library item on the device.

Happening with an m4b file.

kymahi avatar Dec 09 '23 14:12 kymahi

this is still an issue with the newest app on iOS + newest server version! "item downloaded but failed to create library item". server version 2.7.2 ios 0.9.71 (even though it shows 0.9.70 in app, i guess someone did not change the value)

happens on every mp3 on the server. i can download the items fine on any browser on windows/mac.

the server log just shows that the files were requested by the user. no more log when the error shows up (even log lvl is debug...)

maybe you can add more debug log lines around the method...

xanthos84 avatar Jan 30 '24 15:01 xanthos84

Having same issue

Server 2.8.1 ios (self signed) 0.9.73-beta

Jeor avatar Mar 25 '24 17:03 Jeor

Having the same issue. App is signed and installed using a valid dev certificate. How can I further troubleshoot this?

soberhofer avatar Apr 08 '24 17:04 soberhofer

As an additional Information: When the download finishes and i get the error, the following is logged by the kernel on the iPhone:

Sandbox: Audiobookshelf(10645) deny(1) file-write-unlink /private/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/com.audiobookshelf.app.XXXXXXX/CFNetworkDownload_ZcBCsm.tmp

soberhofer avatar Apr 16 '24 12:04 soberhofer

Also getting this error, only happens on my wife's phone, any book. Tried hostname, then IP. Tried deleting app and re-installing. Tried creating a second account, issue still persists. Tried restarting iPhone. re-scanning book. works fine on my phone.

jerry00020001 avatar May 19 '24 20:05 jerry00020001

Also getting this error. Client version 0.9.74. Server version 2.9.0. Every attempt to download a book yields "Item download complete but failed to create library item" error message on the client. App is personally signed and sideloaded (not part of the test flight beta). iOS 17.4.1.

I suspect this may have something to do with personally signed apps as it sounds like everyone reporting above is not in the Test Flight beta. ?

clincher61 avatar May 22 '24 16:05 clincher61

TLDR: Use AltStore to sideload the app.

I have found the root cause of this problem. It is occurring due to a missing sandbox entitlement which seems to be coming from how users are choosing to sideload their app. It is not an application bug/build/configuration issue. At this time I have tested Sideloadly and AltStore with sideloading via Altstore being the solution. Other sideloading methods may work but I have not tested them.

When building the application from source and deploying to a simulator or physical device, we can review the console logs while attempting to download a file from the server. A proper download looks like this: ⚡️ [log] - Local library item {"serverConnectionConfigId":"aHR0cHM6Ly9hYi5jZi1sLmNvbUBjb2ZpZmllbGQ=","localFiles":[{"size":482114117,"contentUrl":"file:///var/mobile/Containers/Data/Application/608A8FB7-6BA5-4393-9761-92B505875F5B/Documents/9550e1ac-ebc0-4b6e-b233-8a563aa379be/Harry%20Potter%20and%20the%20Philosopher's%20Stone%20-%20Harry%20Potter%20and%20the%20Philosopher's%20Stone.m4b","id":"9550e1ac-ebc0-4b6e-b233-8a563aa379be_SGFycnkgUG90dGVyIGFuZCB0aGUgUGhpbG9zb3BoZXIncyBTdG9uZSAtIEhhcnJ5IFBvdHRlciBhbmQgdGhlIFBoaWxvc29waGVyJ3MgU3RvbmUubTRi","filename":"Harry Potter and the Philosopher's Stone - Harry Potter and the Philosopher's Stone.m4b","basePath":"Harry Potter and the Philosopher's Stone - Harry Potter and the Philosopher's Stone.m4b","mimeType":"audio/mp4"},{"mimeType":"image/jpg","contentUrl":"file:///var/mobile/Containers/Data/Application/608A8FB7-6BA5-4393-9761-92B505875F5B/Documents/9550e1ac-ebc0-4b6e-b233-8a563aa379be/cover.jpg","id":"9550e1ac-ebc0-4b6e-b233-8a563aa379be_Y292ZXIuanBn","filename":"cover.jpg","basePath":"cover.jpg","size":32016}],"serverAddress":"https://your-server-here.com","isLocal":true,"libraryItemId":"9550e1ac-ebc0-4b6e-b233-8a563aa379be","contentUrl":"file:///var/mobile/Containers/Data/Application/608A8FB7-6BA5-4393-9761-92B505875F5B/Documents/9550e1ac-ebc0-4b6e-b233-8a563aa379be/","media":{"audioFiles":[{"index":1,"metadata":{"filename":"Harry Potter and the Philosopher's Stone - Harry Potter and the Philosopher's Stone.m4b","ext":".m4b","relPath":"Harry Potter and the Philosopher's Stone - Harry Potter and the Philosopher's Stone.m4b","path":"/audiobooks/J.K. Rowling/Harry Potter/1 - Harry Potter and the Philosopher's Stone/Harry Potter and the Philosopher's Stone - Harry Potter and the Philosopher's Stone.m4b","size":482114117},"ino":"36522"}],"tags":[],"ebookFile":null,"metadata":{"explicit":false,"authors":[{"name":"J.K. Rowling","id":"e414a5ac-0cc7-42b9-b410-ac6c8d609f7c","coverPath":null}],"isbn":null,"publishedYear":"1997","genres":["Academy","Portal Fantasy (YA)"],"language":"English","authorName":"J.K. Rowling","publisher":"Pottermore Publishing","narratorName":"Stephen Fry","subtitle":null,"asin":"B079TM3YHV","title":"01 Harry Potter and the Philosopher's Stone","authorNameLF":"Rowling, J.K.","publishedDate":null,"narrators":["Stephen Fry"],"feedUrl":null,"seriesName":"Harry Potter #1","author":null,"description":"Unabridged"},"size":482114117,"episodes":[],"autoDownloadEpisodes":null,"libraryItemId":"9550e1ac-ebc0-4b6e-b233-8a563aa379be","chapters":[{"end":28.813991,"id":0,"title":"Opening Credits","start":0},{"end":1928.717982,"id":1,"title":"Chapter 1: The Boy Who Lived","start":28.813991},{"end":3258.663968,"id":2,"title":"Chapter 2: The Vanishing Glass","start":1928.717982},{"end":4775.994966,"id":3,"title":"Chapter 3: The Letters from No One","start":3258.663968},{"end":6246.165964,"id":4,"title":"Chapter 4: The Keeper of the Keys","start":4775.994966},{"end":8890.128957,"id":5,"title":"Chapter 5: Diagon Alley","start":6246.165964},{"end":11176.736939,"id":6,"title":"Chapter 6: The Journey from Platform Nine and Three-Quarters","start":8890.128957},{"end":12950.763923,"id":7,"title":"Chapter 7: The Sorting Hat","start":11176.736939},{"end":14076.652902,"id":8,"title":"Chapter 8: The Potions Master","start":12950.763923},{"end":15918.2739,"id":9,"title":"Chapter 9: The Midnight Duel","start":14076.652902},{"end":17490.101882,"id":10,"title":"Chapter 10: Hallowe'en","start":15918.2739},{"end":18700.069864,"id":11,"title":"Chapter 11: Quidditch","start":17490.101882},{"end":20766.296848,"id":12,"title":"Chapter 12: The Mirror of Erised","start":18700.069864},{"end":21985.808844,"id":13,"title":"Chapter 13: Nicolas Flamel","start":20766.296848},{"end":23265.900839,"id":14,"title":"Chapter 14: Norbert the Norwegian","start":21985.808844},{"end":25329.318821,"id":15,"title":"Chapter 15: The Forbidden Forest","start":23265.900839},{"end":27916.578821,"id":16,"title":"Chapter 16: Through the Trapdoor","start":25329.318821},{"end":30243.98381,"id":17,"title"

The big takeaway here is that the system is able to write and access /private/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/com.audiobookshelf.app.XXXXXX/ while downloading the temporary file and moving it into the user's library.

The ENABLE_USER_SCRIPT_SANDBOXING is already set to "no" in the app's build configuration. With help from this article I was able to determine the app configuration was correct.

As seen by other users above, when the application is signed without the correct entitlements we receive a console message iPhone kernel(Sandbox)[0] <Error>: Sandbox: Audiobookshelf(8348) deny(1) file-write-unlink /private/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/com.audiobookshelf.app.XXXXXXX/CFNetworkDownload_UyO830.tmp

Hope this helps! I believe it would be beneficial to have a notice posted as I see users potentially running into this.

cofifield avatar Jun 04 '24 14:06 cofifield

Thanks, can the OP confirm if they were also sideloading? @xanthos84

advplyr avatar Jun 04 '24 15:06 advplyr

yes sideloading the app. need to see if i can switch to something like altstore, as I use my own system to sign the apps - so its quite embarrassing to use something else 3rd party to get the app running like it should. maybe i can get a TestFlight invitation?

xanthos84 avatar Jun 04 '24 18:06 xanthos84

There should currently be spots available in Testflight (a little over 1000 spots cleared 2 days ago)

nichwall avatar Jun 04 '24 18:06 nichwall

brilliant news! just opted in!

xanthos84 avatar Jun 04 '24 18:06 xanthos84

Latest release installed via Altstore is no longer having the issue. Previously, Sideloadly was used unsuccessfully FWIW.

Jeor avatar Jun 04 '24 18:06 Jeor

I also ran into this problem earlier this week. For me it happened because I didn't have enough free space on my iPhone. After cleaning a few gbs up, the download succeeded.

megawubs avatar Jun 07 '24 04:06 megawubs

Have same thing. Sideloadly worked absolutely fine, but e-sign and scarlet are having issues.