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

iOS book starts playing when app opens

Open mdeeter opened this issue 1 year ago • 47 comments

Steps to reproduce

  1. Listen to book (it's one I've downloaded)
  2. Pause book (typically done from lock screen, not sure if it matters)
  3. Hours later, open the app
  4. The last book will resume playing before the UI is finished loading

Expected behaviour

  • Preferred behavior: The book doesn't automatically start playing (or if some users want it to, make it configurable in the app settings to 'autoplay when opened'.
  • At the very least, I'd prefer if the book didn't start playing before the UI was loaded... it's playing before the player is even visible... so I have to wait for several seconds for the player UI to show up in order to pause the book.

Actual behaviour

  • Tell us what happens

Environment data

Audiobookshelf Version: 2.5.0

  • [ ] Android App?
  • [x] iOS App? - version 0.9.68-beta

iOS Issue

iOS Version: 17.1.2

iPhone model: iPhone 12 Pro

mdeeter avatar Dec 07 '23 14:12 mdeeter

I'm not able to reproduce this. What version of the iOS app are you using?

Is this happening every time for you? Are you leaving the app open in the background or closing it?

advplyr avatar Dec 08 '23 22:12 advplyr

app version 0.9.68-beta (updated in og description)

I typically always switch apps (leaving apps in the bg)... until something doesn't seem to be working, then I'll hard-close the app and re-open it.

It's happened several times in the past week, but it doesn't seem to happen all of the time... often enough to be a little annoying :)

mdeeter avatar Dec 09 '23 00:12 mdeeter

Just happened again...

I put in my airpods... Unlocked my phone... Opened the app...

The book started playing immediately... Here's the ui

image

Then I try tapping on the book... But it won't open until the ui finishes loading... image

