Skip to content

CastPlayer crashes when Receiver has error in LOAD message interceptor #708

Open

Description

@JonWatson

Version

Media3 1.1.1

More version details

When our Cast Receiver has an internal exception/error inside a LOAD message interceptor, the CastPlayer on the Sender app is crashing like so:

// Cast Receiver error, unsure if this is helpful.  This is our bug that needs to be fixed
playerManager.setMessageInterceptor(
  cast.framework.messages.MessageType.LOAD,
  request => {
      // do something bad here that causes an exception in the JavaScript
  }
);

// Cast Sender crashes here
java.lang.IllegalStateException
	at androidx.media3.common.util.Assertions.checkStateNotNull(Assertions.java:117)
	at androidx.media3.cast.CastTimelineTracker.getCastTimeline(CastTimelineTracker.java:113)
	at androidx.media3.cast.CastPlayer.updateTimeline(CastPlayer.java:1031)
	at androidx.media3.cast.CastPlayer.updateTimelineAndNotifyIfChanged(CastPlayer.java:956)
	at androidx.media3.cast.CastPlayer.updateInternalStateAndNotifyIfChanged(CastPlayer.java:832)
	at androidx.media3.cast.CastPlayer.access$800(CastPlayer.java:84)
	at androidx.media3.cast.CastPlayer$StatusListener.onStatusUpdated(CastPlayer.java:1370)
	at com.google.android.gms.cast.framework.media.zzbn.zzm(com.google.android.gms:play-services-cast-framework@@21.3.0:6)
	at com.google.android.gms.cast.internal.zzaq.zzY(com.google.android.gms:play-services-cast@@21.3.0:1)
	at com.google.android.gms.cast.internal.zzaq.zzO(com.google.android.gms:play-services-cast@@21.3.0:59)
	at com.google.android.gms.cast.framework.media.RemoteMediaClient.onMessageReceived(com.google.android.gms:play-services-cast-framework@@21.3.0:1)
	at com.google.android.gms.cast.zzbq.run(com.google.android.gms:play-services-cast@@21.3.0:4)
	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:7918)
	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)

Devices that reproduce the issue

Pixel 7 Pro running Android 13

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Have a Cast Receiver that throws an exception within its LOAD messageInterceptor

Expected result

Cast Sender (CastPlayer) should not crash the app

Actual result

CastPlayer crashes the app on a borked timeline

Media

Any

Bug Report

Activity

  1. changed the title [-]CastPlayer crashes when Receiver has error[/-] [+]CastPlayer crashes when Receiver has error in LOAD message interceptor[/+] on Oct 6, 2023
  2. marcbaechinger commented on Nov 9, 2023

    @marcbaechinger
    Contributor

    Thanks for reporting.

    If there is no media info object in the media status, we can't really build a timeline. So at this place we probably should just return an empty timeline when mediaStatus.getMediaInfo() is null. This avoids the crash you report.

    I wonder whether we can make CastPlayer throw a playback error in such a case.

    We look into this an update this issue when we publish a fix for this.

  3. added a commit that references this issue on Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions