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

Cmcd.Factory causes exception upon track change #888

Closed
1 task done
mikef-dk opened this issue Dec 13, 2023 · 4 comments
Closed
1 task done

Cmcd.Factory causes exception upon track change #888

mikef-dk opened this issue Dec 13, 2023 · 4 comments
Assignees

Comments

@mikef-dk
Copy link

Version

Media3 1.2.0

More version details

Following the release of androidx.media3 v1.2.0 we tried to enable the CMCD with the default configuration via MediaSource.Factory#setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT). While it seems to work during regular playback, a crash occurs once a different track (e.g. Audio track) is selected via the UI. Following the stacktrace:

Playback error
androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
   at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:685 undefined)
   at android.os.Handler.dispatchMessage(Handler.java:102 undefined)
   at android.os.Looper.loopOnce(Looper.java:201 undefined)
   at android.os.Looper.loop(Looper.java:288 undefined)
   at android.os.HandlerThread.run(HandlerThread.java:67 undefined)
Caused by: java.lang.IllegalArgumentException
   at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:40 undefined)
   at androidx.media3.exoplayer.upstream.CmcdData$Factory.<init>(CmcdData.java:135 undefined)
   at androidx.media3.exoplayer.dash.DefaultDashChunkSource.getNextChunk(DefaultDashChunkSource.java:418 undefined)
   at androidx.media3.exoplayer.source.chunk.ChunkSampleStream.continueLoading(ChunkSampleStream.java:580 undefined)
   at androidx.media3.exoplayer.source.CompositeSequenceableLoader.continueLoading(CompositeSequenceableLoader.java:81 undefined)
   at androidx.media3.exoplayer.dash.DashMediaPeriod.continueLoading(DashMediaPeriod.java:324 undefined)
   at androidx.media3.exoplayer.source.MaskingMediaPeriod.continueLoading(MaskingMediaPeriod.java:229 undefined)
   at androidx.media3.exoplayer.MediaPeriodHolder.continueLoading(MediaPeriodHolder.java:234 undefined)
   at androidx.media3.exoplayer.ExoPlayerImplInternal.maybeContinueLoading(ExoPlayerImplInternal.java:2477 undefined)
   at androidx.media3.exoplayer.ExoPlayerImplInternal.handleContinueLoadingRequested(ExoPlayerImplInternal.java:2438 undefined)
   at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:551 undefined)
   at android.os.Handler.dispatchMessage(Handler.java:102 undefined) 
   at android.os.Looper.loopOnce(Looper.java:201 undefined) 
   at android.os.Looper.loop(Looper.java:288 undefined) 
   at android.os.HandlerThread.run(HandlerThread.java:67 undefined)

The reason for this seems to be a negative bufferedDurationUs that is passed to the CmcdData.Factory and I assume the reason for this crash cannot be fixed by the client.

Other than that: The issue can be reproduced with the demo app once CMCD is enabled. Version 1.1.x does have the same issue.

Devices that reproduce the issue

Reproducable on all physical devices and emulators I tested it on

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Pre-requisite: Set CMCD configuration during setup of MediaSourceFactory, e.g. add the following line

.setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT)

to the end of the setup within PlayerActivity#createMediaSourceFactory.

  1. Open demo app
  2. Open Widevine DASH (MP4, H264) dropdown
  3. Select HD (cbcs)
  4. Click on "SELECT TRACKS"
  5. Select 320 x 142, 0.77 Mbps tracks
  6. Observe player

Expected result

Playback continues/starts with selected track

Actual result

"Playback failed" is displayed. Clicking on "Play" button starts/resumes playback with selected track

Media

https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
copybara-service bot pushed a commit that referenced this issue Dec 15, 2023
When track is changed during playback, `playbackPositionUs` may be in middle of a chunk and `loadPositionUs` should be the start of that chunk. In this situation `loadPositionUs` can be less than the current `playbackPositionUs`, resulting into negative `bufferedDurationUs`. It translates to having no buffer and hence we should send `0` for `bufferedDurationUs` when creating new instances of `CmcdData.Factory`.

Issue: #888

#minor-release

PiperOrigin-RevId: 591099785
@rohitjoins
Copy link
Contributor

Thanks for reporting the issue. A fix was submitted to the main branch.

copybara-service bot pushed a commit to google/ExoPlayer that referenced this issue Dec 15, 2023
When track is changed during playback, `playbackPositionUs` may be in middle of a chunk and `loadPositionUs` should be the start of that chunk. In this situation `loadPositionUs` can be less than the current `playbackPositionUs`, resulting into negative `bufferedDurationUs`. It translates to having no buffer and hence we should send `0` for `bufferedDurationUs` when creating new instances of `CmcdData.Factory`.

Issue: androidx/media#888

#minor-release

PiperOrigin-RevId: 591099785
microkatz pushed a commit that referenced this issue Jan 11, 2024
When track is changed during playback, `playbackPositionUs` may be in middle of a chunk and `loadPositionUs` should be the start of that chunk. In this situation `loadPositionUs` can be less than the current `playbackPositionUs`, resulting into negative `bufferedDurationUs`. It translates to having no buffer and hence we should send `0` for `bufferedDurationUs` when creating new instances of `CmcdData.Factory`.

Issue: #888

#minor-release

PiperOrigin-RevId: 591099785
(cherry picked from commit 7f6596b)
@akhilesh-dubey
Copy link

@rohitjoins Thank you for addressing the issue. When can we expect the availability of this fix in the upcoming release?

@rohitjoins
Copy link
Contributor

@akhilesh-dubey, we are doing a bug-fix release this week which will also include the fix for this issue.

@rohitjoins
Copy link
Contributor

The fix is in the release branch.

@androidx androidx locked and limited conversation to collaborators Feb 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants