Provide and example with Companion Ad integration.
Current code have
/**
* Sets the slots for displaying companion ads. Individual slots can be created using {@link
* ImaSdkFactory#createCompanionAdSlot()}.
*
* @param companionSlots Slots for displaying companion ads.
* @see AdDisplayContainer#setCompanionSlots(Collection)
* @deprecated Use {@code getAdDisplayContainer().setCompanionSlots(...)}.
*/
@Deprecated
public void setCompanionSlots(Collection<CompanionAdSlot> companionSlots) {
adDisplayContainer.setCompanionSlots(companionSlots);
}
But there is no implementation example. Having Companion Ad integration would help us debug and troubleshoot any issues when it doesn't work on our clients.
Currently we have in our client code this part
CompanionAdView companionAdView = companionProvider.getCompanionAdView();
// Set up spots for companions.
CompanionAdSlot companionAdSlot = imaFactory.createCompanionAdSlot();
companionAdSlot.setContainer(companionAdView.getCompanionViewGroup());
companionAdSlot.setSize(companionAdView.getWidth(), companionAdView.getHeight());
ArrayList<CompanionAdSlot> companionAdSlots = new ArrayList<>();
companionAdSlots.add(companionAdSlot);
adDisplayContainer.setCompanionSlots(companionAdSlots);
Recent update to targetSdk 29 made it impossible to display companion banner( it's shown as blank white). So we were hoping to compare with ExoPlayer IMA integration and check if it's something on our side.
I can't think of any alternative solutions.
@andrewlewis, could you look into this?
The code from your comment looks right: it should work to call imaAdsLoader.getAdDisplayContainer().setCompanionSlots(slots); to set the slots you've instantiated.
It does work, but we would prefer to have example in ExoPlayer Demo project that would be maintenaned by Google/ExoPlayer team, so anytime something won't work on our side, we would have source of truth.
Another point is to have this under ExoPlayer example is to test compatibility with Android SDK versions. For example we updated to targetSdk version 29, and companion banner isn't showing up properly. Contacting IMA SDK team, we found that they don't use ExoPlayer, but refer to https://github.com/googleads/googleads-ima-android/releases which is different implementation and doesn't work for us. That said it makes harder for us to prove that there is an issue in IMA SDK code, that prevents companion to be shown correctly in combination of ExoPlayer + IMA + Companion Banner
It sounds strange that this would break when changing targetSdkVersion to 29. Can you reproduce the same thing with the IMA SDK sample app? As regards this feature, I can't think of anything obvious we're doing that could make a difference.
Their IMA SDK Sample doesn't have exact use case. It doesn't render 300x250 ad unit as companion ad banner. It only counts for 320x50 companion ad banner. If I modify their example to render 300x250 ad unit, then it's not working properly.
I don't know what might be different in this case, but it seems like IMA extension for ExoPlayer works different comparing to their sample, as it result in blank white ad unit rending. Please see attached screenshots
This is IMA SDK Sample app with correct container sizes (300x250dp)

This is our sample project with correct companion ad container (300x250dp) + targetSDK 29. It does render correctly if I just change target sdk back to 28(no other changes)

This is our sample project if I change companion banner container to smaller size (320x50dp) to match IMA SDK Sample

So for us it would be much simpler to reference ExoPlayer IMA Demo project where everything setup, rather than providing and maintaining sample projects to prove that something isn't working properly on someone's else side.
Are you saying that from API 29 the size of the companion slot view makes a difference to whether the companion ad shows up, while when targeting API 28 it shows in both cases?
Yes. If I change target sdk to 29 then it's NOT showing up correctly with container size 300dp x 250dp, but works with smaller size. I didn't experiment with what exact size it should be, since it's breaking our functionality and ad unit requirements.
Having target sdk 28 IMA SDK renders 300dpx250dp ad unit normally.
For now I'd like to repurpose this issue to track the problem that companion ads don't show when updating to target API 29.
I'm not sure it's worth supporting companion ads in the main ExoPlayer demo app given that the API is pretty simple. Also, in the medium/longer term it's quite likely that at least one of the IMA SDK sample apps will start using the ExoPlayer IMA extension (TBC though).
This is also tracked by [Internal: b/142852592].
I think the IMA SDK release notes item "Adds scaling for Companion Ads on high-pixel-density devices." may address this and is included in IMA SDK version 3.18.1. The dev-v2 branch has picked that up (but see also the latest reply on #6429 for a caveat). If this is still reproducible on dev-v2 please let me know and I'll reopen the issue.
Note: it looks like this wasn't actually fixed in 3.18.1 but there is a fix coming in the upcoming IMA SDK version 3.20.1.
Most helpful comment
For now I'd like to repurpose this issue to track the problem that companion ads don't show when updating to target API 29.
I'm not sure it's worth supporting companion ads in the main ExoPlayer demo app given that the API is pretty simple. Also, in the medium/longer term it's quite likely that at least one of the IMA SDK sample apps will start using the ExoPlayer IMA extension (TBC though).