Admob wrong banner height

Hi everyone,

I’ve probably found a bug with method ads.height using the admob plugin.

Sometimes, the value returned by ads.height when my banner is refreshing seems too small. I usually get the value 44.41 which is correct but sometimes I get the value 29.61 which is incorrect because the new banner has the same height than the previous one on my nexus 5 screen. Sometimes it’s even the same ad but the value is different. Thus, the ad is showing over my game menu on 44.41 - 29.61 pixels to be accurate, because visually the banner height seems to be 44.41 but ads.height returns 29.61 :confused:

Did someone have the same issue ?

Hi,

I have the same problem. On my test device (samsung GT-I9300 / Android 4.3) I usually get 150 for ads.height(). But sometimes I get 84.375 for the same ad banner. Do you know any workaround for this bug?

build number: 2731

deniz.

Hi @david.ciaudo, deniz,

It would help if we could see some code, and also see how you’ve set up your content area in config.lua.

Brent

Hi! This is my config file :

[lua]application = {

content = {

width = 320,

height = 480, 

scale = “letterBox”,

fps = 60,

imageSuffix =

        {

            ["@2"] = 2,

            ["@3"] = 3,

            ["@4"] = 4,

        },

}, 

}

[/lua]

The code to display the admob banner is classic :

ads.show( “banner”, { x=display.screenOriginX, y=100000, appId=bannerAppID } )

I use the trick “y=100000” to put the banner at the bottom of my app. However I have some troubles to display my menu buttons above it because, sometimes, admob returns wrong banner height as I said. By the way, I’m using corona build 2646.

At the moment I have a very dirty workaround :

local offsetYPub = math.max(44,ads.height())

I’ve already tried to ads.hide() ads.show() a new banner when my app receives a refresh event from admob. But it does not fix the problem. What is really weird is when admob gives me the same banner but the ads.height() returns a different value…

smart ads come in 30,50,90 px high versions, depending on device screen height (in dp).  sounds like both posters are getting two different sized ads:  30/50ths gives right ratio for OP’s problem, 50/90ths gives right ratio for second poster’s problem.

since (in theory) screen height should be a “constant” (for a single specific test device), look for things that might alter it:  do they support orientation?  do they support immersive mode?  (android)  do they toggle the status bar on/off?  etc

if none of that is going on then monitor adb logcat for admob’s requests/responses and see if either sending wrong-sized screen or returning wrong-sized ad (given a specific device’s screen height in dp you can calc which size it SHOULD have returned).  finally, if request/response both appear correct, then something must be amiss in how ads.height() calcs its return…

hth

I also use “letterbox” content scaling with content width = 1080 and content height = 1920.

@davebollinger:

This is the device output log messages from android logcat (./adb logcat | grep Ads)

I/Ads     (15808): Starting ad request.

I/Ads     (15808): Use AdRequest.Builder.addTestDevice(“XXXXXYYYYYZZZZZ”) to get test ads on this device.

I/Ads     (15808): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.

I/Ads     (15808): Ad finished loading.

 

I can not find any admob request/response log messages. Am i missing something?

My app supports only portrait orientation, the status bar is always hidden and my app does not support immersive mode.

I don’t understand what you mean about “sending wrong-sized screen or returning wrong-sized ad”.

When I print the display.contentHeight in the response where I get the value of the banner, the result is always 480.

By the way I found another little problem. I did a screenshot of my app :

N3xMUqf.png?1

As you can see, there is a little space where we can see the rest of my game between the banner and the bottom of the screen, yet the banner height is still 44.41

This banner was displayed at the start of my app using the code below:

ads.show( “banner”, { x=display.screenOriginX, y=100000, appId=bannerAppID } )

It looks like even the trick to put banner at the bottom of an app is not working properly either.

For info, it was the first banner displayed when I did my test and then after an auto refresh, I got a new banner with no problem. Height value ? Still 44.41

I2fPEJa.png

Then after another refresh I got the same banner but with a wrong ads.height() as you can see with position the green circles (29.61 instead of 44.41 which is my original problem):

4XtjwFG.png

