Skip to content
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

Automotive sample crashes on emulators that do not display group titles #2033

Open
1 task done
alx-jst opened this issue Jan 10, 2025 · 2 comments
Open
1 task done
Assignees
Labels

Comments

@alx-jst
Copy link

alx-jst commented Jan 10, 2025

Version

Media3 1.5.1

More version details

Modify the demo-session-automotive app to display group titles

  1. Checkout release 1.5.1.
  2. Open MediaItemTree.kt at line 100.
  3. Modify the buildMediaItem method to add a group title as follows:
    .setExtras(Bundle().apply { putString(MediaConstants.EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE, "Group title") })

Alternatively, apply the attached set_group_title.patch file using Git.
set_group_title.patch

Devices that reproduce the issue

Any emulator that is not able to display group titles, including the following:

  • Automotive (1408p landscape) emulator with Google Play API 34-ext9
  • Automotive Distant Display emulator with Google Play API 33
  • Automotive Large Portrait emulator API 33
  • Automotive Ultrawide API emulator 34-ext9

Devices that do not reproduce the issue

Devices capable of displaying group titles:

  • Automotive (1024p landscape) emulator API 32
  • A couple real vehicles I could test so far

Reproducible in the demo app?

Yes

Reproduction steps

  1. Launch the patched demo-session-automotive app on an Automotive emulator that does not support displaying group titles.
  2. Navigate to a screen that displays grouped content and their titles (Home, Album Folder, Artist Folder, Genre Folder)
  3. Scroll to the bottom of the content (list/grid).
  4. Perform a navigation action, such as:
    • Clicking on a browsable item.
    • Switching tabs.
    • Pressing the back button.

The app crashes with the following exception:

java.lang.IndexOutOfBoundsException: toIndex = n

Where n corresponds to the total number of items in the list/grid + 1, regardless of the index of the item you've clicked on.

Expected result

The app should navigate to the requested content without crashing.

Actual result

Only when the content (list/grid) is scrolled to the end, any navigation interaction triggers an IndexOutOfBoundsException.
See stacktrace.txt.

Media

Not applicable

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@marcbaechinger
Copy link
Contributor

marcbaechinger commented Jan 14, 2025

Thanks for your report.

From what you describe, I believe this is an issue with the AAOS app or then the structure of the content provided to AAOS by the app rather than Media3.

2025-01-10 17:14:54.891  5397-5397  AndroidRuntime  com.android.car.media   E  FATAL EXCEPTION: main (Ask Gemini)
    Process: com.android.car.media, PID: 5397
    java.lang.IndexOutOfBoundsException: toIndex = 7
        at java.util.ArrayList.subListRangeCheck(ArrayList.java:1016)
        at java.util.ArrayList.subList(ArrayList.java:1008)
        at com.android.car.media.BrowseViewController.onShow(BrowseViewController.java:213)
        at com.android.car.media.MediaActivityController.showCurrentNode(MediaActivityController.java:622)
        at com.android.car.media.MediaActivityController.navigateTo(MediaActivityController.java:576)
        at com.android.car.media.MediaActivityController.access$1000(MediaActivityController.java:79)
        at com.android.car.media.MediaActivityController$3.goToMediaItem(MediaActivityController.java:450)
        at com.android.car.media.BrowseViewController$1.onBrowsableItemClicked(BrowseViewController.java:176)
        at com.android.car.media.browse.BrowseAdapter$2.lambda$onMediaItemClicked$0(BrowseAdapter.java:172)
        at com.android.car.media.browse.BrowseAdapter$2$$ExternalSyntheticLambda0.accept(Unknown Source:4)
        at com.android.car.media.browse.BrowseAdapter.notify(BrowseAdapter.java:330)
        at com.android.car.media.browse.BrowseAdapter.access$000(BrowseAdapter.java:55)
        at com.android.car.media.browse.BrowseAdapter$2.onMediaItemClicked(BrowseAdapter.java:164)
        at com.android.car.media.browse.BrowseViewHolder.lambda$bind$0(BrowseViewHolder.java:126)
        at com.android.car.media.browse.BrowseViewHolder$$ExternalSyntheticLambda2.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:7542)
        at android.view.View.performClickInternal(View.java:7519)
        at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
        at android.view.View$PerformClick.run(View.java:29476)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7924)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Without the modification it works, where with your modification to use a group title it starts to fail. I'd think that AAOS needs to anticipate to some extend, that the data is wrong.

Said that, I don't actually know why this fails, but from the stack trace above I'd expect that when clicking a media item that is displyed somewhere, AAOS should take care to not fail here.

Can you point me to the AAOS documentation that describes what you are doing with EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE?

@alx-jst
Copy link
Author

alx-jst commented Jan 17, 2025

Thank you for your answer.

What I'm doing with EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE is building a list of MediaItem grouped by category (using setExtras) to return when onGetChildren is called, following this Android developer tutorial.

Here are the relevant references:

Additionally, I’ve observed that Spotify and Deezer, which also group content, do not crash under the same conditions, suggesting their implementations avoid this issue. One hypothesis is that they rely on an earlier version of androidx.media (e.g., Media2), which might not trigger this problem.

Could you help me better understand how Media3 interacts with AAOS when grouping content? Could there have been a regression between Media2 and Media3 that might explain this behavior? Any guidance on ensuring compatibility between grouped content and the AAOS media experience would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants