Ensures errors are correctly attributed to ad or content #2655
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
AD_STATE_ERROR
.ALL_ADS_COMPLETED
is dispatched by IMA, the player is torn down before ExoPlayer updatesAdPlaybackState
to reflect completion.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.