googleads / googleads-mobile-ios-mediation

Apache License 2.0
120 stars 137 forks source link

Admob's Adaptive Banners cause Facebook banner requests to not fill with "Display format doesn't match" #210

Closed smartestapps closed 4 years ago

smartestapps commented 4 years ago

Ever since switching to Admob's adaptive banners, my Facebook banners that I have under Admob's mediation are not filling as much with the error message: "Display format doesn't match". When I checked the ad request format, it tells me that about 1/3 to 1/4 of the calls are for Interstitial display formats. I've never had this issue before when I was still using the Facebook SDK and adapters from 2019 and before switching to adaptive banners. I even tried to force the banner ad size to be 320x50 for any heights returned above 250, and it still makes calls that Facebook thinks is for their Interstitial display format. I'm wondering if this is a known issue and can be fixed or if I should stop using adaptive banners or if there's some code that I could add to prevent Facebook from getting an invalid ad size for their banner ads. Thank you.

ericleich commented 4 years ago

@smartestapps https://github.com/googleads/googleads-mobile-ios-mediation/blob/master/adapters/Facebook/FacebookAdapter/GADFBBannerAd.m#L26-L60 is the code that's doing the mapping, assuming you use the latest adapter. I do see a bug here in that this code shouldn't use look at kFBAdSizeInterstitial as a potential size. Having said that, the kFBAdSizeInterstitial.size is mapping to 0x0, and if it's matching that, then after the fix I still expect you'd run into an earlier (but better descriptive) error: "Invalid size for Facebook mediation adapter. Size: %" for your case.

What size are you requesting when you're getting that error? Are any of your requests less than 320x50?

smartestapps commented 4 years ago

Thank you, Eric, for the response.

Yes, I'm using the newest facebook sdk and adapters. I have no idea what size is being requested that is causing the fill error. Facebook isn't telling me what the exact size of the requests that fail are. It just says that the display format is incorrect and shows that the request was for an interstitial ad. I don't know if any request will be less than 320x50, but that gives me an idea to run a test case for that situation and to block out requests for that.

Can you think of any other test cases I should test for so that only valid requests are made? I'm thinking about blocking any ad requests where:

1) Height is more than 250.

2) Width is less than 320.

3) Height is less than 50.

That's a quick fix on my end. But for the long term, the Facebook adapter should be updated to prevent the interstitial ad format from ever being requested for the adaptive banner ad format because Facebook made it impossible for their ad banners to display interstitial ads even though they support interstitial ads in general.

I'm only talking about iOS apps, so it should only be whatever iOS devices are available now. I'm using the exact code that was written in the instruction guide for adaptive banners in Admob. For someone with more free-time and will than me, they could run through all the limited iOS resolutions and figure out which device will do this, but I don't think it's necessary. We can just fix this issue by editing the following code:

Lines 35-38:

NSArray *potentials = @[ NSValueFromGADAdSize(banner50), NSValueFromGADAdSize(banner90), NSValueFromGADAdSize(mRect), NSValueFromGADAdSize(interstitial) ];

should be changed to:

NSArray *potentials = @[ NSValueFromGADAdSize(banner50), NSValueFromGADAdSize(banner90), NSValueFromGADAdSize(mRect) ];

Line 34 and 47 - 49 should be deleted.

Can someone push out an update to the adapter soon so that I can update my app? Thanks.

ericleich commented 4 years ago

@smartestapps Yes we will make that change shortly and plan to have a release out this week.

In case I wasn't clear before, I'm still not convinced this fix will entirely address your issue. GADClosestValidSizeForAdSizes() returns a size matching one of the inputs, but also requires 50% width and 70% height of the size requested by Google. This is done to ensure that if you make a large ad request, the ad network doesn't return a small ad (e.g. a 320x50 for a 728x90).

The interstitial size ended up being 0x0, so it's odd that got chosen in the first place, but I also suspect that by removing that size, you may still end up with no valid size and still a no fill. But at least you'll get a better error message.

smartestapps commented 4 years ago

@ericleich Just to be clear, are you suggesting that GADClosestValidSizeForAdSizes() will return an invalid size even if you only provide it with a list of valid sizes in the potential list? I thought that by removing the interstitial size as one of the potential ad sizes that it would be forced to choose a valid size (the closest valid size).

ericleich commented 4 years ago

@smartestapps Here is the documentation for GADClosestValidSizeForAdSizes(). This can return kGADAdSizeInvalid if no there is no potential size close to the size you're requesting. The "configurable fractions" are 50% width and 70% height currently.

So if you were to request 300x200 for example, Facebook's 250 height is too big, and Facebook's 90 and 50 height is too small, and so that request would return kGADAdSizeInvalid.

Now, I'm not sure how any request would have matched kFBAdSizeInterstitial in the first place, seeing as that size is 0x0. Unless you somehow made a 0x0 request.

Anyhow, https://github.com/googleads/googleads-mobile-ios-mediation/commit/9a062195783552c0a6b7d804c335187ee7966d54 went into the 5.8.0.2 release, so now if you make a request that doesn't match a size with the new version, you should get the clearer error message that'll help us further debug if there's still an issue. Please file a new issue if you're still running into issues, and we can debug further why the adapter may still not like your requested ad size.