Then the book opens (it's still playing) and there's no player UI showing... image

I click play button and it pauses the book and it shows the player UI at the bottom... image

mdeeter avatar Dec 09 '23 10:12 mdeeter

It’s a weird one. I get the same issue. Doesn’t really bother me but still, curious.

KaiStarkk avatar Dec 18 '23 01:12 KaiStarkk

I experienced this same issue. Here are some additional details in case it is helpful in recreating:

I was listening to a book on my iPhone in the car via Bluetooth. I then switched the car to play a different audio source (though I don't think I explicitly paused Audiobookshelf) I then was listening on my phone to the same book via headphones. I then paused the book in my phone. I then listened to the book on my iPad via headphones. I paused the iPad. Both devices were put down for several hours, but the app was not killed on either device. When I picked up the phone several hours later, this issue popped up.

The immediately-start-playing issue doesn't bother me too much (I would hate to have a fix for this prevent being able to get in and out of a car and continue listening without a bunch of button presses), but I experienced a secondary issue where the controls were not visible while the book was playing. Possibly the same as OP's "before the UI is finished loading."

P.S. I meant to mention that major kudos are deserved fro the developers of this app. This is one of the best if not the best open source iOS apps I've experienced. It looks beautiful, runs smoothly, and does what it's supposed to. This is the one bug that I've found so far.

dathbe avatar Dec 20 '23 16:12 dathbe

I also have the same issue, it used to happen before but seems to got fixed. But now it's back. Also not a big issue, i usually just press play again and it continues with the controls.

RealWalts avatar Dec 22 '23 21:12 RealWalts

This happens whether the book is downloaded or streaming. The streaming one is way more confusing because it starts playing the audio even before the server connects.

When I go to the book that's playing it shows as if it isn't playing.

This is also happening on the macOS client which seems to be the iOS app running on Mac. It randomly starts playing there and I can't get the play controls to come up so I have to quit the app.

I just updated the server app so I'll test it this week and report back.

livineasy629 avatar Dec 27 '23 02:12 livineasy629

Still present on the latest server version and updated iOS app. It will even continue playing a file that isn't downloaded while the server is disconnected.

livineasy629 avatar Jan 03 '24 22:01 livineasy629

It will even continue playing a file that isn't downloaded while the server is disconnected.

This isn't too surprising. Presumably the app caches some duration while it's streaming. Would be interesting to know how long it will play when this happens.

dathbe avatar Jan 04 '24 04:01 dathbe

I also have the same issue with the latest version...

GiladHi avatar Feb 05 '24 09:02 GiladHi

It will even continue playing a file that isn't downloaded while the server is disconnected.

This isn't too surprising. Presumably the app caches some duration while it's streaming. Would be interesting to know how long it will play when this happens.

In a recent play, I just left the house and left my wifi, I opened my app in the car and got about 3-5 min away when it stopped and I noticed it wasn't connected to my server. I killed the app and reconnected and it played fine.

I agree that it seems that the app is automatically playing from the cache. I think I'd prefer it if it wouldn't autoplay when I open the app.

mdeeter avatar Feb 06 '24 22:02 mdeeter

Is anyone able to reproduce this consistently yet? I'm trying to reproduce it again but unsuccessful so far.

By reproduce consistently I mean you are able to cause this to happen with a specific set of steps that you can share.

I've taken a guess at what could be happening while reading through the docs but I can't be sure until I can reproduce it. https://developer.apple.com/documentation/avfaudio/avaudiosession/interruptionreason/appwassuspended

advplyr avatar Feb 08 '24 00:02 advplyr

Let me know if this issue persists in 0.9.72-beta

advplyr avatar Feb 11 '24 23:02 advplyr

I'll test it asap. I made attempts to trigger this intentionally (to try to gauge a cause/effect) for about 20 min yesterday and couldn't get it to happen. Then it happened (seemingly randomly) when I opened the app last night.... and then again just now when I opened up the app to check what version I had installed (0.9.71). I'll update again next week if I do or don't see it again (after updating).

mdeeter avatar Feb 11 '24 23:02 mdeeter

So this is continuing to happen to me in the latest version (0.9.72). Idk if this is related, but I also experienced my current book starting to play at 1-2 AM seemingly on it's own.

This is really weird. I wonder if there's some logging that could be enabled (perhaps that I could opt-into) that could cache interactions that I could then send you (or upload here) to help triage this issue.

mdeeter avatar Feb 15 '24 23:02 mdeeter

If we're right that this is a caching issue, the server may not even know. Thus, logs may not be entirely useful.

dathbe avatar Feb 15 '24 23:02 dathbe

Still happened with the latest build, even with downloaded local files.

GiladHi avatar Feb 15 '24 23:02 GiladHi

The best way to figure this out is to find out how to reproduce it

advplyr avatar Feb 15 '24 23:02 advplyr

I experienced an extreme example of this last night where a book started playing randomly at midnight. The phone was otherwise sitting peacefully on my nightstand. When I opened the app to stop it, I was greeted with this:

2024-02-15 23-40-38 small

There was at least one, if not 2 more copies of the error message on the screen when I first opened it, and they were disappearing quickly. I didn't have my full senses about me, but I don't believe I had the option to stop the playback from within the app and had to force quit the app to get playback to stop (i.e., the playback controls were missing).

Steps to repeat:

  1. Open app from force-closed state
  2. Play book for about 2-5 minutes
  3. Pause book (I think i used the in-app controls for this, but it's possible I used the lock screen widget)
  4. Switch to a different app, but leave player open in background
  5. About 8 hours later, playback randomly restarted

I had not touched the app since pausing.

dathbe avatar Feb 16 '24 16:02 dathbe

I experienced an extreme example of this last night where a book started playing randomly at midnight. The phone was otherwise sitting peacefully on my nightstand. When I opened the app to stop it, I was greeted with this:

There was at least one, if not 2 more copies of the error message on the screen when I first opened it, and they were disappearing quickly. I didn't have my full senses about me, but I don't believe I had the option to stop the playback from within the app and had to force quit the app to get playback to stop (i.e., the playback controls were missing).

Steps to repeat:

  1. Open app from force-closed state.
  2. Play book for about 2-5 minutes
  3. Pause book (I think i used the in-app controls for this, but it's possible I used the lock screen widget)
  4. About 8 hours later, playback randomly restarted

I had not touched the app since pausing.

It also started playing at night here as well randomly. It had been a few hours since I last used it.

RealWalts avatar Feb 16 '24 16:02 RealWalts

I know it was mentioned that this also happens while streaming but the screenshots I've seen so far have all been downloaded. Is it possible the streaming is a slightly different situation happening that is getting conflated with this one? Because that happens often and makes it difficult to narrow down the issue.

advplyr avatar Feb 16 '24 16:02 advplyr

This book was not downloaded -- at least not manually.

dathbe avatar Feb 16 '24 16:02 dathbe

I'm currently on book 16 of Dresden Files... I've been streaming this series since book 10 and still seeing this issue... so I don't think it's specific to downloaded vs streaming.

mdeeter avatar Feb 16 '24 16:02 mdeeter

I'm surprised you haven't been able to reproduce this. I just tried it again (play, pause, don't force close, wait many hours, open app) and it did it again. I have a habit of force closing apps, so I think I'm 3 for 3 when leaving it in the background and having it play when re-opening.

dathbe avatar Feb 18 '24 01:02 dathbe

I have this issue too on latest ios 17.3.1 and latest ABS ios app version 0.9.72 beta

It seems like after the ABS app is in the background for a while, it forgets its playback state even though it's for sure paused. When opening the app it resumes to become playing BUT WITHOUT the miniplayer coming up

nigiriemoji avatar Feb 23 '24 21:02 nigiriemoji

I have this issue too on latest ios and latest ABS ios app version

Would you mind adding the version numbers instead of just latest, since that can help with future debugging when reviewing old issues? Assuming that's 0.9.72

nichwall avatar Feb 23 '24 22:02 nichwall

I have this issue too on latest ios and latest ABS ios app version

Would you mind adding the version numbers instead of just latest, since that can help with future debugging when reviewing old issues? Assuming that's 0.9.72

done, thank you. any logs i can provide to help?

nigiriemoji avatar Feb 23 '24 22:02 nigiriemoji

Here is a video of the exact bug that I’m experiencing.

I was playing an audiobook a few hours ago. The ABS app v0.9.72 stays in background apps for iOS 17.3.1, then when I open up the app the play continues to resume. Note that the mini player at the bottom does NOT show up at the bottom. It does if I manually hit play, but not when encountering this bug

https://github.com/advplyr/audiobookshelf-app/assets/53108354/d158c905-84df-4775-9860-82a7f8c83927

These are my logs:

Server Log Level

2024-02-27 03:45:29.246

INFO

[SocketAuthority] Socket Connected N9VHAZFqL21fdDG4AABb

2024-02-27 03:45:29.716

INFO

[PlaybackSessionManager] Syncing local session "Real Tigers" (1e47c6cb-8558-46e4-a72e-d37947abc8f0)

2024-02-27 03:45:35.872

INFO

[PlaybackSessionManager] startSession: Closing open session "Real Tigers" for user "adminABS" (Device: iPhone16,2 / v0.9.72)

2024-02-27 03:46:10.010

INFO

[SocketAuthority] Socket N9VHAZFqL21fdDG4AABb disconnected from client "adminABS" after 40764ms (Reason: transport close)

nigiriemoji avatar Feb 27 '24 03:02 nigiriemoji

That’s effectively identical to what I experience. I’m using an iPhone 13 mini in case that’s making a difference.

dathbe avatar Feb 27 '24 13:02 dathbe

yes, that's the exact same UX I have as well

mdeeter avatar Feb 27 '24 14:02 mdeeter