Skip to content

fix(android-auto): resolve playlist freeze and playback delay#4060

Open
kairosci wants to merge 1 commit into
MetrolistGroup:mainfrom
kairosci:fix-android-auto-playback-and-browsing
Open

fix(android-auto): resolve playlist freeze and playback delay#4060
kairosci wants to merge 1 commit into
MetrolistGroup:mainfrom
kairosci:fix-android-auto-playback-and-browsing

Conversation

@kairosci

@kairosci kairosci commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Android Auto playlist view freezes with infinite loading spinner and song playback is significantly delayed with incomplete metadata.

Cause

onPlaybackResumption in MediaLibrarySessionCallback returned a SettableFuture that was never resolved. When Android Auto connected and called this callback, the future blocked the entire media session pipeline indefinitely. All subsequent browsing and playback commands from the car UI were queued behind this hung future, causing both the playlist freeze and playback delay. Additionally, onSetMediaItems dispatched database queries on Dispatchers.Main instead of Dispatchers.IO, blocking the main thread during song selection and compounding the playback delay.

Solution

Replaced the never-completing SettableFuture in onPlaybackResumption with Futures.immediateFuture(emptyList()) so the callback completes instantly and unblocks the session. Added explicit Dispatchers.IO to onSetMediaItems to move database work off the main thread, consistent with how onGetChildren already runs.

Testing

Built successfully with assembleFossDebug, no warnings or errors introduced. The fix is a minimal two-line change with no new dependencies or side effects.

Related Issues

Closes #4055

Summary by CodeRabbit

  • Bug Fixes
    • Improved playback resumption so the app now returns a stable, immediate result instead of leaving the request unresolved.
    • Made media item loading run on a background I/O thread for more reliable playback handling.

…leting unfinished futures and moving IO off main thread
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ff7aa24-a2d3-4cee-b516-78780443a7e4

📥 Commits

Reviewing files that changed from the base of the PR and between 4f36df9 and edfa102.

📒 Files selected for processing (1)
  • app/src/main/kotlin/com/metrolist/music/playback/MediaLibrarySessionCallback.kt

📝 Walkthrough

Walkthrough

MediaLibrarySessionCallback now returns an immediate empty MediaItemsWithStartPosition from onPlaybackResumption, removes the unused SettableFuture import, and explicitly runs onSetMediaItems work on Dispatchers.IO.

Changes

Playback callback updates

Layer / File(s) Summary
Playback callback updates
app/src/main/kotlin/com/metrolist/music/playback/MediaLibrarySessionCallback.kt
Removes the SettableFuture import, changes onPlaybackResumption to return MediaItemsWithStartPosition(emptyList(), 0, C.TIME_UNSET), and sets onSetMediaItems to use Dispatchers.IO.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • nyxiereal
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the Android Auto playlist freeze and playback delay fix.
Description check ✅ Passed The description follows the template and covers problem, cause, solution, testing, and related issue.
Linked Issues check ✅ Passed The changes address the linked Android Auto playlist freeze and playback delay issues as requested.
Out of Scope Changes check ✅ Passed The PR only changes the Android Auto session callback code and stays within the linked issue scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kairosci

Copy link
Copy Markdown
Contributor Author

@akash-banjade could you try this and verify whether this solves your issue? Thanks

@akash-banjade

Copy link
Copy Markdown

HI @kairosci, thanks now the app is responding as expected. Thank you very much

@kairosci

Copy link
Copy Markdown
Contributor Author

@mostafaalagamy could you take a look? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metrolist App Freezes on Playlist Navigation & Exhibits Playback Delay in Android Auto

2 participants