App keeps crashing (local storage permissions lost) #613

Open
opened 2026-04-24 23:30:13 +02:00 by adam · 46 comments
Owner

Originally created by @WickedSquirrel on GitHub (Jul 6, 2023).

Steps to reproduce

  1. Use the app to listen to an Audiobook that's locally saved

Expected behaviour

Actual behaviour

  • the audio starts stuttering and is then cutting off
  • the app keeps crashing and displays the standard android waiting for app.. sometimes it plays while the message is shown

Environment data

Audiobookshelf Version:

  • [ X ] Android App?
  • iOS App?

Android Issue

Android version:
Newest

Device model:
Pixel 5

Stock or customized system:
Stock I think

iOS Issue

iOS Version:

iPhone model:

Originally created by @WickedSquirrel on GitHub (Jul 6, 2023). ### Steps to reproduce 1. Use the app to listen to an Audiobook that's locally saved 2. 3. ### Expected behaviour - ### Actual behaviour - the audio starts stuttering and is then cutting off - the app keeps crashing and displays the standard android waiting for app.. sometimes it plays while the message is shown ### Environment data Audiobookshelf Version: - [ X ] Android App? - [ ] iOS App? #### Android Issue Android version: Newest Device model: Pixel 5 Stock or customized system: Stock I think #### iOS Issue iOS Version: iPhone model:
adam added the bugandroid labels 2026-04-24 23:30:13 +02:00
Author
Owner

@nichwall commented on GitHub (Jul 7, 2023):

What server version are you running? If you are running the latest app (0.9.65), you need to have at least server version 2.2.23. You can check both of these numbers using the menu in the upper right corner of the app

@nichwall commented on GitHub (Jul 7, 2023): What server version are you running? If you are running the latest app (0.9.65), you need to have at least server version 2.2.23. You can check both of these numbers using the menu in the upper right corner of the app
Author
Owner

@mihailim commented on GitHub (Jul 7, 2023):

Been happening for me as well for the past few weeks. Docker 2.2.23, app 0.9.65. Opus, multiple files per audiobook. Excepting the app from battery optimization and so on doesn't seem to change anything.

@mihailim commented on GitHub (Jul 7, 2023): Been happening for me as well for the past few weeks. Docker 2.2.23, app 0.9.65. Opus, multiple files per audiobook. Excepting the app from battery optimization and so on doesn't seem to change anything.
Author
Owner

@gazpachoking commented on GitHub (Jul 9, 2023):

This happens for me, but only if I download the audiobook locally. Streaming works fine.

EDIT: Some more detail
When I click to play a downloaded book, the audio starts immediately, but the player (the strip on the bottom of the screen) doesn't show up for several seconds (~15 seconds.)
Usually, the audio starts getting stuttery after a few seconds.
Sometimes the whole app crashes a few seconds later.
Sometimes things will keep working, and the stutters stop, or go down to a minimum. When this happens, the phone still seems to run hotter and more slugishly.
This wasn't happening before a few weeks ago, though I haven't done experimentation to pin it down to a specific version yet.

Current versions:
Server: 2.2.23
Android App: 0.9.65-beta

EDIT2:
Did some more testing, seems this started with 0.9.64. I just tried that and 0.9.63, and things seem to be working better on 0.9.63.

@gazpachoking commented on GitHub (Jul 9, 2023): This happens for me, but only if I download the audiobook locally. Streaming works fine. EDIT: Some more detail When I click to play a downloaded book, the audio starts immediately, but the player (the strip on the bottom of the screen) doesn't show up for several seconds (~15 seconds.) Usually, the audio starts getting stuttery after a few seconds. Sometimes the whole app crashes a few seconds later. Sometimes things will keep working, and the stutters stop, or go down to a minimum. When this happens, the phone still seems to run hotter and more slugishly. This wasn't happening before a few weeks ago, though I haven't done experimentation to pin it down to a specific version yet. Current versions: Server: 2.2.23 Android App: 0.9.65-beta EDIT2: Did some more testing, seems this started with 0.9.64. I just tried that and 0.9.63, and things seem to be working better on 0.9.63.
Author
Owner

@mihailim commented on GitHub (Jul 10, 2023):

Thank you for the additional description, @gazpachoking ! Yeah, that's exactly how it's behaving for me as well for local playback, including the initial UI freeze while audio is playing, the stutters and so on. The only additional details I can add are:

  • Android 13
  • I'm normally listening at 1.5x speed, but when the app crashes and it's behaving the way you've described after restarting it, speed is back at 1.0x, even if I previously made sure to set 1.5x, play a bit, and shut the app down properly so the playback speed gets saved.

These may or may not be relevant, just throwing them out there as additional data points.

Edit: Oh, and of course tried completely nuking the app (including its local cache, storage, and the local storage directory) then reinstalling it and creating a new local storage directory. No change.

@mihailim commented on GitHub (Jul 10, 2023): Thank you for the additional description, @gazpachoking ! Yeah, that's exactly how it's behaving for me as well for local playback, including the initial UI freeze while audio is playing, the stutters and so on. The only additional details I can add are: * Android 13 * I'm normally listening at 1.5x speed, but when the app crashes and it's behaving the way you've described after restarting it, speed is back at 1.0x, even if I previously made sure to set 1.5x, play a bit, and shut the app down properly so the playback speed gets saved. These may or may not be relevant, just throwing them out there as additional data points. **Edit:** Oh, and of course tried completely nuking the app (including its local cache, storage, _and_ the local storage directory) then reinstalling it and creating a new local storage directory. No change.
Author
Owner

@WickedSquirrel commented on GitHub (Jul 10, 2023):

What server version are you running? If you are running the latest app (0.9.65), you need to have at least server version 2.2.23. You can check both of these numbers using the menu in the upper right corner of the app

Screenshot_20230710-182701~2.png

I think I have both set to always be up to date

