Remove pending adLoad timeout tasks when resuming content

When a timeline change occurs, the `AdTagLoader` will post an adLoad timeout task if currently waiting for an ad to load. Once sdk calls `loadAd`, any pending timeout tasks are removed. If the timeout occurs, the ad group is canceled and content will resume.

If the SDK proceeded to resume content without calling `loadAd`, then any pending timeout tasks should be removed or else a future ad group may error due to a previous timeout task.

PiperOrigin-RevId: 723442852
This commit is contained in:
michaelkatz 2025-02-05 03:28:30 -08:00 committed by Copybara-Service
parent 97a1d31b5d
commit 4c163553e7

View File

@ -797,7 +797,10 @@ import java.util.Map;
private void resumeContentInternal() {
if (imaAdInfo != null) {
adPlaybackState = adPlaybackState.withSkippedAdGroup(imaAdInfo.adGroupIndex);
// Remove any pending timeout tasks as CONTENT_RESUME_REQUESTED may occur instead of loadAd.
// See [Internal: b/330750756].
handler.removeCallbacks(adLoadTimeoutRunnable);
adPlaybackState = adPlaybackState.withSkippedAdGroup(checkNotNull(imaAdInfo).adGroupIndex);
updateAdPlaybackState();
}
}