For info, greenCircle.y = display.screenOriginY + display.contentHeight + math.abs(display.screenOriginY) * 2 - ads.height() - greenCircle.height/2

I definitely think something must be amiss in how ads.height() calcluates its return… which leads to 2 display problems :confused:

Putting ads in a game is the kind of thing that make my users angry, but they will definitly kill me if it causes display bug!

it may be that admob has since “silenced” the network traffic, have you tried it without the grep?  (it’s been a while, but IIRC it was tagged under network or something)

your content size shouldn’t (in theory) matter.  your content size will scale the number returned by ads.height() (since it’s provided in terms of content pixels), but it shouldn’t affect which actual ad size (in absolute unscaled pixels) is requested/returned – that should be determined solely by device’s device-independent pixels (dp) height, which has nothing to do with your content size.

>> I don’t understand what you mean about “sending wrong-sized screen or returning wrong-sized ad”.

doesn’t matter - it’s nothing YOU have control over, it’s admob internals, and it sounds like you can no longer see the request/response in the logcat anyway.

>> When I print the display.contentHeight in the response where I get the value of the banner, the result is always 480.

contentHeight is simply whatever value you set it to in config.lua – has nothing to do with admob.

the screenshot with your positioning problem would seem to be a smaller-height ad (probably the 30px, given your ratios) wrapped in the “textile” background (to make it 50px, to suit your display height) – maybe THAT’s the combination that fools the plugin.  (actual ad is 30px, but occupies as if 50px, because of the textile padding – maybe ads.height() is returning a value that doesn’t include the padding???)  and if it’s calc’ing the wrong height, then maybe that’s also why it’s positioning it incorrectly.

note that this is all just conjecture.  without being able to see the actual request/response it’ll now be very difficult to do a DIY diagnosis.

I’ve done some research and found another thread about this problem :

https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjFweOn77HJAhXBPxoKHQ6dBmYQFgggMAA&url=https%3A%2F%2Fforums.coronalabs.com%2Ftopic%2F53212-admob-wrong-adsheight-for-some-ios-devices%2F&usg=AFQjCNG9aGYD6X8tQFu5LhDZGMZzckyzGQ&sig2=m9wKLPwpAyUGBg1LGywbyQ&cad=rja

Unfortunately, it seems that the bug has not be solved after one year :frowning:

Hi,

I have the same problem. On my test device (samsung GT-I9300 / Android 4.3) I usually get 150 for ads.height(). But sometimes I get 84.375 for the same ad banner. Do you know any workaround for this bug?

build number: 2731

deniz.

Hi @david.ciaudo, deniz,

It would help if we could see some code, and also see how you’ve set up your content area in config.lua.

Brent

Hi! This is my config file :

[lua]application = {

content = {

width = 320,

height = 480, 

scale = “letterBox”,

fps = 60,

imageSuffix =

        {

            ["@2"] = 2,

            ["@3"] = 3,

            ["@4"] = 4,

        },

}, 

}

[/lua]

The code to display the admob banner is classic :

ads.show( “banner”, { x=display.screenOriginX, y=100000, appId=bannerAppID } )

I use the trick “y=100000” to put the banner at the bottom of my app. However I have some troubles to display my menu buttons above it because, sometimes, admob returns wrong banner height as I said. By the way, I’m using corona build 2646.

At the moment I have a very dirty workaround :

local offsetYPub = math.max(44,ads.height())

I’ve already tried to ads.hide() ads.show() a new banner when my app receives a refresh event from admob. But it does not fix the problem. What is really weird is when admob gives me the same banner but the ads.height() returns a different value…

smart ads come in 30,50,90 px high versions, depending on device screen height (in dp).  sounds like both posters are getting two different sized ads:  30/50ths gives right ratio for OP’s problem, 50/90ths gives right ratio for second poster’s problem.

since (in theory) screen height should be a “constant” (for a single specific test device), look for things that might alter it:  do they support orientation?  do they support immersive mode?  (android)  do they toggle the status bar on/off?  etc

