Skip to content

Make MediaControllerImplBase local binder aware #2642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nift4
Copy link

@nift4 nift4 commented Jul 23, 2025

The session->controller data flow already nicely avoids bundling if we don't have to bundle by skipping the entire PlayerInfo object which contains almost everything. But in the controller->session data flow, some complex objects (MediaMetadata, MediaItem and TrackSelectionParameters) were always bundled even if we don't have to. This change skips bundling for these object and should improve performance significantly when sending large lists of MediaItems to a session in the same process.

@nift4
Copy link
Author

nift4 commented Jul 23, 2025

For some background, my app has a controller.setMediaItems() call in a onclick listener, and Play Console has been complaining about ANRs in the unbundling code:

      at androidx.media3.common.MediaMetadata$Builder.build (MediaMetadata.java:624)
      at androidx.media3.common.MediaMetadata.fromBundle (MediaMetadata.java:1541)
      at androidx.media3.common.MediaItem.fromBundle (MediaItem.java:2463)
      at androidx.media3.common.util.BundleCollectionUtil.fromBundleList (BundleCollectionUtil.java:67)
      at androidx.media3.session.MediaSessionStub.setMediaItemsWithStartIndex (MediaSessionStub.java:1113)
      at androidx.media3.session.MediaControllerImplBase.lambda$setMediaItems$27 (MediaControllerImplBase.java:899)
      at androidx.media3.session.MediaControllerImplBase.dispatchRemoteSessionTask (MediaControllerImplBase.java:392)
      at androidx.media3.session.MediaControllerImplBase.dispatchRemoteSessionTaskWithPlayerCommand (MediaControllerImplBase.java:331)
      at androidx.media3.session.MediaControllerImplBase.setMediaItems (MediaControllerImplBase.java:897)
      at androidx.media3.session.MediaController.setMediaItems (MediaController.java:1301)
      at org.akanework.gramophone.ui.adapters.SongAdapter.onClick (SongAdapter.kt:163)

The session->controller data flow already nicely avoids bundling if
we don't have to bundle by skipping the entire PlayerInfo object
which contains almost everything. But in the controller->session
data flow, some complex objects (MediaMetadata, MediaItem and
TrackSelectionParameters) were always bundled even if we don't have
to. This change skips bundling for these object and should improve
performance significantly when sending large lists of MediaItems to
a session in the same process.
@nift4 nift4 force-pushed the controllernobundle branch from e48a380 to cbd2208 Compare July 25, 2025 18:22
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.

2 participants