@WickedSquirrel commented on GitHub (Jul 10, 2023): > What server version are you running? If you are running the latest app (0.9.65), you need to have at least server version 2.2.23. You can check both of these numbers using the menu in the upper right corner of the app ![Screenshot_20230710-182701~2.png](https://github.com/advplyr/audiobookshelf-app/assets/123376444/cb72c93a-1bdf-4d98-9a15-810fbdd9b5ac) I think I have both set to always be up to date
Author
Owner

@nichwall commented on GitHub (Jul 11, 2023):

Are all of you listening to the books in a web browser at all, or only in the Android app? Are you in an area with poor cell reception when this issue occurs?

@Daemonias - Is it with both streamed and downloaded books?
@gazpachoking @mihailim - Are you waiting for the server connection to be established before beginning playback?

There was a change recently (don't remember exactly when) to allow playback if the connection to the server hasn't been established. What happens if you log out of the server and try to play a downloaded book (steps below)?

  1. Press "Logout" at the bottom of the menu
  2. Press the back arrow in the upper left to use the app completely offline
  3. The menu on the right should now say "Connect to Server" at the top with a crossed out cloud

You can also try playing a downloaded book in airplane mode, just trying to narrow down what the issue is

@nichwall commented on GitHub (Jul 11, 2023): Are all of you listening to the books in a web browser at all, or only in the Android app? Are you in an area with poor cell reception when this issue occurs? @Daemonias - Is it with both streamed and downloaded books? @gazpachoking @mihailim - Are you waiting for the server connection to be established before beginning playback? There was a change recently (don't remember exactly when) to allow playback if the connection to the server hasn't been established. What happens if you log out of the server and try to play a downloaded book (steps below)? 1. Press "Logout" at the bottom of the menu 2. Press the back arrow in the upper left to use the app completely offline 3. The menu on the right should now say "Connect to Server" at the top with a crossed out cloud You can also try playing a downloaded book in airplane mode, just trying to narrow down what the issue is
Author
Owner

@WickedSquirrel commented on GitHub (Jul 11, 2023):

I don't know.. I nearly never stream.. I can try.

And I will try the offline mode.

@WickedSquirrel commented on GitHub (Jul 11, 2023): I don't know.. I nearly never stream.. I can try. And I will try the offline mode.
Author
Owner

@mihailim commented on GitHub (Jul 11, 2023):

Tested three scenarios:

  1. Wifi and mobile data disconnected, i.e. no IP connectivity: Can't reproduce the crashing in about 30 minutes of testing. When initiating local media playback, audio starts right away as usual, but the UI freezes / isn't interactable for about 5 seconds, again as usual.
  2. Wifi and mobile data connected, but server deliberately stopped: Can't reproduce the crashing in about 15 minutes of testing, i.e. same as scenario 1. Again, when initiating local media playback, audio starts right away as usual, but the UI freezes / isn't interactable for about 5 seconds, again as usual.
  3. Wifi and mobile data connected, server online: Crashes once in a while, as usual. When initiating local media playback, audio starts right away as usual but stutters for a while, and the UI freezes / isn't interactable for about 15-20 seconds, again as usual for this scenario.

So indeed it seems to be related to client/server comms. Speculation: smells like a race condition somewhere, blocking the UI -- and maybe the UI blockage is leading to the app being killed?

@mihailim commented on GitHub (Jul 11, 2023): Tested three scenarios: 1. Wifi and mobile data disconnected, i.e. no IP connectivity: Can't reproduce the crashing in about 30 minutes of testing. When initiating local media playback, audio starts right away as usual, but the UI freezes / isn't interactable for about 5 seconds, again as usual. 2. Wifi and mobile data connected, but server deliberately stopped: Can't reproduce the crashing in about 15 minutes of testing, i.e. same as scenario 1. Again, when initiating local media playback, audio starts right away as usual, but the UI freezes / isn't interactable for about 5 seconds, again as usual. 3. Wifi and mobile data connected, server online: Crashes once in a while, as usual. When initiating local media playback, audio starts right away as usual but stutters for a while, and the UI freezes / isn't interactable for about 15-20 seconds, again as usual for this scenario. So indeed it seems to be related to client/server comms. Speculation: smells like a race condition somewhere, blocking the UI -- and maybe the UI blockage is leading to the app being killed?
Author
Owner

@advplyr commented on GitHub (Jul 11, 2023):

@mihailim When the UI leads to the crash this usually gives a message like "the app isn't responding", is that what you are seeing?

You said you are on Android 13 but what device are you using and is it stock?

You said you were using opus audio files, have you tried any other audio formats?

If you go to logs on the server and enable debug logs you should be able to watch the mobile app sync with the server every 30 seconds or so.

@advplyr commented on GitHub (Jul 11, 2023): @mihailim When the UI leads to the crash this usually gives a message like "the app isn't responding", is that what you are seeing? You said you are on Android 13 but what device are you using and is it stock? You said you were using opus audio files, have you tried any other audio formats? If you go to logs on the server and enable debug logs you should be able to watch the mobile app sync with the server every 30 seconds or so.
Author
Owner

@mihailim commented on GitHub (Jul 11, 2023):

Bit hard to tell, since the screen is always off when it happens, and unlocking it presumably clears :) I'll try to reproduce with it plugged in and every screen timeout turned off; could take a bit though. I'll also try to capture some filtered and some raw logcat output, and will try to correlate it with the server-side debug logs.

Using a Pixel 6a, fully stock, not rooted, July 5 2023 patch level, but the problem has been occurring for at least 2 months.

Haven't tried any other formats yet, will try a monolithic m4b.

@mihailim commented on GitHub (Jul 11, 2023): Bit hard to tell, since the screen is always off when it happens, and unlocking it presumably clears :) I'll try to reproduce with it plugged in and every screen timeout turned off; could take a bit though. I'll also try to capture some filtered _and_ some raw logcat output, and will try to correlate it with the server-side debug logs. Using a Pixel 6a, fully stock, not rooted, July 5 2023 patch level, but the problem has been occurring for at least 2 months. Haven't tried any other formats yet, will try a monolithic m4b.
Author
Owner

@WickedSquirrel commented on GitHub (Jul 12, 2023):

@mihailim When the UI leads to the crash this usually gives a message like "the app isn't responding", is that what you are seeing?

You said you are on Android 13 but what device are you using and is it stock?

You said you were using opus audio files, have you tried any other audio formats?

If you go to logs on the server and enable debug logs you should be able to watch the mobile app sync with the server every 30 seconds or so.

That's what I'm sometimes getting.. it can even play while saying that.. then I press wait for app.. then it comes again.
Leaving the app or closing the screen will make it crash

@WickedSquirrel commented on GitHub (Jul 12, 2023): > @mihailim When the UI leads to the crash this usually gives a message like "the app isn't responding", is that what you are seeing? > > You said you are on Android 13 but what device are you using and is it stock? > > You said you were using opus audio files, have you tried any other audio formats? > > If you go to logs on the server and enable debug logs you should be able to watch the mobile app sync with the server every 30 seconds or so. That's what I'm sometimes getting.. it can even play while saying that.. then I press wait for app.. then it comes again. Leaving the app or closing the screen will make it crash
Author
Owner

@gazpachoking commented on GitHub (Aug 3, 2023):

I've noticed that some books are worse than others with this problem. Perhaps to do with the number of files?

Downloaded books are totally unusable for me with Android Auto, because the app crashes and is closed after a few seconds of playback.
I can't use another app while listening to a downloaded book either, because the message about audiobookshelf not responding keeps popping up over the other app (the audio continues to play in the background though.) If I click 'wait' I get a few seconds before the dialog pops back up again. If I click to end the program playback stops.

@gazpachoking commented on GitHub (Aug 3, 2023): I've noticed that some books are worse than others with this problem. Perhaps to do with the number of files? Downloaded books are totally unusable for me with Android Auto, because the app crashes and is closed after a few seconds of playback. I can't use another app while listening to a downloaded book either, because the message about audiobookshelf not responding keeps popping up over the other app (the audio continues to play in the background though.) If I click 'wait' I get a few seconds before the dialog pops back up again. If I click to end the program playback stops.
Author
Owner

@mihailim commented on GitHub (Aug 4, 2023):

Update (and sorry for the long absence without feedback): So far I'm unable to reproduce this any longer after changing the nginx reverse proxy read and send timeout values.

Context: Used to have the timeouts at 20 seconds by default, down from the nginx defaults of 60 seconds. Wanted to get rid of the constant annoying "socket connected / socket disconnected" messages. In other words, in the nginx config, at the same level as the other proxy directives such as proxy_pass and proxy_set_header, I've added

proxy_read_timeout 1h;
proxy_send_timeout 1h;

Since then, the problem has completely disappeared -- which tracks with the speculation that it was sync-related.

Might be worth trying that to see if it actually helps!

Edit:

Tightened things up even further -- left the read and send timeout at the 60 second nginx defaults for the main reverse proxy, and set them to 1 hour just for the /socket.io/ location. Local playback still works perfectly this way. So from where I'm standing, there's a strong likelihood that the issues were caused by too-low reverse proxy read and send timeouts to the sync API endpoint.

@mihailim commented on GitHub (Aug 4, 2023): Update (and sorry for the long absence without feedback): So far I'm unable to reproduce this any longer after changing the nginx reverse proxy read and send timeout values. Context: Used to have the timeouts at 20 seconds by default, down from the nginx defaults of 60 seconds. Wanted to get rid of the constant annoying "socket connected / socket disconnected" messages. In other words, in the nginx config, at the same level as the other proxy directives such as `proxy_pass` and `proxy_set_header`, I've added proxy_read_timeout 1h; proxy_send_timeout 1h; Since then, the problem has completely disappeared -- which tracks with the speculation that it was sync-related. Might be worth trying that to see if it actually helps! **Edit:** Tightened things up even further -- left the read and send timeout at the 60 second nginx defaults for the main reverse proxy, and set them to 1 hour just for the `/socket.io/` location. Local playback still works perfectly this way. So from where I'm standing, there's a strong likelihood that the issues were caused by too-low reverse proxy read and send timeouts to the sync API endpoint.
Author
Owner

@gazpachoking commented on GitHub (Aug 11, 2023):

Tried setting the timeouts on my reverse proxy to 1h as well, but with no luck. Didn't seem to affect this issue at all. I'm also confused how it could affect things, as the issue occurs immediately when starting a book, how would any sort of timeout affect things before the timeout period has even elapsed?

@gazpachoking commented on GitHub (Aug 11, 2023): Tried setting the timeouts on my reverse proxy to 1h as well, but with no luck. Didn't seem to affect this issue at all. I'm also confused how it could affect things, as the issue occurs immediately when starting a book, how would any sort of timeout affect things before the timeout period has even elapsed?
Author
Owner

@mihailim commented on GitHub (Aug 11, 2023):

Damn and blast... I really had hopes that was it. For me, it always took 15+ minutes to happen, usually even longer (which is why it was rather difficult to reproduce reliably) and it doesn't happen at all now... :/

@mihailim commented on GitHub (Aug 11, 2023): Damn and blast... I really had hopes that was it. For me, it always took 15+ minutes to happen, usually even longer (which is why it was rather difficult to reproduce reliably) and it doesn't happen at all now... :/
Author
Owner

@gazpachoking commented on GitHub (Aug 13, 2023):

Ugh. I tried to revert to 0.9.63 again, but now that version is failing to download my books.

@gazpachoking commented on GitHub (Aug 13, 2023): Ugh. I tried to revert to 0.9.63 again, but now that version is failing to download my books.
Author
Owner

@mihailim commented on GitHub (Aug 13, 2023):

Yup, you'd need to downgrade the server as well.

@mihailim commented on GitHub (Aug 13, 2023): Yup, you'd need to downgrade the server as well.
Author
Owner

@gazpachoking commented on GitHub (Aug 13, 2023):

Hmmmmm. This is anecdotal at this point because I've only clicked to play once. Something got messed up during my version changes and even when restoring 0.9.65 the app was crashing all the time. I cleared my audiobook download folder (because it never matches already downloaded things to the server items after a version change,) then cleared the app cache and storage. Somehow everything seems to be working properly for downloaded books now. The real test will be when I get back in to my car for android auto, as that's when it's at its worst.

@gazpachoking commented on GitHub (Aug 13, 2023): Hmmmmm. This is anecdotal at this point because I've only clicked to play once. Something got messed up during my version changes and even when restoring 0.9.65 the app was crashing all the time. I cleared my audiobook download folder (because it never matches already downloaded things to the server items after a version change,) then cleared the app cache and storage. Somehow everything seems to be working properly for downloaded books now. The real test will be when I get back in to my car for android auto, as that's when it's at its worst.
Author
Owner

@mihailim commented on GitHub (Aug 15, 2023):

The server-side switch to SQLite also necessitated a change in all the IDs (libraries, library items, authors, what have you), so when downgrading nothing already downloaded would match, need to start from a clean slate on the app side.

@mihailim commented on GitHub (Aug 15, 2023): The server-side switch to SQLite also necessitated a change in all the IDs (libraries, library items, authors, what have you), so when downgrading nothing already downloaded would match, need to start from a clean slate on the app side.
Author
Owner

@gazpachoking commented on GitHub (Aug 23, 2023):

I cleared my audiobook download folder (because it never matches already downloaded things to the server items after a version change,) then cleared the app cache and storage. Somehow everything seems to be working properly for downloaded books now. The real test will be when I get back in to my car for android auto, as that's when it's at its worst.

Things were fine for a while, but now it's back to freezing my phone for a while after I click play on local media (crashing in the worst case scenario.) I didn't change any versions or settings since it was working. I tried clearing the app storage/cache and signing in and downloading a book again, but that didn't fix anything this time.

@gazpachoking commented on GitHub (Aug 23, 2023): > I cleared my audiobook download folder (because it never matches already downloaded things to the server items after a version change,) then cleared the app cache and storage. Somehow everything seems to be working properly for downloaded books now. The real test will be when I get back in to my car for android auto, as that's when it's at its worst. Things were fine for a while, but now it's back to freezing my phone for a while after I click play on local media (crashing in the worst case scenario.) I didn't change any versions or settings since it was working. I tried clearing the app storage/cache and signing in and downloading a book again, but that didn't fix anything this time.
Author
Owner

@gazpachoking commented on GitHub (Oct 7, 2023):

Still having this issue on 0.9.66. The book will play okay while the screen is on, but the 'audiobookshelf isn't responding' keeps popping up, making the phone unusable. If the screen is asleep, audiobookshelf gets killed and the book stops playing.

@gazpachoking commented on GitHub (Oct 7, 2023): Still having this issue on 0.9.66. The book will play okay while the screen is on, but the 'audiobookshelf isn't responding' keeps popping up, making the phone unusable. If the screen is asleep, audiobookshelf gets killed and the book stops playing.
Author
Owner

@sandreas commented on GitHub (Nov 18, 2023):

@advplyr I have the exact same behaviour on some other apps too. Seems to be a problem with battery settings and android permissions, the app has to request BackgroundService permission to prevent it.

Maybe this helps. An app that works and is open source: https://github.com/PaulWoitaschek/Voice
The app itself is not designed for me personally, but at least the background playback works.

@sandreas commented on GitHub (Nov 18, 2023): @advplyr I have the exact same behaviour on some other apps too. Seems to be a problem with battery settings and android permissions, the app has to request BackgroundService permission to prevent it. Maybe this helps. An app that works and is open source: https://github.com/PaulWoitaschek/Voice The app itself is not designed for me personally, but at least the background playback works.
Author
Owner

@advplyr commented on GitHub (Nov 18, 2023):

@sandreas Thanks, I've had this stackoverflow post bookmarked for a while now because it explains the issue well: https://stackoverflow.com/questions/69604951/getting-android-app-foregroundservicestartnotallowedexception-in-android-12-sdk

That exception is the one that is thrown

@advplyr commented on GitHub (Nov 18, 2023): @sandreas Thanks, I've had this stackoverflow post bookmarked for a while now because it explains the issue well: https://stackoverflow.com/questions/69604951/getting-android-app-foregroundservicestartnotallowedexception-in-android-12-sdk That exception is the one that is thrown
Author
Owner

@advplyr commented on GitHub (Nov 18, 2023):

Notice that they say one way to prevent this from happening is to disable battery optimization:

The user turns off battery optimizations for your app. You can help users find this option by sending them to your app's App info page in system settings. To do so, invoke an intent that contains the ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS intent action.

This works for most cases. I would rather do it correctly like they explain in the post but I haven't dug into it yet, it is a lot of work it seems like.

@advplyr commented on GitHub (Nov 18, 2023): Notice that they say one way to prevent this from happening is to disable battery optimization: ``` The user turns off battery optimizations for your app. You can help users find this option by sending them to your app's App info page in system settings. To do so, invoke an intent that contains the ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS intent action. ``` This works for most cases. I would rather do it correctly like they explain in the post but I haven't dug into it yet, it is a lot of work it seems like.
Author
Owner

@mihailim commented on GitHub (Nov 18, 2023):

It seems there are multiple causes manifesting in a similar way -- back when I could reliably reproduce the problem, the application battery usage was set to Unrestricted. That helped, in the sense that it significantly reduced the occurrence of the problem from multiple times per hour of playback to once every few hours, but it didn't eliminate it completely.

@mihailim commented on GitHub (Nov 18, 2023): It seems there are multiple causes manifesting in a similar way -- back when I could reliably reproduce the problem, the application battery usage was set to Unrestricted. That helped, in the sense that it significantly reduced the occurrence of the problem from multiple times per hour of playback to once every few hours, but it didn't eliminate it completely.
Author
Owner

@advplyr commented on GitHub (Nov 18, 2023):

@mihailim Yeah I think there was an issue with media downloaded prior to the db switch in server v2.2.23

@advplyr commented on GitHub (Nov 18, 2023): @mihailim Yeah I think there was an issue with media downloaded prior to the db switch in server v2.2.23
Author
Owner

@sandreas commented on GitHub (Nov 19, 2023):

Here is a little more detail about Background-Services on Android. It's for flutter, but I personally find it useful:

https://suragch.medium.com/background-audio-in-flutter-with-audio-service-and-just-audio-3cce17b4a7d

Here is an example manifest file: https://github.com/suragch/flutter_audio_service_demo/blob/master/final/android/app/src/main/AndroidManifest.xml

Here are the most important parts:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="dev.suragch.flutter_audio_service_demo">
    <application
        android:label="flutter_audio_service_demo"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- ... -->
   <service 
            android:name="com.ryanheise.audioservice.AudioService"
            android:foregroundServiceType="mediaPlayback"
            android:exported="true" 
            tools:ignore="Instantiatable">
          <intent-filter>
            <action android:name="android.media.browse.MediaBrowserService" />
          </intent-filter>
        </service>
        <receiver 
            android:name="com.ryanheise.audioservice.MediaButtonReceiver"
            android:exported="true" 
            tools:ignore="Instantiatable">
          <intent-filter>
            <action android:name="android.intent.action.MEDIA_BUTTON" />
          </intent-filter>
        </receiver> 
<!-- ... --->
</manifest>
@sandreas commented on GitHub (Nov 19, 2023): Here is a little more detail about Background-Services on Android. It's for flutter, but I personally find it useful: https://suragch.medium.com/background-audio-in-flutter-with-audio-service-and-just-audio-3cce17b4a7d Here is an example manifest file: https://github.com/suragch/flutter_audio_service_demo/blob/master/final/android/app/src/main/AndroidManifest.xml Here are the most important parts: ```xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="dev.suragch.flutter_audio_service_demo"> <application android:label="flutter_audio_service_demo" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.INTERNET" /> <!-- ... --> <service android:name="com.ryanheise.audioservice.AudioService" android:foregroundServiceType="mediaPlayback" android:exported="true" tools:ignore="Instantiatable"> <intent-filter> <action android:name="android.media.browse.MediaBrowserService" /> </intent-filter> </service> <receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" android:exported="true" tools:ignore="Instantiatable"> <intent-filter> <action android:name="android.intent.action.MEDIA_BUTTON" /> </intent-filter> </receiver> <!-- ... ---> </manifest> ```
Author
Owner

@shvnrg commented on GitHub (Dec 7, 2023):

I had this problem too for a while now and experimented a little bit.

Could anyone with the problem try to download the media to internal app storage?
It looks like this solved the problem for me:
External Folder Library: stutter and then force close
Internal Storage: no problems

Pixel 4a, Android 13, Full Stock, Server v2.6.0, App v0.9.68-beta

@shvnrg commented on GitHub (Dec 7, 2023): I had this problem too for a while now and experimented a little bit. Could anyone with the problem try to download the media to **internal app storage**? It looks like this solved the problem for me: External Folder Library: stutter and then force close Internal Storage: no problems Pixel 4a, Android 13, Full Stock, Server v2.6.0, App v0.9.68-beta
Author
Owner

@sandreas commented on GitHub (Dec 7, 2023):

Could anyone with the problem try to download the media to internal app storage?

Thank you for your effort, but this does not work for me. And I'd like to mention, that even if it had worked, it would not have solved the problem. My internal storage is just not big enough for the audio books I use.

I have tested several offline media player apps and used the audiobookshelf download folder as source. Some of them did show the same issue, some of them worked like a charm (mostly the trials of commercial ones). I think getting this to work may be complex task, but it has to do with adding the correct permissions into the manifest and then requesting a media session the correct way.

android.permission.WAKE_LOCK
android.permission.FOREGROUND_SERVICE
android.permission.INTERNET

In addition you can allow interactions via media button by adding a <receiver> class implementing the according interface, which will result in supporting media buttons and cable headphone remotes.

<receiver 
            android:name="com.ryanheise.audioservice.MediaButtonReceiver"
            android:exported="true" 
            tools:ignore="Instantiatable">
          <intent-filter>
            <action android:name="android.intent.action.MEDIA_BUTTON" />
          </intent-filter>
        </receiver> 

This is definitely a problem in how audiobookshelf-app is implemented and not something that can be solved completely by tinkering with the android settings.

Here I summarized everything I found and the test project (written in flutter) works like a charm on my device (I modified it to use a valid audiobookshelf source and tested it for more than 2 hours of listening).

@sandreas commented on GitHub (Dec 7, 2023): > Could anyone with the problem try to download the media to internal app storage? Thank you for your effort, but this does not work for me. And I'd like to mention, that even if it had worked, it would not have solved the problem. My internal storage is just not big enough for the audio books I use. I have tested several offline media player apps and used the audiobookshelf download folder as source. Some of them did show the same issue, some of them worked like a charm (mostly the trials of commercial ones). I think getting this to work may be complex task, but it has to do with adding the correct permissions into the manifest and then requesting a media session the correct way. ``` android.permission.WAKE_LOCK android.permission.FOREGROUND_SERVICE android.permission.INTERNET ``` In addition you can allow interactions via media button by adding a `<receiver>` class implementing the according interface, which will result in supporting media buttons and cable headphone remotes. ``` <receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" android:exported="true" tools:ignore="Instantiatable"> <intent-filter> <action android:name="android.intent.action.MEDIA_BUTTON" /> </intent-filter> </receiver> ``` This is definitely a problem in how audiobookshelf-app is implemented and not something that can be solved completely by tinkering with the android settings. [Here](https://github.com/advplyr/audiobookshelf-app/issues/773#issuecomment-1817887883) I summarized everything I found and the test project (written in flutter) works like a charm on my device (I modified it to use a valid audiobookshelf source and tested it for more than 2 hours of listening).
Author
Owner

@advplyr commented on GitHub (Dec 7, 2023):

@sandreas What android version and device are you using? I know Android 10 and below will have permission issues when not using internal storage.

@advplyr commented on GitHub (Dec 7, 2023): @sandreas What android version and device are you using? I know Android 10 and below will have permission issues when not using internal storage.
Author
Owner

@sandreas commented on GitHub (Dec 7, 2023):

What android version and device are you using? I know Android 10 and below will have permission issues when not using internal storage.

@advplyr
Android 12 on Unihertz Jelly 2e

Edit:

In https://github.com/advplyr/audiobookshelf-app/blob/master/android/app/src/main/AndroidManifest.xml I don't see the android.permission.WAKE_LOCK. Is this added programmatically?

@sandreas commented on GitHub (Dec 7, 2023): > What android version and device are you using? I know Android 10 and below will have permission issues when not using internal storage. @advplyr Android 12 on Unihertz Jelly 2e Edit: In https://github.com/advplyr/audiobookshelf-app/blob/master/android/app/src/main/AndroidManifest.xml I don't see the `android.permission.WAKE_LOCK`. Is this added programmatically?
Author
Owner

@Salvoxia commented on GitHub (Dec 11, 2023):

I also have crashing problems where the app gets killed randomly when playing. Sometimes after a couple of seconds, sometimes it runs for half an hour.
App version is 0.9.68-beta on Anrdoid 13.
Only seems to be happening for certain audio books, but I was not yet able to find a significant difference between ones that work and ones that don't.
I was now able to record such a crash with adb logcat | grep audiobookshelf. It seems like the Low Memory Killer Daemon simply kills off ABS due to "high memory pressure". See the logs at timestamp 12-11 20:47:42.284:

12-11 20:46:51.522  2426  2426 D FaceWidgetSeekBarViewModel_1: [registerCallback] :: {com.audiobookshelf.app}, android.media.session.MediaController@de92c61
12-11 20:46:52.483  1429  2669 D SGM:GameManager: identifyForegroundApp. com.audiobookshelf.app, mCurrentUserId: 0, callerUserId: 0
12-11 20:46:52.483  1429  2669 D SGM:PkgDataHelper: getGamePkgData(). com.audiobookshelf.app
12-11 20:47:06.472  6348  6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local
12-11 20:47:21.456  6348  6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local
12-11 20:47:36.457  6348  6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local
12-11 20:47:39.365  1429  2667 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.audiobookshelf.app,userId = 0
12-11 20:47:39.366  1429  2667 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.audiobookshelf.app,userId = 0
12-11 20:47:39.386 10839 10839 I Edge.badge: updateBadge item = com.audiobookshelf.app:0 1
12-11 20:47:39.388 17001 17001 I Launcher.NotificationListener: onNotificationPosted : com.audiobookshelf.app number : 0
12-11 20:47:39.398  2426  2426 D MediaDataManager: onMediaNotificationAdded() : 0|com.audiobookshelf.app|10|null|10478
12-11 20:47:39.398  2426  2426 D MediaLogger: Notification added [0|com.audiobookshelf.app|10|null|10478]
12-11 20:47:39.398  2426  2426 D BubblesManager: onEntryUpdated : shouldBubbleUp=true ,key=0|com.audiobookshelf.app|10|null|10478
12-11 20:47:39.400  2426  2498 W Bubbles : Unable to create bubble -- no intent: 0|com.audiobookshelf.app|10|null|10478
12-11 20:47:39.407  2426  2426 D InterruptionStateProvider:  no Heads up : edgelighting enabled app. 0|com.audiobookshelf.app|10|null|10478
12-11 20:47:39.672  2804  2804 V AvrcpMediaPlayerWrapper: onQueueChanged(): com.audiobookshelf.app
12-11 20:47:39.710  2804  2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app
12-11 20:47:39.712  2804  2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app : PlaybackState {state=PLAYING(3), position=99842, buffered position=172567, speed=1.0, updated=443779135, actions=102223, custom actions=[Action:mName='Jump Backward, mIcon=2131230945, mExtras=null, Action:mName='Jump Forward, mIcon=2131230934, mExtras=null, Action:mName='Change Playback Speed, mIcon=2131231176, mExtras=Bundle[mParcelledData.dataSize=28], Action:mName='Skip Backward, mIcon=2131231309, mExtras=null, Action:mName='Skip Forward, mIcon=2131231308, mExtras=null], active item id=254, error=null}
12-11 20:47:39.712  2804  2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app : PlaybackState {state=PLAYING(3), position=99842, buffered position=172567, speed=1.0, updated=443779135, actions=102223, custom actions=[Action:mName='Jump Backward, mIcon=2131230945, mExtras=null, Action:mName='Jump Forward, mIcon=2131230934, mExtras=null, Action:mName='Change Playback Speed, mIcon=2131231176, mExtras=Bundle[mParcelledData.dataSize=28], Action:mName='Skip Backward, mIcon=2131231309, mExtras=null, Action:mName='Skip Forward, mIcon=2131231308, mExtras=null], active item id=254, error=null}
12-11 20:47:39.716  2804  2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app
12-11 20:47:39.723  2804  2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app
12-11 20:47:40.092  2426  2426 D MediaLogger: Media data loaded key[0|com.audiobookshelf.app|10|null|10478] oldKey[0|com.audiobookshelf.app|10|null|10478] title[Slee] isActive[true]
12-11 20:47:40.101  2426  2426 D MediaLogger: Media player updated [0|com.audiobookshelf.app|10|null|10478] isPlaying[true]
12-11 20:47:40.126  2426  2426 D FaceWidgetNotificationControllerWrapper: onMediaDataLoaded, 0|com.audiobookshelf.app|10|null|10478, 0|com.audiobookshelf.app|10|null|10478, MediaData(userId=0, initialized=true, app=Audiobookshelf, appIcon=Icon(typ=RESOURCE pkg=com.audiobookshelf.app id=0x7f0801de), artist=Stephen King, Owen King, song=Sleeping Beauties, artwork=Icon(typ=BITMAP size=2400x2400), actions=[MediaAction(icon=android.graphics.drawable.VectorDrawable@e420f49, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@e3ef04e, contentDescription=Change Playback Speed, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@3e20b13, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@a50b150, contentDescription=Jump Backward, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.AnimatedVectorDrawable@dbb4876, action=com.android.systemui.media.MediaDataManager$getStandardAction$2@a15fe77, contentDescription=Pausieren, background=android.graphics.drawable.AnimatedVectorDrawable@5efcae4, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@7430b4d, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@f8b7602, contentDescription=Jump Forward, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@858456f, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@597927c, contentDescription=Skip Backward, background=null, rebindId=null)], actionsToShowInCompact=[1, 2, 3], semanticActions=MediaButton(playOrPause=MediaAction(icon=android.graphics.drawable.AnimatedVectorDrawable@dbb4876, action=com.android.systemui.media.MediaDataManager$getStandardAction$2@a15fe77, contentDescription=Pausieren, background=android.graphics.drawable.AnimatedVectorDrawable@5efcae4, rebindId=null), nextOrCustom=MediaAction(icon=android.graphics.drawable.VectorDrawable@7430b4d, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@f8b7602, contentDescription=Jump Forward, background=null, rebindId=null), prevOrCustom=MediaAction(icon=android.graphics.drawable.VectorDrawable@3e20b13, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@a50b150, contentDescription=Jump Backward, background=null, rebindId=null), custom0=MediaAction(icon=android.graphics.drawable.VectorDrawable@e420f49, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@e3ef04e, contentDescription=Change Playback Speed, background=null, rebindId=null), custom1=MediaAction(icon=android.graphics.drawable.VectorDrawable@858456f, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@597927c, contentDescription=Skip Backward, background=null, rebindId=null), reserveNext=false, reservePrev=false), packageName=com.audiobookshelf.app, token=android.media.session.MediaSession$Token@e2f3594, clickIntent=PendingIntent{38ad92e: android.os.BinderProxy@8cd55ac}, device=MediaDeviceData(enabled=true, icon=0.0,0.0-120.0,120.0
12-11 20:47:40.126  2426  2426 D FaceWidgetNotificationControllerWrapper: Attribute:2, name=Dieses Telefon, intent=null, id=remote_submix_media_device_id, customMediaDeviceData=SecMediaDeviceDataImpl(deviceType=1)), active=true, resumeAction=null, playbackLocation=0, resumption=false, notificationKey=0|com.audiobookshelf.app|10|null|10478, hasCheckedForResume=true, isPlaying=true, isClearable=false, lastActive=443780661, instanceId=com.android.internal.logging.InstanceId@16d3, appUid=10478, customMediaData=SecMediaDataImpl(uid=10478))
12-11 20:47:40.127  2426  2426 D FaceWidgetMediaDataRepository: [update] key : 0|com.audiobookshelf.app|10|null|10478, oldKey : 0|com.audiobookshelf.app|10|null|10478, media : com.audiobookshelf.app, sourceType : NOTIFICATION
12-11 20:47:40.148  2426  2426 D FaceWidgetMusicViewModel: onChanged :: PluginFaceWidgetMediaData{packageName='com.audiobookshelf.app'isActive='true', playbackState=3', metaData=Sleeping Beauties, null, null', (APP ICON, ALBUM_ART)'}
12-11 20:47:42.284   500   500 I lmkd    : Reclaim 'com.audiobookshelf.app' (6348), uid 10478, oom_score_adj 200, state 4 to free 307332kB rss, 60344kB swap; reason: min2x watermark is breached even after kill
12-11 20:47:42.284  1429  1537 I ActivityManager_KPM: calculateLmkdStatus currentProcess Killed com.audiobookshelf.app_200
12-11 20:47:42.383  2804  2804 V AvrcpMediaPlayerWrapper: onQueueChanged(): com.audiobookshelf.app
12-11 20:47:42.413  1429  2669 I ActivityManager: Process com.audiobookshelf.app (pid 6348) has died: prcp FGS (175,3196)
12-11 20:47:42.414  1429  3954 I WindowManager: WIN DEATH: Window{5545990 u0 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity}
12-11 20:47:42.416  1429  2293 D ConnectivityService: releasing NetworkRequest [ REQUEST id=7128, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10478 RequestorUid: 10478 RequestorPkg: com.audiobookshelf.app UnderlyingNetworks: Null] ] (release request)
12-11 20:47:42.439  1429  3954 W InputManager-JNI: Input channel object '5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity (client)' was disposed without first being removed with the input manager!
12-11 20:47:42.449  2804  2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app
12-11 20:47:42.451  2804  2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app tried to update with no queue
12-11 20:47:42.452  2804  2804 I AvrcpMediaPlayerList: onMediaKeyEventSessionChanged: packageName=com.audiobookshelf.app
12-11 20:47:42.452  2804  2804 W AvrcpMediaPlayerList: com.audiobookshelf.app is already the active player
12-11 20:47:42.453  2804  2804 W AvrcpMediaPlayerWrapper: The session was destroyed com.audiobookshelf.app
12-11 20:47:42.454  2804  2804 D AvrcpMediaPlayerList: sessionUpdatedCallback(): packageName: com.audiobookshelf.app
12-11 20:47:42.462  1429  3954 V WindowManager: Remove Window{5545990 u0 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity}: mSurfaceController=null mAnimatingExit=false mRemoveOnExit=false mHasSurface=false surfaceShowing=false animating=false app-animation=false mWillReplaceWindow=false mDisplayFrozen=false callers=com.android.server.wm.WindowState.-$$Nest$mremoveIfPossible:0 com.android.server.wm.WindowState$DeathRecipient.binderDied:3808 android.os.IBinder$DeathRecipient.binderDied:323 android.os.BinderProxy.sendDeathNotice:781 <bottom of call stack> <bottom of call stack>
12-11 20:47:42.503  1111  1111 I Layer   : id=24765 removeFromCurrentState 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765 (199)
12-11 20:47:42.503  1111  1111 I SurfaceFlinger: id=24765 Removed 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765 (199)
12-11 20:47:42.504  1111  1111 I Layer   : id=24765 Destroyed 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765
12-11 20:47:42.564  1429  2669 W ActivityManager: Exception when unbinding service com.audiobookshelf.app/org.chromium.content.app.SandboxedProcessService0:2
12-11 20:47:42.579  1429  2669 W ActivityManager: Scheduling restart of crashed service com.audiobookshelf.app/.player.PlayerNotificationService in 109634ms for start-requested
12-11 20:47:42.593  1429  1429 D EdgeLightingManager: hideForNotification : packageName = com.audiobookshelf.app
12-11 20:47:42.594  1429  1429 D EdgeLightingPolicyManager:NotificationGroup: remove : sbn : StatusBarNotification(pkg=com.audiobookshelf.app user=UserHandle{0} id=10 tag=null key=0|com.audiobookshelf.app|10|null|10478: Notification(channel=audiobookshelf_channel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x6a color=0x00000000 category=transport actions=3 vis=PUBLIC semFlags=0x0 semPriority=0 semMissedCount=0))
12-11 20:47:42.600  1429  1429 D EdgeLightingPolicyManager: isAcceptableApplication:  pkg=com.audiobookshelf.app , range=1 , includeAllApp=false , userId=0 , infoRange=0 , infoCategory=0
12-11 20:47:42.601  1429  1429 D EdgeLightingManager: hideEdgeLightingInternal : packageName = com.audiobookshelf.app, reason=1
12-11 20:47:42.601  1429  1429 E EdgeLightingClientManager: stopEdgeLightingInternal mHosts is null. pkg=com.audiobookshelf.app,reason=1
12-11 20:47:42.631  1429  1429 D NotificationReminder: removeFromNotiList record com.audiobookshelf.app
12-11 20:47:42.652  1429  1534 W UsageStatsService: Unexpected activity event reported! (com.audiobookshelf.app/com.audiobookshelf.app.MainActivity event : 23 instanceId : 138762803)
12-11 20:47:42.727  2426  2426 D MediaLogger: Notification removed [0|com.audiobookshelf.app|10|null|10478]
12-11 20:47:42.750  2426  2426 D MediaLogger: Media data removed [0|com.audiobookshelf.app|10|null|10478]
12-11 20:47:42.800  2426  2426 D MediaLogger: Media player removed [0|com.audiobookshelf.app|10|null|10478]
12-11 20:47:42.829  2426  2426 D FaceWidgetNotificationControllerWrapper: onMediaDataRemoved, 0|com.audiobookshelf.app|10|null|10478
12-11 20:47:42.834  2426  2426 D FaceWidgetMediaDataRepository: [remove] key : 0|com.audiobookshelf.app|10|null|10478, sourceType : NOTIFICATION
12-11 20:47:42.887  2426  2426 D FaceWidgetSeekBarViewModel_1: [unregisterCallback] :: {com.audiobookshelf.app}, android.media.session.MediaController@de92c61
12-11 20:47:50.909  1429  1534 W ActivityManager: Rescheduling restart of crashed service com.audiobookshelf.app/.player.PlayerNotificationService in 0ms for mem-pressure-event

Not sure if this is related to what other people have described in this thread, symptoms seem to be similar to some reports, not to others.
When checking, my phone usually has about 3GB memory left (total 8GB), even with ABS running and playing.
I'm happy to provide more data, if guided.

@Salvoxia commented on GitHub (Dec 11, 2023): I also have crashing problems where the app gets killed randomly when playing. Sometimes after a couple of seconds, sometimes it runs for half an hour. App version is 0.9.68-beta on Anrdoid 13. Only seems to be happening for certain audio books, but I was not yet able to find a significant difference between ones that work and ones that don't. I was now able to record such a crash with `adb logcat | grep audiobookshelf`. It seems like the Low Memory Killer Daemon simply kills off ABS due to "high memory pressure". See the logs at timestamp `12-11 20:47:42.284`: ``` 12-11 20:46:51.522 2426 2426 D FaceWidgetSeekBarViewModel_1: [registerCallback] :: {com.audiobookshelf.app}, android.media.session.MediaController@de92c61 12-11 20:46:52.483 1429 2669 D SGM:GameManager: identifyForegroundApp. com.audiobookshelf.app, mCurrentUserId: 0, callerUserId: 0 12-11 20:46:52.483 1429 2669 D SGM:PkgDataHelper: getGamePkgData(). com.audiobookshelf.app 12-11 20:47:06.472 6348 6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local 12-11 20:47:21.456 6348 6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local 12-11 20:47:36.457 6348 6348 D ApiHandler: postRequest to https://audiobookshelf.mydomain.com/api/session/local 12-11 20:47:39.365 1429 2667 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.audiobookshelf.app,userId = 0 12-11 20:47:39.366 1429 2667 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.audiobookshelf.app,userId = 0 12-11 20:47:39.386 10839 10839 I Edge.badge: updateBadge item = com.audiobookshelf.app:0 1 12-11 20:47:39.388 17001 17001 I Launcher.NotificationListener: onNotificationPosted : com.audiobookshelf.app number : 0 12-11 20:47:39.398 2426 2426 D MediaDataManager: onMediaNotificationAdded() : 0|com.audiobookshelf.app|10|null|10478 12-11 20:47:39.398 2426 2426 D MediaLogger: Notification added [0|com.audiobookshelf.app|10|null|10478] 12-11 20:47:39.398 2426 2426 D BubblesManager: onEntryUpdated : shouldBubbleUp=true ,key=0|com.audiobookshelf.app|10|null|10478 12-11 20:47:39.400 2426 2498 W Bubbles : Unable to create bubble -- no intent: 0|com.audiobookshelf.app|10|null|10478 12-11 20:47:39.407 2426 2426 D InterruptionStateProvider: no Heads up : edgelighting enabled app. 0|com.audiobookshelf.app|10|null|10478 12-11 20:47:39.672 2804 2804 V AvrcpMediaPlayerWrapper: onQueueChanged(): com.audiobookshelf.app 12-11 20:47:39.710 2804 2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app 12-11 20:47:39.712 2804 2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app : PlaybackState {state=PLAYING(3), position=99842, buffered position=172567, speed=1.0, updated=443779135, actions=102223, custom actions=[Action:mName='Jump Backward, mIcon=2131230945, mExtras=null, Action:mName='Jump Forward, mIcon=2131230934, mExtras=null, Action:mName='Change Playback Speed, mIcon=2131231176, mExtras=Bundle[mParcelledData.dataSize=28], Action:mName='Skip Backward, mIcon=2131231309, mExtras=null, Action:mName='Skip Forward, mIcon=2131231308, mExtras=null], active item id=254, error=null} 12-11 20:47:39.712 2804 2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app : PlaybackState {state=PLAYING(3), position=99842, buffered position=172567, speed=1.0, updated=443779135, actions=102223, custom actions=[Action:mName='Jump Backward, mIcon=2131230945, mExtras=null, Action:mName='Jump Forward, mIcon=2131230934, mExtras=null, Action:mName='Change Playback Speed, mIcon=2131231176, mExtras=Bundle[mParcelledData.dataSize=28], Action:mName='Skip Backward, mIcon=2131231309, mExtras=null, Action:mName='Skip Forward, mIcon=2131231308, mExtras=null], active item id=254, error=null} 12-11 20:47:39.716 2804 2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app 12-11 20:47:39.723 2804 2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app 12-11 20:47:40.092 2426 2426 D MediaLogger: Media data loaded key[0|com.audiobookshelf.app|10|null|10478] oldKey[0|com.audiobookshelf.app|10|null|10478] title[Slee] isActive[true] 12-11 20:47:40.101 2426 2426 D MediaLogger: Media player updated [0|com.audiobookshelf.app|10|null|10478] isPlaying[true] 12-11 20:47:40.126 2426 2426 D FaceWidgetNotificationControllerWrapper: onMediaDataLoaded, 0|com.audiobookshelf.app|10|null|10478, 0|com.audiobookshelf.app|10|null|10478, MediaData(userId=0, initialized=true, app=Audiobookshelf, appIcon=Icon(typ=RESOURCE pkg=com.audiobookshelf.app id=0x7f0801de), artist=Stephen King, Owen King, song=Sleeping Beauties, artwork=Icon(typ=BITMAP size=2400x2400), actions=[MediaAction(icon=android.graphics.drawable.VectorDrawable@e420f49, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@e3ef04e, contentDescription=Change Playback Speed, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@3e20b13, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@a50b150, contentDescription=Jump Backward, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.AnimatedVectorDrawable@dbb4876, action=com.android.systemui.media.MediaDataManager$getStandardAction$2@a15fe77, contentDescription=Pausieren, background=android.graphics.drawable.AnimatedVectorDrawable@5efcae4, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@7430b4d, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@f8b7602, contentDescription=Jump Forward, background=null, rebindId=null), MediaAction(icon=android.graphics.drawable.VectorDrawable@858456f, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@597927c, contentDescription=Skip Backward, background=null, rebindId=null)], actionsToShowInCompact=[1, 2, 3], semanticActions=MediaButton(playOrPause=MediaAction(icon=android.graphics.drawable.AnimatedVectorDrawable@dbb4876, action=com.android.systemui.media.MediaDataManager$getStandardAction$2@a15fe77, contentDescription=Pausieren, background=android.graphics.drawable.AnimatedVectorDrawable@5efcae4, rebindId=null), nextOrCustom=MediaAction(icon=android.graphics.drawable.VectorDrawable@7430b4d, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@f8b7602, contentDescription=Jump Forward, background=null, rebindId=null), prevOrCustom=MediaAction(icon=android.graphics.drawable.VectorDrawable@3e20b13, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@a50b150, contentDescription=Jump Backward, background=null, rebindId=null), custom0=MediaAction(icon=android.graphics.drawable.VectorDrawable@e420f49, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@e3ef04e, contentDescription=Change Playback Speed, background=null, rebindId=null), custom1=MediaAction(icon=android.graphics.drawable.VectorDrawable@858456f, action=com.android.systemui.media.MediaDataManager$getCustomAction$1@597927c, contentDescription=Skip Backward, background=null, rebindId=null), reserveNext=false, reservePrev=false), packageName=com.audiobookshelf.app, token=android.media.session.MediaSession$Token@e2f3594, clickIntent=PendingIntent{38ad92e: android.os.BinderProxy@8cd55ac}, device=MediaDeviceData(enabled=true, icon=0.0,0.0-120.0,120.0 12-11 20:47:40.126 2426 2426 D FaceWidgetNotificationControllerWrapper: Attribute:2, name=Dieses Telefon, intent=null, id=remote_submix_media_device_id, customMediaDeviceData=SecMediaDeviceDataImpl(deviceType=1)), active=true, resumeAction=null, playbackLocation=0, resumption=false, notificationKey=0|com.audiobookshelf.app|10|null|10478, hasCheckedForResume=true, isPlaying=true, isClearable=false, lastActive=443780661, instanceId=com.android.internal.logging.InstanceId@16d3, appUid=10478, customMediaData=SecMediaDataImpl(uid=10478)) 12-11 20:47:40.127 2426 2426 D FaceWidgetMediaDataRepository: [update] key : 0|com.audiobookshelf.app|10|null|10478, oldKey : 0|com.audiobookshelf.app|10|null|10478, media : com.audiobookshelf.app, sourceType : NOTIFICATION 12-11 20:47:40.148 2426 2426 D FaceWidgetMusicViewModel: onChanged :: PluginFaceWidgetMediaData{packageName='com.audiobookshelf.app'isActive='true', playbackState=3', metaData=Sleeping Beauties, null, null', (APP ICON, ALBUM_ART)'} 12-11 20:47:42.284 500 500 I lmkd : Reclaim 'com.audiobookshelf.app' (6348), uid 10478, oom_score_adj 200, state 4 to free 307332kB rss, 60344kB swap; reason: min2x watermark is breached even after kill 12-11 20:47:42.284 1429 1537 I ActivityManager_KPM: calculateLmkdStatus currentProcess Killed com.audiobookshelf.app_200 12-11 20:47:42.383 2804 2804 V AvrcpMediaPlayerWrapper: onQueueChanged(): com.audiobookshelf.app 12-11 20:47:42.413 1429 2669 I ActivityManager: Process com.audiobookshelf.app (pid 6348) has died: prcp FGS (175,3196) 12-11 20:47:42.414 1429 3954 I WindowManager: WIN DEATH: Window{5545990 u0 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity} 12-11 20:47:42.416 1429 2293 D ConnectivityService: releasing NetworkRequest [ REQUEST id=7128, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10478 RequestorUid: 10478 RequestorPkg: com.audiobookshelf.app UnderlyingNetworks: Null] ] (release request) 12-11 20:47:42.439 1429 3954 W InputManager-JNI: Input channel object '5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity (client)' was disposed without first being removed with the input manager! 12-11 20:47:42.449 2804 2804 V AvrcpMediaPlayerWrapper: sendMediaUpdate(): Metadata has been updated for com.audiobookshelf.app 12-11 20:47:42.451 2804 2804 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.audiobookshelf.app tried to update with no queue 12-11 20:47:42.452 2804 2804 I AvrcpMediaPlayerList: onMediaKeyEventSessionChanged: packageName=com.audiobookshelf.app 12-11 20:47:42.452 2804 2804 W AvrcpMediaPlayerList: com.audiobookshelf.app is already the active player 12-11 20:47:42.453 2804 2804 W AvrcpMediaPlayerWrapper: The session was destroyed com.audiobookshelf.app 12-11 20:47:42.454 2804 2804 D AvrcpMediaPlayerList: sessionUpdatedCallback(): packageName: com.audiobookshelf.app 12-11 20:47:42.462 1429 3954 V WindowManager: Remove Window{5545990 u0 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity}: mSurfaceController=null mAnimatingExit=false mRemoveOnExit=false mHasSurface=false surfaceShowing=false animating=false app-animation=false mWillReplaceWindow=false mDisplayFrozen=false callers=com.android.server.wm.WindowState.-$$Nest$mremoveIfPossible:0 com.android.server.wm.WindowState$DeathRecipient.binderDied:3808 android.os.IBinder$DeathRecipient.binderDied:323 android.os.BinderProxy.sendDeathNotice:781 <bottom of call stack> <bottom of call stack> 12-11 20:47:42.503 1111 1111 I Layer : id=24765 removeFromCurrentState 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765 (199) 12-11 20:47:42.503 1111 1111 I SurfaceFlinger: id=24765 Removed 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765 (199) 12-11 20:47:42.504 1111 1111 I Layer : id=24765 Destroyed 5545990 com.audiobookshelf.app/com.audiobookshelf.app.MainActivity#24765 12-11 20:47:42.564 1429 2669 W ActivityManager: Exception when unbinding service com.audiobookshelf.app/org.chromium.content.app.SandboxedProcessService0:2 12-11 20:47:42.579 1429 2669 W ActivityManager: Scheduling restart of crashed service com.audiobookshelf.app/.player.PlayerNotificationService in 109634ms for start-requested 12-11 20:47:42.593 1429 1429 D EdgeLightingManager: hideForNotification : packageName = com.audiobookshelf.app 12-11 20:47:42.594 1429 1429 D EdgeLightingPolicyManager:NotificationGroup: remove : sbn : StatusBarNotification(pkg=com.audiobookshelf.app user=UserHandle{0} id=10 tag=null key=0|com.audiobookshelf.app|10|null|10478: Notification(channel=audiobookshelf_channel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x6a color=0x00000000 category=transport actions=3 vis=PUBLIC semFlags=0x0 semPriority=0 semMissedCount=0)) 12-11 20:47:42.600 1429 1429 D EdgeLightingPolicyManager: isAcceptableApplication: pkg=com.audiobookshelf.app , range=1 , includeAllApp=false , userId=0 , infoRange=0 , infoCategory=0 12-11 20:47:42.601 1429 1429 D EdgeLightingManager: hideEdgeLightingInternal : packageName = com.audiobookshelf.app, reason=1 12-11 20:47:42.601 1429 1429 E EdgeLightingClientManager: stopEdgeLightingInternal mHosts is null. pkg=com.audiobookshelf.app,reason=1 12-11 20:47:42.631 1429 1429 D NotificationReminder: removeFromNotiList record com.audiobookshelf.app 12-11 20:47:42.652 1429 1534 W UsageStatsService: Unexpected activity event reported! (com.audiobookshelf.app/com.audiobookshelf.app.MainActivity event : 23 instanceId : 138762803) 12-11 20:47:42.727 2426 2426 D MediaLogger: Notification removed [0|com.audiobookshelf.app|10|null|10478] 12-11 20:47:42.750 2426 2426 D MediaLogger: Media data removed [0|com.audiobookshelf.app|10|null|10478] 12-11 20:47:42.800 2426 2426 D MediaLogger: Media player removed [0|com.audiobookshelf.app|10|null|10478] 12-11 20:47:42.829 2426 2426 D FaceWidgetNotificationControllerWrapper: onMediaDataRemoved, 0|com.audiobookshelf.app|10|null|10478 12-11 20:47:42.834 2426 2426 D FaceWidgetMediaDataRepository: [remove] key : 0|com.audiobookshelf.app|10|null|10478, sourceType : NOTIFICATION 12-11 20:47:42.887 2426 2426 D FaceWidgetSeekBarViewModel_1: [unregisterCallback] :: {com.audiobookshelf.app}, android.media.session.MediaController@de92c61 12-11 20:47:50.909 1429 1534 W ActivityManager: Rescheduling restart of crashed service com.audiobookshelf.app/.player.PlayerNotificationService in 0ms for mem-pressure-event ``` Not sure if this is related to what other people have described in this thread, symptoms seem to be similar to some reports, not to others. When checking, my phone usually has about 3GB memory left (total 8GB), even with ABS running and playing. I'm happy to provide more data, if guided.
Author
Owner

@7h3ju57 commented on GitHub (Dec 23, 2023):

I'm getting the same issue.
I always download my books and experiencing the following issues.
Start the book, it starts but I have to make sure to wait for the playback bar to show up first then I can lock my phone and listen otherwise abs gets killed.
Using android auto, plays a few seconds then dies. Workaround is to start it manually on the phone, then abs in auto restarts a couple times and starts working as normal.

Running latest version of abs server and client on pixel 8

@7h3ju57 commented on GitHub (Dec 23, 2023): I'm getting the same issue. I always download my books and experiencing the following issues. Start the book, it starts but I have to make sure to wait for the playback bar to show up first then I can lock my phone and listen otherwise abs gets killed. Using android auto, plays a few seconds then dies. Workaround is to start it manually on the phone, then abs in auto restarts a couple times and starts working as normal. Running latest version of abs server and client on pixel 8
Author
Owner

@advplyr commented on GitHub (Dec 23, 2023):

Have you tried disabling battery optimization for Abs? I'm on a pixel 6 Android 13 and don't have these issues.

There is more work to do here but I think a workaround for most is going to be disabling battery optimization.

@advplyr commented on GitHub (Dec 23, 2023): Have you tried disabling battery optimization for Abs? I'm on a pixel 6 Android 13 and don't have these issues. There is more work to do here but I think a workaround for most is going to be disabling battery optimization.
Author
Owner

@7h3ju57 commented on GitHub (Dec 23, 2023):

Yeah I've tried disabling battery optimization.

For me anyway the issue is due to local downloads.
To test I deleted the local version and all the issues are gone. No 15 second delay for the playback bar to appear after starting a book, and abs in android auto worked fine for at least two trips.

So looks like the issues are caused by local downloaded books?

Anything I can do to help identify any issues? Logs etc?

@7h3ju57 commented on GitHub (Dec 23, 2023): Yeah I've tried disabling battery optimization. For me anyway the issue is due to local downloads. To test I deleted the local version and all the issues are gone. No 15 second delay for the playback bar to appear after starting a book, and abs in android auto worked fine for at least two trips. So looks like the issues are caused by local downloaded books? Anything I can do to help identify any issues? Logs etc?
Author
Owner

@Salvoxia commented on GitHub (Dec 23, 2023):

@7h3ju57 Does it make any difference for you if you download to Internal App Storage or to a manually added folder?

@Salvoxia commented on GitHub (Dec 23, 2023): @7h3ju57 Does it make any difference for you if you download to Internal App Storage or to a manually added folder?
Author
Owner

@gazpachoking commented on GitHub (Dec 23, 2023):

I have a pixel 5, and experience the issue with battery optimization turned off, and when downloaded to internal or external storage.

Edit: I was wrong. Internal storage does fix the problem.

@gazpachoking commented on GitHub (Dec 23, 2023): I have a pixel 5, and experience the issue with battery optimization turned off, and when downloaded to internal or external storage. Edit: I was wrong. Internal storage does fix the problem.
Author
Owner

@7h3ju57 commented on GitHub (Dec 24, 2023):

@7h3ju57 Does it make any difference for you if you download to Internal App Storage or to a manually added folder?

Can confirm downloading to internal storage fixes all the issues I was experiencing.

@7h3ju57 commented on GitHub (Dec 24, 2023): > @7h3ju57 Does it make any difference for you if you download to Internal App Storage or to a manually added folder? Can confirm downloading to internal storage fixes all the issues I was experiencing.
Author
Owner

@gazpachoking commented on GitHub (Dec 24, 2023):

Can confirm downloading to internal storage fixes all the issues I was experiencing.

Oh! It fixes for me too. I had tested on a previous version with no luck, but it worked this time.

@gazpachoking commented on GitHub (Dec 24, 2023): > Can confirm downloading to internal storage fixes all the issues I was experiencing. Oh! It fixes for me too. I had tested on a previous version with no luck, but it worked this time.
Author
Owner

@Salvoxia commented on GitHub (Dec 24, 2023):

Thanks, I can confirm as well that I no longer experience the issues I described when sticking to Internal App Storage for downloaded books.

@Salvoxia commented on GitHub (Dec 24, 2023): Thanks, I can confirm as well that I no longer experience the issues I described when sticking to Internal App Storage for downloaded books.
Author
Owner

@sandreas commented on GitHub (Dec 24, 2023):

Thanks, I can confirm as well that I no longer experience the issues I described when sticking to Internal App Storage for downloaded books.

This is great, but still a WORKAROUND... not a fix. There are other apps out there working flawlessly with external storage, so it must be possible somehow. However, I understand that it is complicated and much work.

@sandreas commented on GitHub (Dec 24, 2023): > Thanks, I can confirm as well that I no longer experience the issues I described when sticking to Internal App Storage for downloaded books. This is great, but still a WORKAROUND... not a fix. There are other apps out there working flawlessly with external storage, so it must be possible somehow. However, I understand that it is complicated and much work.
Author
Owner

@Salvoxia commented on GitHub (Dec 24, 2023):

Sure, but for fixing reproducing this behavior is necessary, and this is an important clue as to how to reproducing the problem more or less reliably might be possible.

@Salvoxia commented on GitHub (Dec 24, 2023): Sure, but for fixing reproducing this behavior is necessary, and this is an important clue as to how to reproducing the problem more or less reliably might be possible.
Author
Owner

@sandreas commented on GitHub (Dec 24, 2023):

Sure, but for fixing reproducing this behavior is necessary, and this is an important clue as to how to reproducing the problem more or less reliably might be possible.

Absolutely. I would love to help, but I don't know how :-) Maybe I'll find the time after christmas.

@sandreas commented on GitHub (Dec 24, 2023): > Sure, but for fixing reproducing this behavior is necessary, and this is an important clue as to how to reproducing the problem more or less reliably might be possible. Absolutely. I would love to help, but I don't know how :-) Maybe I'll find the time after christmas.
Author
Owner

@mihailim commented on GitHub (Dec 24, 2023):

For what it's worth, I can also confirm that all the app playback freezes / crashes are gone when downloading books to Internal storage, as opposed to a separate folder as I used to do before.

Pixel 6a, Android 14 on the latest patch level -- although the issue has always been intermittently present for all A14 builds when trying local playback.

Permanently exempting the app from battery optimization as advised a few months back definitely helped reduce the incidence to the point where it became impossible to reliably reproduce without waiting 20-30 minutes at the very least, but in itself that never solved the problem. This workaround did, reliably -- not a single incident for a full day (8+ hours of playback), which was never the case before.

@mihailim commented on GitHub (Dec 24, 2023): For what it's worth, I can also confirm that all the app playback freezes / crashes are gone when downloading books to Internal storage, as opposed to a separate folder as I used to do before. Pixel 6a, Android 14 on the latest patch level -- although the issue has always been intermittently present for all A14 builds when trying local playback. Permanently exempting the app from battery optimization as advised a few months back definitely helped reduce the incidence to the point where it became impossible to reliably reproduce without waiting 20-30 minutes at the very least, but in itself that never solved the problem. This workaround did, reliably -- not a single incident for a full day (8+ hours of playback), which was never the case before.
Author
Owner

@sandreas commented on GitHub (Apr 10, 2024):

@advplyr
Is it possible, that a request to ignore battery optimizations would help at least with a few of the crashes?

The AndroidManifest.xml is missing this at the moment:

  1. https://stackoverflow.com/questions/44862176/request-ignore-battery-optimizations-how-to-do-it-right
  2. https://www.youtube.com/watch?v=A8_Sp4c2dSo
@sandreas commented on GitHub (Apr 10, 2024): @advplyr Is it possible, that a request to ignore battery optimizations would help at least with a few of the crashes? The `AndroidManifest.xml` is missing this at the moment: 1. https://stackoverflow.com/questions/44862176/request-ignore-battery-optimizations-how-to-do-it-right 2. https://www.youtube.com/watch?v=A8_Sp4c2dSo
Author
Owner

@advplyr commented on GitHub (Apr 10, 2024):

That looks old, is that still supported? Saw a comment saying Google Play store looks for this in app approval

@advplyr commented on GitHub (Apr 10, 2024): That looks old, is that still supported? Saw a comment saying Google Play store looks for this in app approval
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#613