if none of that is going on then monitor adb logcat for admob’s requests/responses and see if either sending wrong-sized screen or returning wrong-sized ad (given a specific device’s screen height in dp you can calc which size it SHOULD have returned).  finally, if request/response both appear correct, then something must be amiss in how ads.height() calcs its return…

hth

I also use “letterbox” content scaling with content width = 1080 and content height = 1920.

@davebollinger:

This is the device output log messages from android logcat (./adb logcat | grep Ads)

I/Ads     (15808): Starting ad request.

I/Ads     (15808): Use AdRequest.Builder.addTestDevice(“XXXXXYYYYYZZZZZ”) to get test ads on this device.

I/Ads     (15808): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.

I/Ads     (15808): Ad finished loading.

 

I can not find any admob request/response log messages. Am i missing something?

My app supports only portrait orientation, the status bar is always hidden and my app does not support immersive mode.

I don’t understand what you mean about “sending wrong-sized screen or returning wrong-sized ad”.

When I print the display.contentHeight in the response where I get the value of the banner, the result is always 480.

By the way I found another little problem. I did a screenshot of my app :

N3xMUqf.png?1

As you can see, there is a little space where we can see the rest of my game between the banner and the bottom of the screen, yet the banner height is still 44.41

This banner was displayed at the start of my app using the code below:

ads.show( “banner”, { x=display.screenOriginX, y=100000, appId=bannerAppID } )

It looks like even the trick to put banner at the bottom of an app is not working properly either.

For info, it was the first banner displayed when I did my test and then after an auto refresh, I got a new banner with no problem. Height value ? Still 44.41

I2fPEJa.png

Then after another refresh I got the same banner but with a wrong ads.height() as you can see with position the green circles (29.61 instead of 44.41 which is my original problem):

4XtjwFG.png

For info, greenCircle.y = display.screenOriginY + display.contentHeight + math.abs(display.screenOriginY) * 2 - ads.height() - greenCircle.height/2

I definitely think something must be amiss in how ads.height() calcluates its return… which leads to 2 display problems :confused:

Putting ads in a game is the kind of thing that make my users angry, but they will definitly kill me if it causes display bug!

it may be that admob has since “silenced” the network traffic, have you tried it without the grep?  (it’s been a while, but IIRC it was tagged under network or something)

your content size shouldn’t (in theory) matter.  your content size will scale the number returned by ads.height() (since it’s provided in terms of content pixels), but it shouldn’t affect which actual ad size (in absolute unscaled pixels) is requested/returned – that should be determined solely by device’s device-independent pixels (dp) height, which has nothing to do with your content size.

>> I don’t understand what you mean about “sending wrong-sized screen or returning wrong-sized ad”.

doesn’t matter - it’s nothing YOU have control over, it’s admob internals, and it sounds like you can no longer see the request/response in the logcat anyway.

>> When I print the display.contentHeight in the response where I get the value of the banner, the result is always 480.

contentHeight is simply whatever value you set it to in config.lua – has nothing to do with admob.

the screenshot with your positioning problem would seem to be a smaller-height ad (probably the 30px, given your ratios) wrapped in the “textile” background (to make it 50px, to suit your display height) – maybe THAT’s the combination that fools the plugin.  (actual ad is 30px, but occupies as if 50px, because of the textile padding – maybe ads.height() is returning a value that doesn’t include the padding???)  and if it’s calc’ing the wrong height, then maybe that’s also why it’s positioning it incorrectly.

note that this is all just conjecture.  without being able to see the actual request/response it’ll now be very difficult to do a DIY diagnosis.

I’ve done some research and found another thread about this problem :

https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjFweOn77HJAhXBPxoKHQ6dBmYQFgggMAA&url=https%3A%2F%2Fforums.coronalabs.com%2Ftopic%2F53212-admob-wrong-adsheight-for-some-ios-devices%2F&usg=AFQjCNG9aGYD6X8tQFu5LhDZGMZzckyzGQ&sig2=m9wKLPwpAyUGBg1LGywbyQ&cad=rja

Unfortunately, it seems that the bug has not be solved after one year :frowning: