Skip to content

feat(rendering): expose winning creative size on BannerView - #1007

Open
nsp37 wants to merge 8 commits into
prebid:masterfrom
nsp37:feat/bannerview-expose-won-size
Open

nsp37 wants to merge 8 commits into
prebid:masterfrom
nsp37:feat/bannerview-expose-won-size

Conversation

@nsp37

@nsp37 nsp37 commented Sep 8, 2026 •

Copy link
Copy Markdown

Fixes #1006.

Problem

The rendering BannerView gives consumers no way to learn which requested size actually won. BannerViewListener.onAdLoaded(BannerView) carries no size and there's no getter for the rendered creative's dimensions. For a multi-size rendering placement (multiple sizes on one BannerView via addAdditionalSizes(...), e.g. 300x250 + 320x50) the host must reserve the bounding box of all requested sizes and, when a smaller creative wins, has no signal to shrink the slot — leaving whitespace. iOS already exposes this via bannerView(_:didReceiveAdWithAdSize:).

Change

A non-breaking public getter on BannerView:

  • @Nullable AdSize getCreativeSize() → declared size in dp of the displayed creative. null when nothing is displayed, 0x0 when a creative is displayed but its size is unknown.

The size is published right before onAdLoaded, so onAdLoaded can read it and it stays accurate across refreshes (see "Changes after review"). A getter rather than a new listener method, so no existing implementer breaks.

Notes

  • No behavior change for existing consumers. The API additions are the getter and a BannerEventListener.onAdServerWin(View, AdSize) overload (see below).
  • iOS parity with didReceiveAdWithAdSize.

Changes after review

