Skip to content

fix(music): resume from a Play button only when the queue can be read - #2341

Merged
A-EDev merged 2 commits into
mainfrom
fix/music-resume-button-crash
Nov 24, 2026
Merged

A-EDev merged 2 commits into
mainfrom
fix/music-resume-button-crash

Conversation

@A-EDev

@A-EDev A-EDev commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • A Play button (headset, car, watch) that starts the music service only resumes when the saved queue can actually be read.
  • Before, the check was "the queue file exists". A store that DataStore reset after corruption, or a queue that failed to read or decode, still said yes. The resume then failed, Media3 had nothing to show, no notification was posted, and Android killed the app with ForegroundServiceDidNotStartInTimeException. Once Flow accepts the start, Media3 has no public way back, so the answer has to be right up front.
  • New ResumableQueueFile: resume needs a non-empty store with no .unreadable marker beside it. A failed restore writes the marker, the next successful save or restore removes it. Still answered from file metadata on the main thread, with the marker writes on Dispatchers.IO.

Related issue

Closes #2283

Change type

  • Bug fix
  • Feature
  • Refactor or maintenance
  • Build, packaging, or CI
  • Documentation

Validation

  • ./gradlew :app:assembleGithubDebug
  • ./gradlew :app:testGithubDebugUnitTest (7109 tests, 0 failures, with all five of this batch merged together)
  • I ran any additional flavor-specific build or test tasks affected by this change. (spotlessCheck, :app:compileFossDebugKotlin)
  • I manually tested the affected behavior on an Android device or emulator.

Test device and Android version: Android emulator, phone image, Android 17 (API 37)

  • New ResumableQueueFileTest (JVM, temp folder).
  • Emulator repro: play a song, pause, force-stop, empty music_queue.preferences_pb, then adb shell cmd media_session dispatch play. Main crashes with the exact exception from the issue 12 s later. With this PR the start is declined and the service stops cleanly.
  • With a real saved queue, Play after a force-stop still resumes the song.

Screenshots or recordings

Risk and compatibility

Only changes when a Play button may resume. A queue saved before this update still resumes.

  • The change does not introduce secrets, private data, or unexpected telemetry.
  • New user-facing text uses Android string resources.
  • Dependency and lockfile changes are intentional and limited to this PR.
  • Room schema changes include the required version bump and migration, or this PR does not change the Room schema.
  • Breaking changes and upgrade steps are clearly documented.

@github-actions github-actions Bot added documentation Improvements or additions to documentation player Video and audio playback labels Nov 23, 2026
@A-EDev
A-EDev merged commit 334ec66 into main Nov 24, 2026
29 of 34 checks passed
@A-EDev
A-EDev deleted the fix/music-resume-button-crash branch November 24, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation player Video and audio playback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: RemoteServiceException$ForegroundServiceDidNotStartInTimeException in ActivityThread.java:2877 (3.0.5)

1 participant