Crash: BadParcelableException
@marcbaechinger is already working on this.
Since Dec 17, 2025.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.6.1
More version details
No response
Devices that reproduce the issue
While I am unable to reproduce the issue, based on what we are seeing in our crash logs, it doesn't seem to be device specific. The most recent incidents have been on:
- Samsung SM-S918U
- Samsung SM-A166P
- Google Pixel 6
- Google Pixel 7
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
I don't know how to reproduce the issue. However, my best understanding is that it happens when a MediaSession is being restored, because it seems to be crashing when attempting to read an image from a Bundle. Nothing in my code attempts to write any images to any Bundles, so I assume this is part of the state save/restore that is managed by the Media3 components.
The relevant components that I am using are:
- Service extending
MediaLibraryService:- This service implements
onGetLibraryRoot()andonGetChildren(). TheMediaItems that are such that the only images/bitmaps that are set on them are viaMediaMetadata.Builder().setArtworkUri({uri})where theurivalue is a remote/https url. - onCreate the service instantiates the media session. The player that it uses is a wrapper implementation that forwards all of its functions to either an instance of
ExoPlayeror an instance ofCastPlayerdepending on whether there is an active cast session.
- This service implements
- Custom
MediaNotification.ProviderextendingDefaultMediaNotificationProvider:- On init, calls
setSmallIcon()passing a vector drawable - Overrides
getMediaButtons()for control of when to show next/previous buttons
- On init, calls
Expected result
Saving/restoring media sessions should not result in a crash
Actual result
Intermittent crashes
Sample stack trace:
android.os.BadParcelableException: Bitmap_createFromParcel unknown colortype: 7
at android.graphics.Bitmap.nativeCreateFromParcel(Bitmap.java)
at android.graphics.Bitmap.-$$Nest$smnativeCreateFromParcel(:0)
at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:2387)
at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:2379)
at android.os.Parcel.readParcelableInternal(Parcel.java:5230)
at android.os.Parcel.readValue(Parcel.java:4981)
at android.os.Parcel.readValue(Parcel.java:4717)
at android.os.Parcel.-$$Nest$mreadValue(:0)
at android.os.Parcel$LazyValue.apply(Parcel.java:4826)
at android.os.Parcel$LazyValue.apply(Parcel.java:4779)
at android.os.BaseBundle.unwrapLazyValueFromMapLocked(BaseBundle.java:446)
at android.os.BaseBundle.getValueAt(BaseBundle.java:426)
at android.os.BaseBundle.getValue(BaseBundle.java:397)
at android.os.BaseBundle.getValue(BaseBundle.java:380)
at android.os.BaseBundle.getValue(BaseBundle.java:373)
at android.os.BaseBundle.get(BaseBundle.java:745)
at android.media.MediaMetadata$Builder.build(MediaMetadata.java:965)
at android.media.session.MediaSession.setMetadata(MediaSession.java:512)
at androidx.media3.session.legacy.MediaSessionCompat$MediaSessionImplApi21.setMetadata(MediaSessionCompat.java:4052)
at androidx.media3.session.legacy.MediaSessionCompat.setMetadata(MediaSessionCompat.java:705)
at androidx.media3.session.MediaSessionLegacyStub.setMetadata(MediaSessionLegacyStub.java:963)
at androidx.media3.session.MediaSessionLegacyStub.access$1100(MediaSessionLegacyStub.java:109)
at androidx.media3.session.MediaSessionLegacyStub$ControllerLegacyCbForBroadcast$1.onSuccess(MediaSessionLegacyStub.java:1402)
at androidx.media3.session.MediaSessionLegacyStub$ControllerLegacyCbForBroadcast$1.onSuccess(MediaSessionLegacyStub.java:1396)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1102)
at android.os.Handler.handleCallback(Handler.java:995)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loopOnce(Looper.java:273)
at android.os.Looper.loop(Looper.java:363)
at android.app.ActivityThread.main(ActivityThread.java:10060)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Media
I have not been able to identify which media items cause this issue, but I am trying to find a pattern. If I come up with anything more I will reply to this ticket with more information.
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.