Skip to content

Ensures errors are correctly attributed to ad or content #2655

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

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

Conversation

stevemayhew
Copy link
Contributor

This change is part of a fix to the issue "Player Errors during Ad playback not attributed correctly"

The change introduced in commit 7cf2fd9 was a partial fix to allow ad playback errors to be reported. It delayed removing the listener when an error released the AdsMediaSource.

What remained was the larger issue: When an error occurs during content preparation while an ad is still playing, ExoPlayer cannot correctly attribute the error to the content source. Instead, the error bubbles up through ExoPlayerImplInternal.stopInternal() and causes the entire CompositeMediaSource (AdsMediaSource + content) to be torn down.

This results in the ImaAdsLoader being stopped prematurely — even when the ad is not at fault — and breaks proper ad lifecycle handling.

User-Facing Issues

  1. The ad is incorrectly marked as failed A content preparation error is misattributed to the currently playing ad, resulting in an invalid AD_STATE_ERROR.
  2. The ad is never marked as completed Even though ALL_ADS_COMPLETED is dispatched by IMA, the player is torn down before ExoPlayer updates AdPlaybackState to reflect completion.
  3. A single failing ad in a pod is not skipped If one ad in a pod fails (e.g., due to a 404 or DRM error), the player stops entirely instead of skipping to the next ad in the group.
  4. A failing ad does not fall back to content When an ad fails, the player should skip to content. Instead, the entire playback pipeline is torn down via stopInternal().

This change fixes the first two User-Facing issues. When combined with error recovery logic it also fixes the 4th issue. The 3rd issue may require some work on the IMA SDK side, the mid-pod failure aborts all ad playback with this fix, rather than skipping just the failing ad.

This change is part of a fix to the issue "Player Errors during Ad playback not attributed correctly"

The change introduced in commit 7cf2fd9 was a partial fix to allow ad playback errors to be reported.
It delayed removing the listener when an error released the AdsMediaSource.

What remained was the larger issue: When an error occurs **during content preparation while an ad is
still playing**, ExoPlayer cannot correctly attribute the error to the content source.
Instead, the error bubbles up through `ExoPlayerImplInternal.stopInternal()` and causes
the **entire CompositeMediaSource (AdsMediaSource + content)** to be torn down.

This results in the `ImaAdsLoader` being stopped prematurely — even when the ad is not at fault — and breaks proper ad lifecycle handling.

**User-Facing Issues**

1. **The ad is incorrectly marked as failed**
    A content preparation error is misattributed to the currently playing ad, resulting in an invalid `AD_STATE_ERROR`.
2. **The ad is never marked as completed**
    Even though `ALL_ADS_COMPLETED` is dispatched by IMA, the player is torn down before ExoPlayer updates `AdPlaybackState` to reflect completion.
3. **A single failing ad in a pod is not skipped**
    If one ad in a pod fails (e.g., due to a 404 or DRM error), the player stops entirely instead of skipping to the next ad in the group.
4. **A failing ad does not fall back to content**
    When an ad fails, the player should skip to content. Instead, the entire playback pipeline is torn down via `stopInternal()`.

This change fixes the first two User-Facing issues.  When combined with error recovery logic it also fixes the 4th issue.
The 3rd issue may require some work on the IMA SDK side, the mid-pod failure aborts all ad playback with this fix, rather than skipping just the failing ad.
@stevemayhew
Copy link
Contributor Author

Note a branch with extensive logging and a partial solution for User Facing Issue #4 is in my branch from this change: https://github.com/stevemayhew/media/tree/p-fixes-ad-error-handling-logging

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