- Published
- Nov 4, 2026
- Reading time
- 11 min read
Media3 IMA Ads Replay After Rotation? Trace Resume State
Diagnose IMA ad replay after Android rotation or backgrounding with retained loader state, content position and adsId checks, including Bundle omissions.

In this guide (10 sections)
If an IMA ad starts again after an Android player is recreated, check three things together: the retained client-side ImaAdsLoader, the content resume position and the identity used for ad playback state. Restoring a content timestamp alone does not restore the ad loader's state. A reconstructed configuration can also lose an explicitly chosen adsId.
The current Media3 IMA module documents reusing the same loader when returning from the background, saving getContentPosition(), and seeking to that content position before preparing the new player. These instructions concern a supported client-side IMA lifecycle. They do not promise that an in-memory object survives process death or that every interrupted ad can resume under every integration.
A real rotation question with a version boundary#
An older Stack Overflow question asks how to save and restore ad progress in the ExoPlayer IMA extension. Posted on 4 June 2020, it describes an activity losing its loader field after rotation, with both the ad and content restarting. The author was constrained to legacy ExoPlayer 2.9.6.
One answer suggests handling configuration changes without activity recreation. The author reports using that approach in the legacy app. A later answer, dated 11 August 2022, points to retaining the loader and restoring content position. The opened page has no observed accepted-answer marker. Neither answer is proof that a current Media3 build has been tested or that a manifest flag serializes ad state.
The task remains useful: separate the player instance, the ad state and the content bookmark before diagnosing repeated ad starts. This guide checks that task against current primary documentation, without treating the historical question as a new SDK incident.
Trace ad state through player recreation
Record the loader, content position and ad playback identity across rotation.
Use the tracking QA checklistOpens a practical guide. No email required.
Identify the insertion path and the state you are preserving#
Record the dependency family and actual versions, insertion mode, player ownership and recreation trigger. Distinguish client-side IMA VAST/VMAP playback from a stitched DAI stream. Similar class names do not make their state APIs interchangeable.
| Object or record | Question it answers | Investigation boundary |
|---|---|---|
Client-side ImaAdsLoader | Which instance owns this ad playback state? | Retained object and its lifecycle |
| Player/content bookmark | Where should content resume? | Content position, item and units |
| Media item ad configuration | Which ad-state identity belongs to this item? | Explicit identity and reconstruction |
| Player view and ad UI container | Which current view displays playback and controls? | Recreated view association |
| DAI loader state | Which separate server-side integration supplies resumable state? | Its own API and supported workflow |
Media3's client-side IMA module README describes keeping the loader while the player and media source are released and recreated around backgrounding. Follow the version-appropriate integration. Do not create a second custom adapter over the maintained extension merely to observe lifecycle events.
For a direct custom Android adapter receiving loaded media without the expected callbacks or UI, use the separate Android IMA preloading investigation. Its per-media identity problem differs from retaining a loader across player recreation.
Trace one recreation before changing the lifecycle#
Use one authorized test response and a reproducible transition. Begin with ordinary playback, then trigger the specific rotation or background-and-return sequence. A changed ad decision, content item or app build on repetition can obscure the first failed boundary.
Assign private diagnostic labels to the content session, player, loader and view. Log object reuse as an observation rather than inferring it from a field name. A new object stored in the same activity field remains a new loader.
Keep a sequence containing:
- The current content item, insertion mode and ad configuration.
- Whether an ad is playing, with the available ad-group and ad-index context.
- Content position and, separately, the observed ad position.
- The lifecycle transition and which objects are released or retained.
- The loader returned when the new media source requests one.
- The rebuilt item's ad identity and restored content bookmark.
- Player attachment, seek, preparation, observed playback and relevant event records.
Use elapsed time to order local transitions and retain a wall-clock timestamp and timezone for server correlation. Remove signed URLs, visitor identifiers and credentials from a shared packet. These labels are diagnostic joins, not a new audience identity or campaign deduplication rule.
If the original trace was not captured, reproduce a bounded test rather than claiming the logs reconstruct the missing interruption. Keep incomplete observations explicitly unknown.
Save the content position without substituting the ad clock#
The Media3 Player reference defines content position in milliseconds. During an ad, it identifies the content position to be played after that ad group; outside an ad it matches the ordinary current position. The method also has an applicable command-availability requirement.
That is a different coordinate from seconds elapsed in the advertisement. Saving eight seconds because an ad was eight seconds into playback does not establish that the content should resume at eight seconds. Preserve the item and timeline context with the bookmark.
The module README directs the integration to save the content position and seek before preparing the replacement player. Verify the actual ordering in the affected build. A correct value applied only after preparation is a different trace from the documented sequence.
For a hypothetical unit check, a content position of 90,000 milliseconds is 90 seconds. It is not 90,000 seconds, and it is not an eight-second ad-resume offset. Do not use an apparent numerical similarity to combine those fields.
A restored bookmark is one acceptance check. Continue observing whether the correct ad state accompanies it and whether the player returns to the intended programme position afterward. If the resumed attempt instead reports a media-loading error, preserve that result and use the VAST error investigation; a loading failure needs its own trace before it is attributed to state loss.
Reattach the retained loader through the supported path#
The current ImaAdsLoader reference requires the player to be set before preparing media that uses the loader. Its methods and supported players operate on the main thread. A retained loader still needs the correct replacement player association.
Inspect what the provider returns during recreation. Rebuilding the media source with a provider that allocates a new loader each time defeats the intended retained-state path, even when the previous object remains elsewhere in memory. Conversely, retaining a loader does not make an old view the right ad UI container for the new player.
Review attachment and cleanup with the lifecycle owner. The retained resource needs an explicit final release when playback is finished and will not resume. Do not solve a replay symptom by keeping every player, view and loader indefinitely, or release the loader early while assuming its state remains available.
The AdsLoader interface describes how implementations preserve state around stop/start and an interrupted ad's resume position. That is a loader implementation contract. An app using the maintained IMA extension should not replace its internal state with guessed played flags to make a counter stop increasing.
Preserve the same ad-state identity during reconstruction#
The Media3 ad-insertion guide explains that playlist identity affects whether ad playback state is shared. Record the actual media ID, content URI, ad tag URI and any explicitly supplied ads identifier before and after recreation. Review the installed version's defaults rather than guessing from an identical visible video title.
A stable loader and a changed state key can still describe different playback state. An identifier with a new random value on every reconstruction is therefore a candidate to investigate. Establish the intended session and equality behavior; do not assign the same key to unrelated content simply to suppress ads.
| Reconstruction observation | Next check |
|---|---|
| Same loader and matching intended ads identity | Trace content bookmark, ordering and actual resume |
| New loader returned by provider | Review why the state-owning instance was replaced |
| Same loader but explicit identity changed | Compare the intended state scope and reconstruction |
| Identity shared by unrelated items | Check whether state sharing incorrectly suppresses another item's ads |
| Configuration restored from a bundle | Inspect fields actually preserved, especially an explicit identity |
State sharing is an integration choice. It is not a household frequency cap, cross-device deduplication or evidence that an impression has already been billed. Keep the scope tied to the intended media playback behavior.
Check the Bundle omission before assuming a full restore#
The AdsConfiguration API reference documents an important exception: toBundle() omits adsId, and fromBundle() restores that field as null. Serializing this configuration is not equivalent to preserving every identity chosen by the application.
If the original item used an explicit identifier, compare that value with the reconstructed item. Ask the implementation owner how the intended identity is restored through the supported construction path. Retain the original serialized representation and the actual reconstructed configuration privately.
A null value does not automatically prove a defect: the app may intentionally use the default identity arrangement. The issue is an unintended change in the state scope, established by comparing before and after. Do not claim the omission explains every replay without that evidence.
The bundle also does not serialize the retained client-side loader into a durable process-independent object. For process termination, a cold start or a new device, evaluate the actual supported recovery contract separately. A successful rotation test is insufficient evidence for those transitions.
Keep server-side DAI state outside this client-side recipe#
Media3 exposes a separate server-side IMA AdsLoader.State type. Its existence does not make that state object the serializer for client-side ImaAdsLoader.
When the deployed integration is DAI, use its own loader, state and stream-session guidance. Keep the stream position and timeline conversion appropriate to that path. Do not paste a DAI state-restoration example into a client-side VAST app because both mention IMA.
Likewise, an iOS Picture in Picture callback-delay investigation is a different SDK and lifecycle task. Establish the actual platform before applying advice from a nearby question.
Test the transition and the resulting measurement separately#
Exercise the transitions the app actually supports: rotation while content plays, rotation during an ad, background-and-return during content, background-and-return during an ad, switching content items, and the final disposal path. Add process termination as a separate test with an explicit supported expectation.
Check both playback and UI: correct item and position, intended ad state, usable current controls and content return. A resumed media surface with controls attached to an obsolete view has not completed the acceptance test.
Hypothetical review: twenty controlled transitions are assigned one initial result each, using the first unexplained boundary to avoid counting a test twice.
| Initial result | Transitions |
|---|---|
| Intended loader, identity, content position and playback verified | 12 |
| Provider returned a new loader unexpectedly | 4 |
| Explicit ad identity changed unexpectedly | 2 |
| Content bookmark used the wrong coordinate | 1 |
| Trace incomplete | 1 |
| Total | 20 |
Seven of twenty transitions, or 35%, have an identified initial mismatch. Among nineteen classified transitions, seven is approximately 36.84%. State the denominator; neither percentage is an industry failure rate, a campaign loss estimate or proof of duplicate billable impressions.
A replayed ad can represent another actual exposure, while a repeated transport attempt can refer to the same observation. Do not label both duplicate impressions without the agreed event-identity and counting policy. Preserve actual start, progress and completion records; never manufacture a played or skipped state to hide an unresolved lifecycle problem.
For supported campaigns already sending relevant events to AdProof, retain a campaign, date and timezone-scoped export beside the player trace. Confirm the available event types and filters. The anonymized streaming-publisher case illustrates delivery reconciliation, without establishing native Media3 integration or a replay diagnosis. Discuss the available evidence with the tested transition and counting scope.
Frequently asked questions#
Is restoring the content timestamp enough to restore an interrupted IMA ad?
No. The documented client-side module flow also retains the loader and reconnects it to the rebuilt playback path. Check the intended ad-state identity and actual resume separately from the content bookmark.
Does AdsConfiguration.toBundle preserve my explicit adsId?
The current reference says it omits that field and restoration returns it as null. Compare the reconstructed item with the intended identity arrangement; null is not automatically wrong if the app intentionally uses its defaults.
Can I use the server-side AdsLoader.State for a client-side ImaAdsLoader?
They belong to different integration types. Follow the state contract for the deployed insertion path. A similarly named DAI state type does not establish a client-side serialization API.
Does a successful rotation test prove recovery after process death?
No. Retaining an object in memory and reconstructing after process termination are different boundaries. Test each supported transition with its own expectation and keep unverified recovery behavior explicit.
Trace ad state through player recreation
Record the loader, content position and ad playback identity across rotation.
Use the tracking QA checklistOpens a practical guide. No email required.
