Bug: sometimes UnifiedNativeAdView.mediaContent.aspectRatio is 0, and sometimes it doesn't match the one of the video at all

269 views
Skip to first unread message

AD_LB

unread,
Aug 4, 2020, 6:45:36 AM8/4/20
to google-adm...@googlegroups.com
On the POC that's attached here, I sometimes get an aspect ratio for the video/image to be 0.

On a real app, I get it non-zero, but sometimes it shows a value that doesn't meet the one that's shown.

I wanted to use this information to make it fit the width (but up to some height that I set as the max height for it).
I tried using ConstraintLayout, but seeing that I failed, I did the calculation myself, and then noticed that it's wrong by itself, without being related to ConstraintLayout (though I might have made a mistake there too).

For example, I got an aspect ratio of 1.5, so since the MediaView has a width of 1080px, it should be of the height 720px.
However, when I set it, I can see (I've put a background for it) that its content is smaller. It's 608px instead.
So it should have been 1.777... instead (1080/608). Very far from 1.5

Tested on Pixel 4 Android R beta 2.5.
    implementation 'com.google.android.gms:play-services-ads:19.3.0'



NativeAdvancedExample.zip
2020-08-04_13-40-53.png
Untitled.png
2020-08-04_13-39-49.png

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 4, 2020, 12:55:19 PM8/4/20
to lbl...@gmail.com, google-adm...@googlegroups.com
HI AD_LB,

Thank you for presenting us with this question. So based on the information that you have given here is how I would suggest that you go about trying to fix this.

Giving your height any constraint is generally bad UI/UX as it will usually not scale well that way. Especially if you want to have it scale edge to edge horizontally. When doing most layout designs, you should aim for horizontal and then deal with what happens on the vertical. As this is usually just easier to handle and with least complications. Other wise if you do the horizontal constraint. Then you have a very high risk of having the ad not go edge to edge.

Now in the case of when you did the custom scaling? And the height did not match up? Thats actually fine. As you can set the height of the View to "wrap_content". Which from a UI / UX POV is much easier to work with.

Regards,
William Pescherine
Mobile Ads SDK Team

ref:_00D1U1174p._5004Q23HP3p:ref

AD_LB

unread,
Aug 4, 2020, 1:53:59 PM8/4/20
to Google Mobile Ads SDK Developers
This is not a question.
It's a bug.
The docs state that it will be the aspect ratio of the video, and of the image if there is not video.
What I got is either 0.0 which doesn't make sense, or something that's incorrect.

As for your suggestion, this won't work, because even though the purpose is to set it take the whole width, I don't want to make it too high, because the screen shouldn't contain just the ad or mostly ad. It has its own UI that I want to show. And I made it flexible so that if I think there isn't enough space, I don't show the image/video, and use a design that's more minimal. 
So the priorities for me are:
1. Too much height: use a more minimal ad (banner-style)
2. Up to some height : fit to width
2. Somewhere in between (not too much height, but also has enough height) : letterbox.

So it must have some limit as to how high it will be.
Using "wrap_content" could let it go wild, and currently the aspect ratio that I get isn't reliable due to the 2 possible cases I've mentioned.

BTW, your email notifications here is flawed. I don't see links to the post. I have to manually find it each time.

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 4, 2020, 3:29:41 PM8/4/20
to lbl...@gmail.com, google-adm...@googlegroups.com
HI Liran,

Thank you for bring more information about this to us.

As I have stated in the previous posts that have also been dealing with this and many other issues that you are having. I would ask if you can send us in a sample of the app. So that we can look more into this for you. And help to resolve this issue for you.

As for how to handle the View for your Ad container? I would recommend that you just have the ad fixed on a given size and allow for it to be populated with the items that you can get. There by allowing for a better UX where the ad size is not jumping all over the place if sizes change. This is also why I would suggest the adaptive banners. But if you want to keep it native. I would suggest to standardize your XML view and just go from there.

AD_LB

unread,
Aug 5, 2020, 2:57:42 AM8/5/20
to google-adm...@googlegroups.com
The sample of Google should suffice, with a few adjustments to handle the aspect ratio.
For some reason I don't see 0 on the sample, but I do see incorrect aspect ratio. Perhaps for 0 to appear, you have to use real ad units IDs.
Attached here a sample of it, as well as a screenshot to show the issue.

As for your suggestion, it won't work, because:
1. Fixed size doesn't mean it won't be letterboxed. In fact it has a very high chance of being as such, and this looks bad compared to other types of ads, which loses the point of having control and making things look better.
2. Adaptive banners are not native at all. They are not efficient (use WebView). They don't offer any customization. They don't have videos either. There is nothing similar to native ads that you offer that has the same advantages.
3. The XML can't handle the aspect ratio you provide and using the rules I've set. It's not that flexible. Even a more basic usage failed for me : using ConstraintLayout and set the max height the mediaView can reach. It has to be in code, sadly, and the aspect ratio you provide isn't reliable at all.

Can you please fix the communication here?
I keep seeing just "ref" instead of the conversation and links to the forum.
There is no context. I can't see what you wrote before, and I can't see what I wrote before.
Each time I get an email, I lose the context. I lose the entire conversation. I need to reach the forum again and find where is what you wrote.

And even when I do write a reply here, I can't attach files to it. I have to first post without files, and then edit it and add them.
NativeAdvancedExample.zip
2020-08-05_09-50-02.png

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 5, 2020, 6:20:44 AM8/5/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for getting back to us. However, I wasn't able to reproduce the issue on my end. Since you mentioned that the behavior intermittently occurs, then it appears that the behavior triggers on a specific creative. With this, would it be possible for you to provide a Charles log (see instructions here) capturing the behavior? This will greatly help us in our investigate as this will enabling us to test the ad in our test App environment by trafficking the creative in the test network.

Regards,
Teejay Pimentel

AD_LB

unread,
Aug 5, 2020, 6:28:23 AM8/5/20
to Google Mobile Ads SDK Developers
No. Please present an easier alternative.
Have you looked at the images I've sent? Can you please show me what you get?

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 5, 2020, 10:47:58 AM8/5/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

Attached is a screenshot of what we get when we run the app that you included in the file. I have seen the 0 aspect ratio and have sent that to our team to look at more. Also I have played around with resizing the ad. As you will see from this sample, the issue is that it will not reduce beyond a certain point. But I was able to enlarge it no issue.

Also Charles is a standard technology for us to use to be able to track the events of the app so that we can look into what is happening better. You can get it here .

Regards,
William Pescherine
Screen Shot 2020-08-05 at 10.38.17 AM.png

AD_LB

unread,
Aug 5, 2020, 10:59:44 AM8/5/20
to google-adm...@googlegroups.com
According to your screenshot, you actually failed to reduce it to the correct height that matches the aspect ratio (I see 2 different green colors, and the different one is above and below the video/image), so you've reproduced the issue and it should be enough for you to find how to fix the issue.

About Charles, if you still need something like that, please provide an alternative. I've failed using it, and I've spent enough time trying to configure it.
2020-08-05_17-59-33.png

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 5, 2020, 12:28:52 PM8/5/20
to lbl...@gmail.com, google-adm...@googlegroups.com
HI AD_LB,

So regarding the video and aspect that is being looked into now. The change of the size of the video is currently under review. As for the green area above and below? Those are as intended. The most outer green area is the first LinearLayout that is then holding 2 other layouts inside it. The inner green is in fact the second LinearLayout that sits inside the first. The mediaView which sits inside both of those linearLayouts is being covered by the ad. As I set that background color to black. So if you are expecting the video ad to cover the green area above and below. that is not how that would happen. 

If you want to completely cover the area that is green with an ad. You would have to do several different things. Depending on what you expect the UI to actually look like. Along with how scaling works you would not get vertical stretch on a video.

Again Charles is what we use. Without that it will be very difficult to see what is happening.

AD_LB

unread,
Aug 5, 2020, 2:12:51 PM8/5/20
to Google Mobile Ads SDK Developers
Guys you asked for a sample, and you changed it too much so I can't comment on it properly anymore...
I thought you just changed the color. How could I now guess what you did there?
In any case, the colors are for showing the area the ad takes, compared to the container.
Again, the bug that I reported here is that:
1. Aspect ratio is sometimes 0, even though it shouldn't.
2. Aspect ratio is sometimes different than what the video shows.

Please focus on those issues instead.

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 5, 2020, 4:17:16 PM8/5/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

So as stated for the fact that you are getting the 0 for your aspect ratio. We are currently looking into this. And we will get back to you once we have a solution to offer you for that.

As for the aspect ratio and making sure you have the correct height. I have had to look into a few more things and check out some conversions. So here is the thing, the 608px height for a 1080 px width. Is actually correct when using an aspect ration of 16:9 which makes sense from what you have stated. Here is a link to aspect ratio and keeping within them. As you will see 1080 is not standard. But when applying the 16:9 ratio to it with the numbers that you gave me. This holds as true. 
  • 608/1080 = 576/1024 both equal 5.62 thus scaled properly 
  • x/1080 = 576/1024 and solve for x will give you 607.5 or the 608 rounding up that you got
  • 1024x576 is a 16:9 aspect ratio
  • 1080x608 is also a 16:9 aspect ratio
If you are planning for a smaller height then you will have to worry about side bars with your video. As again videos will always stick to their aspect ratio.

AD_LB

unread,
Aug 10, 2020, 5:56:58 PM8/10/20
to Google Mobile Ads SDK Developers
The aspect ratio I got was 1.5, so since the MediaView had a width of 1080px, it should be of the height 720px.
How exactly did you get to these numbers that you say are correct?
1.5 is 3/2.
Means the width should be 1.5 times the height.
720*1.5 = 1080.
Getting 608 is incorrect. It's not the same aspect ratio at all.
Asepct ratio is width/height.
The width is 1080.
so the formula you need to solve is:
1080/x = 1.5
So x= 1080/1.5 = 720 .


How did you get that 608 is correct?

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 10, 2020, 11:56:32 PM8/10/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,


Thank you for getting back to us.

As per checking, the issue wherein you're getting the 0 for your aspect ratio has been raised to the team for further investigation. We'll let you know the soonest we have our findings. With regard to the 2nd issue wherein the aspect ratio is sometimes different than what the video shows, it would much be appreciated if you could provide us a Charles log (see instructions here) capturing the behavior as this will greatly help us in our investigation.

Regards,
Teejay Pimentel
Message has been deleted

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 11, 2020, 11:50:02 PM8/11/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

I could see that you were able to reproduce the behavior on your end. Kindly capture the mobile session using the following link: Kindly use the Reply privately to author option to share the details privately.

AD_LB

unread,
Aug 12, 2020, 2:06:17 AM8/12/20
to Google Mobile Ads SDK Developers
See previous comments:

I'm unable to use this tool. I tried for hours to use it and it didn't work for me. Offer something easier that I can send you.
Or let me send you logs of the SDK instead.

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 12, 2020, 5:56:34 AM8/12/20
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

I've shared this to the team for further investigation. We'll update this thread the soonest we have our findings.

Mobile Ads SDK Forum Advisor

unread,
Sep 19, 2022, 2:40:18 PM9/19/22
to lbl...@gmail.com, google-adm...@googlegroups.com
Hello,

I hope everyone is doing fine and safe.

I just want to circle back on this and share that the issue reported here has been fixed.

Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q23HP3p:ref

Liran Barsisa

unread,
Jun 22, 2023, 3:28:32 AM6/22/23
to Google Mobile Ads SDK Developers
It actually became worse.
Today I saw an ad that reported aspect ratio of 1, even though it clearly isn't as such.
It also has an icon that is white, which is a problem because the background is white.
You should have better instructions to advertisers, and protection against such cases.
You should also have some instructions for native ads for developers, of recommended backgrounds so that the content of the ad will always be visible.
Here's a screenshot of what I got, showing both issues:
2023-06-22_10-27-45.png

Liran Barsisa

unread,
Jun 22, 2023, 4:40:51 AM6/22/23
to Google Mobile Ads SDK Developers
Created new one as this was said to be fixed:
https://groups.google.com/g/google-admob-ads-sdk/c/tVY8SgDWicI

Mobile Ads SDK Forum Advisor

unread,
Jun 23, 2023, 1:45:34 AM6/23/23
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

Thank you for opening up a new thread. Let's continue on your thread instead for better tracking of your concern.
 
This message is in relation to case "ref:_00D1U1174p._5004Q23HP3p:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages