Player stops between tracks since v1.0.4 (still broken in v1.4.0)
Duplicate Check
- [x] I confirm I searched for existing reports and found no duplicates.
Describe the Bug
Music stops playing after 1-2 tracks and needs to be resumed manually. Worked in v1.0.3, broken since v1.0.4, still broken in v1.2.1. Similar symptoms are reported in #1894, #1948, #1965, #1983, #1847, #1818, #1386, #1995.
Three users independently downgraded to v1.0.3 and confirmed the bug disappears: @ptrkbmn (#1965), @woiang (#1948), @Xynel0 (#1948). @dmurthy-dev captured the failure with ADB in #1894 (see Log section).
The cause could be in commit 71ffebb in the core submodule ("integrate CrossfadeExoPlayerAdapter"). Before that commit, SimpleMediaService passed a single long-lived ExoPlayer to MediaLibrarySession. After it, the session gets CrossfadeExoPlayerAdapter.forwardingPlayer, which uses a separate ExoPlayer per track with one MediaItem per instance. At the end of each track that ExoPlayer hits Player.STATE_ENDED. DelegatingForwardingPlayer forwards this to the MediaSession listener. Media3's MediaLibraryService then drops the foreground-service notification, because from its view playback ended. The adapter swaps to the next pre-cached player and calls play(), but during the ~25 ms gap the FGS has already been cancelled. On HyperOS, OneUI and similar ROMs that gap is long enough for the OS to freeze the process.
In v1.0.3 the single ExoPlayer advanced tracks via its internal playlist, so STATE_ENDED was never fired between tracks. FGS stayed attached.
Possible directions to solve this:
- Suppress
STATE_ENDEDinDelegatingForwardingPlayerwhile a swap is pending (remap toSTATE_BUFFERING). - Call
forwardingPlayer.swapDelegate(next)andnext.play()before the current track hitsSTATE_ENDED, not after.triggerCrossfadeTransitionalready does this for crossfade. - Keep the single-ExoPlayer path as default and only use
CrossfadeExoPlayerAdapterwhen crossfade is enabled.
Steps to Reproduce
- Open a playlist of at least 5 tracks
- Start playback
- Lock the screen
- Player pauses on its own between tracks within 1-3 songs
Expected Behavior
Continuous playback across tracks, as in v1.0.3.
App Version
1.2.1
Android Version
16
Device Model
Samsung Galaxy S23
Custom ROM
- [ ] I am using a custom ROM
Custom ROM Name (if applicable)
No response
Screenshots (optional)
No response
Log / Error Details
ADB capture from @dmurthy-dev in #1894:
MediaSessionService: playbackState=STOPPED
ActivityManager: Cancel FGS notification … ChannelId:media_playback_channel
MediaSessionService: playbackState=PAUSED
ActivityManager: pid 2644 sent binder code 31101 … to frozen apps, got error -74
this issue happens on my Amazon Fire HD 8" (2022 model), but not on my phone (Redmi Note 12). Both devices with all updates.
This is, quite simply, one of the best bug reports I have ever seen. Problem, diff, solution. Well done.
I went back to 1.03 on my s25 and the issue disappeared!
I'm having the same problem. I've reverted to version 1.0.3. I'm hoping you can help resolve the issue. Thanks for everything, you guys are fantastic! You've created a wonderful app.
I have the same problem on the Pixel 8 and the Motorola Edge 50 Pro. After 4–5 songs in a locally downloaded playlist, it stops playing. Hope you fix it.
This is such a good bug report. Thank you @Dollarius !! (And yes, i'm experiencing the same problem. Device: OnePlus 9 Pro, running CrDroid 12.10, which is Android 16)
Same problem on OnePlus Ace 3V (Android 16) ver. 1.0.4-1.2.1. This bug appears less often (doesn't) in Android auto (Full link).
I made a fork which fixes the issue https://github.com/DropaBombOnEm/SimpMusic/releases/tag/1.2.1
I made a fork which fixes the issue https://github.com/DropaBombOnEm/SimpMusic/releases/tag/1.2.1
No, it does not fix the issue. And from what i can tell, it's also vibecoded.
is it fixed in 1.3.0?
I made a fork which fixes the issue https://github.com/DropaBombOnEm/SimpMusic/releases/tag/1.2.1
No, it does not fix the issue. And from what i can tell, it's also vibecoded.
@xad0x, It is vibecode, I'm not a programmer and never claimed to be. I'm just trying to get it to work for personal use & share it with the community, if it works. And you're also right that it wasn't fixed, just less-frequent (on my end) and it didn't happen the hour I tested yesterday.
But it seems the root cause was found now though "player.seekTo() causes ExoPlayer to briefly transition through a non-playing buffering state. The onIsPlayingChanged(false) callback fires, cancelling progressJob. When rebuffering completes near-instantly, onIsPlayingChanged(true) may never fire — leaving progressJob permanently dead. The UI shows "playing" but progress never moves".
I'll do some more testing... My bad for the false-claim of it being fixed. 😅
is it fixed in 1.3.0?
Unfortunately no...
I haven't had any issues with my new 1.3.0-Dev fork, but I'd love for @xad0x to prove me wrong again 😅 🫣
I had 20-30 songs play in the background (during the course of an extended period of time, using other apps & my phone being locked) and playback only paused when my phone switch from Wi-Fi to cellular (when I left home) and I just pressed play from the notification and it resumed like normal...
I also tested my fork via an emulator on my PC and it played songs continuously for hours in-app (app launched on-screen) without playback stopping itself.
This has been fixed. The player no longer drops the foreground service between tracks (STATE_ENDED is now suppressed during track transitions), so the OS can no longer freeze the process during the player swap. Please update to the latest version. Thanks for the detailed root-cause analysis and ADB logs. If it still happens on the latest build, comment with logs and we will reopen.
@maxrave-dev thank you for all the work on this!
That said, it's still broken in v1.4.0: playback still stops between tracks for me on the latest nightly (dev, core 3ecd15f). Could this be reopened? I dug into it and found a possible cause: this may not be the same foreground-service drop you fixed (my process is never frozen in the logs), but a separate audio-focus issue during the precached-player swap. Details below.
Build: FOSS nightly from CI run https://github.com/maxrave-dev/SimpMusic/actions/runs/27085129738 (dev, core submodule 3ecd15f, includes all three prior playback fixes).
Device: Galaxy S23 (SM-S911B), One UI / Android 16, Media3 1.10.1.
I was listening over a Bluetooth speaker (A2DP), which makes the stop very easy to notice, but I don't think Bluetooth itself is the cause. The logs suggest the audio output only gets torn down because playback had already silently paused, so the BT teardown looks like a symptom, not the trigger.
Repro
- Queue several tracks and press play.
- Let it auto-advance on its own (don't touch the transport controls).
- Within a few tracks, playback stops: notification shows the next track at position 0, paused, while the UI "wants" to play.
- Pressing play resumes it (this seems to issue a fresh audio-focus request).
In my case it only seems to break when the next track is served from precache, which might explain why it's intermittent ("stops after 4 to 5 songs").
Possible cause (CrossfadeExoPlayerAdapter.kt)
- Precached/secondary players appear to be created with
handleAudioFocus = false(createExoPlayerInstance, ~line 293; used at ~1202, ~1575, ~2455). Only the initial player (~line 244) handles focus. - On the track-end swap (
loadAndPlayTrackInternal), the old player is released and abandons audio focus, and the precached player's focus handling is enabled afterwards viasetAudioAttributes(audioAttributes, true)(~line 1250) andplay(). It looks like flippinghandleAudioFocusfalse to true on an already-prepared player may not actually re-acquire focus, so the gap left by the old player is never filled and ExoPlayer ends up atPLAYING -> PAUSED (playWhenReady=true).
(I'm not 100% sure on the exact ExoPlayer internals here, but the logs below seem to point this way.)
Evidence (logcat, sanitized)
The session-wide audio-focus timeline is what made me suspect this. Every successful track change is abandon -> request, except the one that stops:
06-07 16:45:14.516 I/MediaFocusControl: requestAudioFocus() ... callingPack=com.maxrave.simpmusic
06-07 16:48:05.515 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic
06-07 16:48:05.528 I/MediaFocusControl: requestAudioFocus() ... com.maxrave.simpmusic
06-07 16:51:33.151 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic
06-07 16:51:33.166 I/MediaFocusControl: requestAudioFocus() ... com.maxrave.simpmusic
06-07 16:54:43.660 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic
06-07 16:54:43.666 I/MediaFocusControl: requestAudioFocus() ... com.maxrave.simpmusic
06-07 16:57:31.264 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic
06-07 16:57:31.270 I/MediaFocusControl: requestAudioFocus() ... com.maxrave.simpmusic
06-07 17:00:17.331 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic <-- no request follows
The failing transition in sequence:
06-07 17:00:17.281 D/CrossfadeExoPlayerAdapter: End of stream reached
06-07 17:00:17.281 D/CrossfadeExoPlayerAdapter: State: PLAYING -> PREPARING (playWhenReady=true)
06-07 17:00:17.302 D/CrossfadeExoPlayerAdapter: Using precached player for <videoId>
06-07 17:00:17.314 I/ExoPlayerImpl: Release 6699789 [AndroidXMedia3/1.10.1] [SM-S911B, samsung, 36]
06-07 17:00:17.331 I/MediaFocusControl: abandonAudioFocus() ... com.maxrave.simpmusic
06-07 17:00:17.342 D/CrossfadeExoPlayerAdapter: State: PREPARING -> PLAYING (playWhenReady=true)
06-07 17:00:17.372 D/CrossfadeExoPlayerAdapter: State: PLAYING -> PAUSED (playWhenReady=true) <-- paused, no focus
06-07 17:00:20.401 I/PAL: Device: close ... PAL_DEVICE_OUT_BLUETOOTH_A2DP, deviceCount 1 -> 0 <-- BT output torn down (after the pause)
(Full 71-line sanitized logcat attached.)
Possible fix direction
Maybe make sure audio focus is actually re-acquired when a precached player is promoted to current, for example by building precache players with audio-focus handling, or forcing a playWhenReady false to true edge after setAudioAttributes(.., true), or requesting focus explicitly before play(). A possible sanity check: every abandonAudioFocus() during a transition should be followed by a requestAudioFocus().
Sad that although v1.4.0 has just been released (#2121), we may have to go back again to v1.0.3.
Happy to capture more logs if it would help.
Just let me know what would be most useful and thanks again for your work!
I too tested v1.4.0 and for me it worked.
Details:
My phone is an OnePlus 9 Pro, ROM is CrDroid 12.10 (Android 16)
I enabled Keep service alive in settings and went into the app info (in system settings) > app battery usage > allow background usage > unrestricted.
I was not logged into youtube.
I listened to the music with bluetooth headphones.
I left my phone locked the entire time.
Using these settings i listened to 9 songs in a row without any interruptions.
Still broken on the released 1.4.0. Reproduced just now on the phone speaker (no Bluetooth):
- Installed the released 1.4.0 (not the nightly).
- Played an uncached album on the phone speaker (playing by ~08:04).
- Playback stopped after exactly 4 songs (08:18:00).
- Turned on "keep service alive" and set the app battery to Unrestricted, then pressed play (08:25:51).
- Playback stopped again after exactly 1 more song (08:28:56).
Both stops show the same thing: abandonAudioFocus() with no following requestAudioFocus(), then PLAYING -> PAUSED (playWhenReady=true). So the Unrestricted/keep-alive changes made no difference, and no Bluetooth is involved.
Full sanitized logcat attached.
@dafcavservicios @brendancarr @afabmoro97 @MrDaraku @xad0x @Prosto-Pasha @DropaBombOnEm @girshcatt @frreachergirl-source how is it for you guys on 1.4.0?
@maxrave-dev I am available to provide more data/tests if it can be helpful.
Hi, everyone! I confirm, the problem remains in 1.4.0.
Il problema persiste anche nella versione 1.4.0 soprattutto quando collego una sorgente bluetooth
Still in 1.5.0.
Il problema persiste ancora una volta nella versione 1.5.0