Round 1

  • The size is captured at display time, not read live from bidResponse.
    • Prebid win: the winning bid's declared w/h.
    • Ad-server win: the ad server's creative size, passed through BannerEventListener.onAdServerWin(View, AdSize). GamBannerEventHandler passes AdManagerAdView.getAdSize(). It is never the losing Prebid bid's size.
  • A refresh that is still in flight or finds no bid keeps reporting the creative on screen. The size is cleared on render failure, when an expired ad is removed (Expire ads respectively to the seatbid.bid.exp #945), and on destroy().
  • The Javadoc describes a declared size, not a measured one, with the MRAID resize caveat.
  • Merged master to pick up the pinned play-services-ads version for CI.

Round 2

  • The API is now a single @Nullable AdSize getCreativeSize() instead of getCreativeWidth()/getCreativeHeight(). null means nothing is displayed. 0x0 means a creative is displayed but its size is unknown: a bid without w/h, a fluid or other non-positive ad server size, or a handler that reports no size.
  • A Prebid creative's size is kept pending and published in onAdLoaded, right before the host listener is called. While a new Prebid creative loads, the previous one is gone and the value is null. A render failure discards the pending size.
  • displayAdServerView() destroys and nulls the previous Prebid DisplayView, so a detached creative can't clear the size, leak, or call bannerViewListener.
  • The preferred renderer name is compared with equals. The Javadoc says the creative is laid out to fill the view, not at the bid size.
  • onAdServerWin(View, AdSize) is now the abstract method. The one-arg overload is a @Deprecated default that forwards with null. BannerView implements only the two-arg method, matching iOS adServerDidWin(_:adSize:).
  • NextGenBannerEventHandler reports the served size through a new AdViewWrapper.adSize (from BannerAd.getAdSize()), so both GAM handlers behave the same.
  • PublisherAdViewWrapper.getAdSize() reuses GamBannerEventHandler.convertGamAdSize(...). The Javadoc covers negative fluid dimensions and GAM-side refresh, which isn't reflected in BannerView.
  • Tests: null ad server view, GAM failure → Prebid fallback, Prebid → GAM → Prebid refresh, app event timeout forwarding the size (GAM and Next-Gen), and PublisherAdViewWrapper / AdViewWrapper size mapping including FLUID, null and exceptions. The BannerViewTest auction helpers are merged into one receiveBid(w, h, exp), and bids name no preferred renderer so tests take the production display path.

Developed with AI assistance.

nsp37 and others added 2 commits September 7, 2026 21:39
Add getCreativeWidth()/getCreativeHeight() so consumers can learn which
requested size won inside BannerViewListener.onAdLoaded(BannerView). For a
multi-size rendering placement (e.g. 300x250 + 320x50) the host otherwise
must reserve the bounding box and cannot shrink to the rendered creative.
Non-breaking getters sourced from the already-populated bidResponse winning
bid (dp; 0 on no-fill). iOS already surfaces this via
bannerView(_:didReceiveAdWithAdSize:). Fixes prebid#1006.
Previous run failed at 'Set up Android SDK' (sdkmanager tools) because it
pinned a stale pre-fix workflow snapshot; prebid/prebid-mobile-android's
main already fixed this on fix/ci-android-sdk-platform-tools (merged
2026-09-14), switching to 'platform-tools'. Empty commit only, to force a
fresh workflow resolution — no source change.

@mdanylov-sigma mdanylov-sigma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up — #1006 is a real gap, and getters rather than a new listener method is the right call for keeping this non-breaking.

One blocking problem: on the ad-server (GAM) win path these getters report the size of the Prebid bid that lost, or 0 when Prebid had no bid at all, even though onAdLoaded fires for the GAM creative. A host using this to size the slot will size it wrong exactly where a wrong size is visible. Details inline, along with a staleness issue around refresh/expiry and a suggested shape for the fix (capture the size when a view is displayed, as iOS does by passing adSize with the ad-server view).

Also worth adding: unit tests for the new public API. BannerViewTest already has the setBidResponse() helper, so null response / no winning bid / winning bid / GAM-win are all cheap to cover.

Reviewed with Claude Code.

public int getCreativeWidth() {
Bid bid = bidResponse != null ? bidResponse.getWinningBid() : null;
return bid != null ? bid.getWidth() : 0;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When GAM wins, this returns the size of the bid that lost.

onAdServerWin calls notifyAdLoadedListener() (line 207) while bidResponse still holds the Prebid bid from onFetchCompleted. So inside onAdLoaded for a GAM creative these getters describe a creative that was never rendered:

  • Sizes 300x250 + 320x50, Prebid bids 320x50, GAM serves its own 300x250 line item → the host reads 320x50 and shrinks the slot, clipping the GAM creative.
  • Prebid has no bid → onError nulls bidResponse → the getters return 0, which the Javadoc defines as no-fill, even though GAM filled the slot. A host that collapses on 0 hides a served ad.

The PR mentions iOS parity, but iOS doesn't have this gap: the size travels with the view (adServerDidWin(_ view:, adSize:) → bannerView(_:didReceiveAdWithAdSize:)), so the GAM path reports GAM's served size.

Suggested fix (also resolves the staleness comment below): record the size where a view is actually displayed rather than deriving it here — in displayPrebidView() (the bid size is already computed there for addView) and in displayAdServerView() (size from the event handler, e.g. AdManagerAdView.getAdSize(), via an overload or a default method on BannerEventListener), and clear it on failure, expiry and destroy.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 46de0e5. The size is now captured where a view is displayed. BannerEventListener gets a default onAdServerWin(View, AdSize) overload, and GamBannerEventHandler passes AdManagerAdView.getAdSize(), so a GAM win reports GAM's served size. A handler that reports no size (or a fluid one) gives 0 instead of the losing bid's size. NextGen still uses the one-arg call, so it reports 0 for now.

*/
public int getCreativeHeight() {
Bid bid = bidResponse != null ? bidResponse.getWinningBid() : null;
return bid != null ? bid.getHeight() : 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values can describe an ad that is not on screen.

They track the mutable bidResponse field, which changes independently of the displayed creative:

  • Refresh: onFetchCompleted (line 173) replaces bidResponse before the new creative renders, so while the ad-server request is in flight the getters return the new bid's size while the previous creative is still displayed.
  • Failed refresh: onError (line 182) sets bidResponse = null → 0 ("no-fill"), but displayPrebidView() is never reached, so the old creative stays visible.
  • Render failure / destroy(): neither clears bidResponse, so the last bid's size is still returned.
  • After merging master: Expire ads respectively to the seatbid.bid.exp #945 expires a refreshable banner by destroying the displayView and calling removeAllViews(), but keeps bidResponse — so these report the expired bid's size for an empty slot until the next fetch.

Capturing the size at display time (see the comment above) removes all four cases.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 46de0e5. The getters now return fields set in displayPrebidView() / onAdServerWin, not from bidResponse. A refresh that is still in flight or finds no bid keeps reporting the creative on screen. The size is cleared on render failure, when #945 expiry removes the ad from a refreshable banner, and on destroy(). Each case has a test in BannerViewTest.

* so the host can size the slot to the creative. {@code onAdLoaded} fires
* after the bid response is set, so this is populated at callback time. On
* the ad-server (GAM) win path the served view owns its size, so this
* reflects the Prebid winning bid only.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc promises more than the value delivers — worth softening even if the behaviour stays.

  • "which size actually rendered" is the requested bid size, not a measured one. When the winning bid names a third-party plugin renderer, displayPrebidView() takes the else branch (line 493) and lays the view out MATCH_PARENT instead of at the bid size, so the bid's w/h is not the rendered size there.
  • MRAID resize() / expand() changes the creative's size after load; these getters keep returning the original bid size.

Calling it the winning bid's declared size would describe it accurately.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 46de0e5. The Javadoc now calls it the winning bid's declared size, not a measured one. It calls out the plugin-renderer MATCH_PARENT layout, MRAID resize()/expand(), the ad-server-win source, and when the value is 0.

* path, or 0 when there is no winning bid. See {@link #getCreativeWidth()}.
*/
public int getCreativeHeight() {
Bid bid = bidResponse != null ? bidResponse.getWinningBid() : null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small cleanup: this null-guarded lookup already exists as getWinnerBid() (line 597) and is now written three times. Production code already calls it from onFetchCompleted, so reusing it here (and dropping the test-only framing) keeps winning-bid selection in one place.

Also note BidResponse.getWinningBid() loops over every seatbid and rewrites winningBidJson on each call, so reading width and height runs that scan twice — worth caching the bid, or the displayed size.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 46de0e5. displayPrebidView() reads the bid once via getWinnerBid(), and the getters only return cached fields, so the seatbid scan no longer runs per call. getWinnerBid() also moved out of the test-only helpers region.

@mdanylov-sigma
mdanylov-sigma self-requested a review September 17, 2026 22:23
Picks up the pinned google-play-services-ads 25.4.0 (the branch had a
floating version that resolved to 25.5.0, which requires minSdk 24 and
broke CI), plus prebid#945 ad expiry, which the review asked to account for.
…isplayed

Address review on prebid#1007. getCreativeWidth()/getCreativeHeight() no longer
read the mutable bidResponse. The size is captured where a creative is
displayed and returned from dedicated fields:

- Prebid win: the winning bid's declared w/h, captured in
  displayPrebidView() via getWinnerBid() before the creative is created.
- Ad server win: the ad server creative's size. BannerEventListener gets a
  default onAdServerWin(View, AdSize) overload; GamBannerEventHandler passes
  AdManagerAdView.getAdSize(). Handlers that report no size, or a fluid
  size, give 0 instead of the losing Prebid bid's size.
- A refresh that is still loading or finds no bid keeps the size of the
  creative on screen.
- Cleared on render failure, when an expired ad is removed, and on destroy.

Javadoc now describes the value as the declared size, and notes plugin
renderers and MRAID resize. getWinnerBid() is no longer framed as
test-only. Adds BannerViewTest and GamBannerEventHandlerTest coverage.

@mdanylov-sigma mdanylov-sigma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. Capturing the size at display time fixes the GAM-win and staleness problems from the last round, and the new tests cover each case. A few follow-ups inline, plus these:

Next-Gen. You mentioned NextGenBannerEventHandler still makes the one-arg call and reports 0. It's a small change: the Next-Gen BannerAd has getAdSize() (width/height in dp), and AdViewWrapper already keeps the loaded ad in ad. An adSize property on the wrapper plus the two-arg call at lines 151 and 195 would do it, and NextGenBannerEventHandlerTest (lines 125/135) would switch to the two-arg verify. I'd do it here so both GAM handlers behave the same. Otherwise, a follow-up issue so it doesn't get lost.

Tests. A few paths aren't covered yet:

  • onAdServerWin(null, size): should clear the size and report onAdFailed.
  • The GAM onAdFailed → onPrebidSdkWin() fallback: should report the bid size.
  • A Prebid → GAM → Prebid refresh sequence.

Minor: mockBidResponse(w, h, exp) overlaps the existing receiveBid(exp) helper. Merging them would leave one way to fake an auction in this class.

Reviewed with Claude Code.

@Override
public void onAdFailed(AdException exception) {
// The Prebid creative failed to render, so there is no creative size to report.
clearCreativeSize();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A detached Prebid creative can clear the size of the ad on screen. displayViewListener is shared by every DisplayView this banner creates. displayAdServerView() calls removeAllViews() without destroying displayView, and displayPrebidView() only destroys it while it's still a child. So after a Prebid → GAM refresh, the old creative is still alive and wired to this listener. If it reports a failure later (a video error, for example), this line sets the size to 0x0 while GAM's creative is on screen.

It's an edge case, but the fix belongs one level down: destroy and null displayView in displayAdServerView(), the same way displayPrebidView() does. That also stops the detached creative from leaking and from sending callbacks to bannerViewListener.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 835a955. displayAdServerView() now destroys and nulls displayView before removing views, and onAdServerWin_DestroysPreviousPrebidCreative covers it.


removeAllViews();

// Captured before the creative is created, so it is set by the time onAdLoaded fires.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small doc mismatch. The Javadoc says the value doesn't change until the next creative is displayed, and that a refresh still loading keeps reporting the creative on screen. But on a Prebid win this runs right after removeAllViews() and before the new creative has loaded. So from here until onAdLoaded (or until the creative fails), the getters report the new bid's size for an empty slot.

Reading it in onAdLoaded is fine. I'd either say in the Javadoc that the value is set when a creative starts displaying and is meant to be read from onAdLoaded, or keep the bid size in a pending field and apply it in displayViewListener.onAdLoaded().

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 835a955. displayPrebidView() sets a pending size (and nulls the current one, since the old creative is removed), onAdLoaded() publishes it before notifying the host, and a render failure discards it. The Javadoc says the value describes the creative on screen and is meant to be read from onAdLoaded.

}

displayView = new DisplayView(getContext(), displayViewListener, displayVideoListener, adUnitConfig, bidResponse);
if (bidResponse.getPreferredPluginRendererName() == PrebidMobilePluginRegister.PREBID_MOBILE_RENDERER_NAME) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my earlier comment on the plugin-renderer MATCH_PARENT branch: it isn't only plugin renderers. This line compares strings with ==. getPreferredPluginRendererName() returns either null (no rendererName in the bid's meta, the usual case) or a string parsed from JSON, which isn't interned. So in practice every Prebid creative takes the MATCH_PARENT branch, and the bid-sized addView only runs in the new tests, because mockBidResponse returns the interned constant.

This predates the PR, and switching to .equals wouldn't change much in production, since null still falls through. But the new Javadoc ("a third party plugin renderer lays its view out to match this view") implies the default renderer is laid out at the bid size, and the tests exercise a branch production doesn't take. I'd make it PrebidMobilePluginRegister.PREBID_MOBILE_RENDERER_NAME.equals(...), have mockBidResponse return null for the renderer name so the tests follow the real path, and adjust that Javadoc bullet.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 835a955. It now uses PREBID_MOBILE_RENDERER_NAME.equals(...), the test helper returns a null renderer name so tests take the MATCH_PARENT path (asserted in creativeSize_OnPrebidWin_CreativeFillsBannerView), and the Javadoc says the creative fills the view rather than being laid out at the bid size.

* render, after an expired ad is removed, and after {@link #destroy()}.</li>
* </ul>
*/
public int getCreativeWidth() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 means two different things here. It's returned when nothing is displayed, and also when a creative is displayed but its size is unknown. That includes a GAM fluid ad, a handler that doesn't report a size (Next-Gen today, or any custom BannerEventHandler), and a Prebid bid without w/h. Those are optional in OpenRTB and often missing on outstream video in a multiformat banner. A host that follows this Javadoc and sets the slot height to getCreativeHeight() collapses a live ad to 0 dp in all of those cases.

One fix that also simplifies the code: keep a single @Nullable AdSize creativeSize field and expose getCreativeSize(), returning null only when nothing is displayed. Hosts can then tell "no ad" from "ad of unknown size". It replaces the two ints, setCreativeSize/clearCreativeSize and the two set-or-clear blocks, and uses the same AdSize type as addAdditionalSizes() and the new onAdServerWin(View, AdSize). If you'd rather keep the int getters, please at least say in the Javadoc that 0 doesn't mean the slot is empty.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 835a955. There is now a single @Nullable AdSize getCreativeSize(): null only when nothing is displayed, and 0x0 when a creative is displayed but its size is unknown (bid without w/h, fluid or other non-positive size, or no size from the handler). The Javadoc says not to size the slot from 0x0.

* Event handlers that know the served size should call this instead of
* {@link #onAdServerWin(View)}, so the banner can report it. Pass null when the size is unknown.
*/
default void onAdServerWin(View view, @Nullable AdSize adSize) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, but worth considering while this API is new: the two overloads delegate to each other. This default forwards two-arg → one-arg, and BannerView's one-arg override forwards back to two-arg. That works today because BannerView overrides both. But BannerView is the only implementer and event handlers are the callers, so the delegation runs the wrong way. If someone later drops the two-arg override, or writes a wrapper that follows this Javadoc and forwards one-arg → two-arg, it recurses until StackOverflowError. A wrapper that only overrides the one-arg method silently drops the size.

Flipping it keeps every existing caller compiling, and matches iOS, where adServerDidWin(_:adSize:) is the only variant:

/** @deprecated Use {@link #onAdServerWin(View, AdSize)}. */
@Deprecated
default void onAdServerWin(View view) {
    onAdServerWin(view, null);
}

void onAdServerWin(View view, @Nullable AdSize adSize);

BannerView then only implements the two-arg method. It would only break code that implements BannerEventListener itself, which should be rare outside the SDK.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 835a955. The two-arg onAdServerWin(View, AdSize) is now abstract, the one-arg overload is a @Deprecated default forwarding null, and BannerView implements only the two-arg method.

recycleCurrentBanner();
embeddedBanner = gamBannerView;
bannerEventListener.onAdServerWin(getView(gamBannerView));
bannerEventListener.onAdServerWin(getView(gamBannerView), getAdSize(gamBannerView));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably rare, since Prebid normally drives refresh, but worth a line in the Javadoc. If refresh is configured on the GAM ad unit itself, GAM reloads the embedded AdManagerAdView in place. onAdLoaded fires again, but requestBanner is null by then, so nothing reaches BannerView and the getters keep the previous creative's size.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 835a955 to the GamBannerEventHandler class Javadoc: refresh configured on the GAM ad unit reloads in place without reaching BannerView, so it keeps the first creative's size.

WhiteBox.method(GamBannerEventHandler.class, "handleAppEventTimeout").invoke(bannerEventHandler);

verify(mockBannerEventListener, times(1)).onAdServerWin(any());
verify(mockBannerEventListener, times(1)).onAdServerWin(any(), any());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app-event-timeout path is the usual ad-server win when Prebid sent a bid, but here it's only verified with any(), any(). A test like the one above, with requestBanner set to a mock that returns a size, would confirm that handleAppEventTimeout forwards it.

PublisherAdViewWrapper.getAdSize() isn't covered in PublisherAdViewWrapperTest either: the FLUID mapping, a null getAdSize(), and the catch path.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 835a955. onAppEventTimeout_PassGamCreativeSizeToOnAdServerWin sets requestBanner to a mock returning a size and verifies it is forwarded, and PublisherAdViewWrapperTest now covers a normal size, FLUID, a null getAdSize() and the catch path.

public AdSize getAdSize() {
try {
com.google.android.gms.ads.AdSize gamAdSize = adView.getAdSize();
return gamAdSize != null ? new AdSize(gamAdSize.getWidth(), gamAdSize.getHeight()) : null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: GamBannerEventHandler.convertGamAdSize(...) already does this mapping, so calling it (after the null check) would keep a single conversion.

Also, the Javadoc says this returns null when GAM reports no size, but for FLUID it returns AdSize(-3, -4). Worth saying that negative dimensions can come back and are filtered in BannerView.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 835a955. getAdSize() calls convertGamAdSize(...) after the null check, and the Javadoc notes that FLUID comes back as -3 x -4 and that BannerView reports it as unknown size.

…Size

Address round 2 review:
- Replace getCreativeWidth/getCreativeHeight with getCreativeSize(). It is null when
  nothing is displayed and 0x0 when a creative is displayed but its size is unknown.
- Publish a Prebid creative's size when it loads, right before onAdLoaded.
- Destroy the previous Prebid creative when the ad server wins, so a detached
  creative cannot clear the size or send callbacks.
- Compare the preferred renderer name with equals.
- Make onAdServerWin(View, AdSize) the primary BannerEventListener method and
  deprecate the one argument overload.
- Report the served size from the Next-Gen banner event handler.
- Reuse convertGamAdSize in PublisherAdViewWrapper.getAdSize and document fluid
  sizes and GAM side refresh.
- Add tests for the null view, GAM failure fallback, refresh sequence, app event
  timeout size and PublisherAdViewWrapper/AdViewWrapper sizes.
@nsp37

nsp37 commented Sep 29, 2026

Copy link
Copy Markdown
Author

Thanks for the second pass. All addressed in 835a955 (after merging current master).

Next-Gen. Done here. AdViewWrapper has an adSize property built from the loaded BannerAd.getAdSize(), NextGenBannerEventHandler makes the two-arg call in both places, and NextGenBannerEventHandlerTest verifies the two-arg call, including a new app-event-timeout test that checks the size is forwarded. AdViewWrapperTest covers the size before load, after load, and when the SDK throws.

Tests. Added in BannerViewTest: onAdServerWin(null, size) clears the size and reports onAdFailed; the GAM onAdFailed → onPrebidSdkWin() fallback reports the bid size; and a Prebid → GAM → Prebid refresh sequence checks the size at each step.

Helper. mockBidResponse(w, h, exp) is merged into receiveBid(w, h, exp), so there is one way to fake an auction. Its bid names no preferred renderer, so the tests follow the production display path.

The PR description's "Changes after review" section now covers round 2.

Resolve conflicts with the GAM manual impression change: handleAdServerWin() now passes the GAM creative size to onAdServerWin(View, AdSize).
The Next-Gen SDK's Kotlin metadata declares getAdSize() as a function, not an adSize property, so the property access did not compile.
@nsp37

nsp37 commented Nov 20, 2026

Copy link
Copy Markdown
Author

@mdanylov-sigma all comments from your second pass were addressed in 835a955 (replies are on each thread). Since then:

  • Merged current master (5268c60). The GAM manual impression change (eebaa68) conflicted. handleAdServerWin() now records the manual impression and passes the GAM creative size to onAdServerWin(View, AdSize), and the tests check both.
  • Next-Gen build fix (caacfa1). AdViewWrapper called BannerAd.adSize, but the Next-Gen SDK exposes getAdSize() as a function, so the module didn't compile. It now calls getAdSize().

Core, GAM and Next-Gen unit tests pass, except MraidInternalBrowserActionTest, which fails the same way on master.

Could you take another look?

@mdanylov-sigma mdanylov-sigma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, everything from the second pass is in. I checked each item against caacfa1:

  • displayAdServerView() destroys and nulls the previous DisplayView, so a detached creative can no longer clear the size.
  • The Prebid size stays pending until onAdLoaded, a render failure drops it, and the Javadoc matches.
  • The renderer name is compared with equals, and the tests now take the production MATCH_PARENT path.
  • A single @Nullable AdSize getCreativeSize(): null when nothing is displayed, 0x0 when the size is unknown.
  • onAdServerWin(View, AdSize) is the abstract method, and the one-arg overload is a deprecated default.
  • Next-Gen reports BannerAd.getAdSize() through AdViewWrapper.adSize.
  • The GAM in-place refresh note, the app-event-timeout and PublisherAdViewWrapper tests, and the three missing BannerView paths are all covered.

BannerViewTest, GamBannerEventHandlerTest, PublisherAdViewWrapperTest, AdViewWrapperTest and NextGenBannerEventHandlerTest pass locally at caacfa1.

Reviewed with Claude Code.

This branch has not been deployed

No deployments
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.

Rendering BannerView does not expose the winning creative size (multi-size slots can't shrink to the rendered creative)

2 participants