question

sbc-games avatar image
sbc-games asked

AdLayout is not displayed (is invisible) sometimes

Hello, I have strange problem. Amazon ads works for me well most of the time. In test mode I always get call to onAdLoaded method of listener. But sometimes the ad is not displayed. It is not displayed but callback says it was succesfuly loaded and the area where it should be is active - so it is just invisible. I can click the invisible ad to launch browser. Then (usually) when I return to the app the ad is probably somehow redrawn and becames visible. I noticed from logCat that when i get this everything is OK (last 2 lines are from onAdReceived callback). In this case there is first 4 times log on resources loaded, then events are fired and finally callback is called: 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Loaded resource: http://g-ecx.images-amazon.com/images/G/01/mobile/adchoices/img_background_gray_tr_l.png 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Loaded resource: http://g-ec2.images-amazon.com/images/G/01/mobile/testing/Pinzon_728x90._V381238266_.jpg 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Loaded resource: http://g-ecx.images-amazon.com/images/G/01/mobile/adchoices/img_text_v2.png 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Loaded resource: http://g-ecx.images-amazon.com/images/G/01/mobile/adchoices/img_icon.png 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Fire changes: {screenSize: { width: 800, height: 1232 }, viewable: false} 03-09 20:29:53.610: D/AmazonMobileAds MraidView(9714): Fire change: {state: 'default'} 03-09 20:29:53.620: D/AmazonMobileAds MraidView(9714): Fire change: {placementType: 'inline'} 03-09 20:29:53.630: D/AmazonMobileAds AdController(9714): adLoaded 03-09 20:29:53.630: D/AmazonMobileAds MraidView(9714): Fire change: {viewable: true} 03-09 20:29:53.720: D/AdsSystem(9714): AMAZON onReceiveAd 03-09 20:29:53.720: D/AdsSystem(9714): AdView width = 800, height = 90 Here is output when there is problem and ad is invisible. The order is always different. The callback is called and events fired before there are some log lines on resources loaded...: 03-09 20:32:09.750: D/AmazonMobileAds MraidView(9714): Loaded resource: http://ads.celtra.com/e9ec687d/amazon.js?&playVideoInCeltraPlayer=0&channelId=a96b0687&c=&scrollableParent=0&scriptId=celtra-script-1&clientTimestamp=1394393529.703 03-09 20:32:09.990: I/GATE(9714): DEV_ACTION_COMPLETED 03-09 20:32:09.990: D/AmazonMobileAds MraidView(9714): Fire changes: {screenSize: { width: 800, height: 1232 }, viewable: false} 03-09 20:32:09.990: D/AmazonMobileAds MraidView(9714): Fire change: {state: 'default'} 03-09 20:32:09.990: D/AmazonMobileAds MraidView(9714): Fire change: {placementType: 'inline'} 03-09 20:32:09.990: D/AmazonMobileAds AdController(9714): adLoaded 03-09 20:32:09.990: D/AmazonMobileAds MraidView(9714): Fire change: {viewable: true} 03-09 20:32:09.990: D/AdsSystem(9714): AMAZON onReceiveAd 03-09 20:32:09.990: D/AdsSystem(9714): AdView width = 800, height = 90 03-09 20:32:10.010: D/AmazonMobileAds MraidView(9714): Loaded resource: http://cache.celtra.com/api/creatives/e9ec687d/compiled/amazon.js?v=39-f46d8e3884&hasJson=1&secure=0 03-09 20:32:12.150: D/AmazonMobileAds MraidView(9714): Loaded resource: http://cache.celtra.com/api/blobs/41f5342b1954191410d160193fe358f6ca51082d91cc166ce2380c2404e291c8/728x90_v1.png 03-09 20:32:12.240: D/AmazonMobileAds MraidView(9714): Loaded resource: http://track.celtra.com/json/eyJldmVudHMiOlt7InNlc3Npb25JZCI6InMxMzk0MzkzNTI4eDUzMWNjMWI4OGJkMmI2eDM5Nzg2MTA3IiwiaW5zdGFudGlhdGlvbiI6IjU2Mzc1NDYzNzcyNTY1MTMiLCJpbmRleCI6MCwiY2xpZW50VGltZXN0YW1wIjoxMzk0MzkzNTMyLjE5OSwibmFtZSI6ImNyZWF0aXZlTG9hZGVkIn0seyJzZXNzaW9uSWQiOiJzMTM5NDM5MzUyOHg1MzFjYzFiODhiZDJiNngzOTc4NjEwNyIsImluc3RhbnRpYXRpb24iOiI1NjM3NTQ2Mzc3MjU2NTEzIiwiaW5kZXgiOjEsImNsaWVudFRpbWVzdGFtcCI6MTM5NDM5MzUzMi4yMTMsInVuaXROYW1lIjoiYmFubmVyIiwic2NyZWVuTG9jYWxJZCI6Mywic2NyZWVuVGl0bGUiOiJTdGFydCIsInNjcmVlbklzTWFzdGVyIjpmYWxzZSwib2JqZWN0TG9jYWxJZCI6bnVsbCwib2JqZWN0TmFtZSI6bnVsbCwib2JqZWN0Q2xhenoiOm51bGwsImluaXRpYXRpb25UaW1lc3RhbXAiOjEzOTQzOTM1MzIuMjExLCJuYW1lIjoic2NyZWVuU2hvd24iLCJmaXJzdCI6dHJ1ZX1dfQ==?crc32=-1978555284 Is it some bug in Ads SDK? Does the order of output have some meaning? Thanks for help!
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Sbc, Thank you for reaching out. From the log I can see your ad view's height and width are 800 and 90. Are you setting ad size manually? Manual Ad size is mentioned here : https://developer.amazon.com/appsandservices/apis/earn/mobile-ads/docs/understanding-api#Amazon%20Mobile%20Ad%20Network%20Concepts Below are the sizes available: AdSize.SIZE_300x50 AdSize.SIZE_320x50 AdSize.SIZE_300x250 AdSize.SIZE_600x90 AdSize.SIZE_728x90 AdSize.SIZE_1024x50 Can you please the post your code and layout xml?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sbc-games avatar image
sbc-games answered
Hi Sujoy, thanks for answer. I have quite sophisticated system for choosing ad size. I have region in my game dedicated for ads. This region is calculted based on device resolution and dp. My ads rotating system then chooses biggest ad from ad network that still fits into region. I was testing on Samsung Galaxy Tab with 800x1280 screen (and dp 1). So AdSize.SIZE_728x90 is the ad that was choosen. What you see in log output is then size of view, that has layout parameters width: match parent (800 ... screen size) and height: wrap content (90 ... ad height). I added the line to check if view exists even if I can not see it... As I wrote: In first case the ad is loaded, clickable, visible. In second case the ad is loaded, clickable but not visible. Yes, you can still click it and when you return from browser back to game the ad then becames visible... The problem appears only in second case when onReceiveAd is called and then there are next "Loaded resource" lines. Every time there is error the log output looks the same. Every time there is no error the log output looks like in the first case (all Loaded resource entries before onReceiveAd). Can it be that in second case callback is called but the data for ad are not still loaded? It is loaded a while after it was called? And thus clicking the invisible ad and returning back forces all the game views repaint and in this time as all the ad data are already delivered it is displayed? I am using FrameLayout and I will send it to you in the evening.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Thanks SBC for the confirmation. I am forwarding the issue to concerned team here for further investigation, I will get back to you shortly.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sbc-games avatar image
sbc-games answered
Hi, for completness here is my layout.xml:
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Sbc, Thanks for sharing layout. Please follow these steps: 1) Update to the latest SDK, which can be downloaded here: https://developer.amazon.com/ads 2) Make sure that the AdLayout's parent container does not have size WRAP_CONTENT x WRAP_CONTENT unless the AdLayout itself has a fixed size. If you are setting the AdLayout's layout parameters in the Java code then we recommend setting the AdLayout's dimensions to MATCH_PARENT x MATCH_PARENT and then setting its parent's dimensions to MATCH_PARENT x WRAP_CONTENT. See examples here: https://developer.amazon.com/public/apis/earn/mobile-ads/docs/quick-start#4.%20Add%20the%20Amazon%20Ad%20Layout%20to%20Your%20App If the problem is still not resolved then you should send us the segment of Java code in which the AdLayout is instantiated. You should also enable logging and send us a full logcat for before the ad request is made and up until the AdLoaded callback is seen; instructions for enabling logging can be found here: https://developer.amazon.com/public/apis/earn/mobile-ads/docs/testing-your-app#Debugging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sbc-games avatar image
sbc-games answered
Hi Sujoy, I tried plenty of possible combinations without luck first. Then I found that it may be problem in GLSurfaceView itself: - in my code I am forcing the view to be set to View.LAYER_TYPE_SOFTWARE. When doing this I get the behavior I am describing (most of the time ad loaded and displayed and sometimes loaded but invisible). But when loaded and displayed, it looks nice like this: https://sites.google.com/site/sbcgamesdev/blogfiles/Screenshot_2014-03-15-15-50-49.jpg - if I do not force the view layer to be View.LAYER_TYPE_SOFTWARE it looks like this: https://sites.google.com/site/sbcgamesdev/blogfiles/Screenshot_2014-03-15-15-51-56.jpg. Notice the white border on left and right side. But the ad is displayed every time and there is no problem. Why I think it is GLSurfaceView problem? Yesterday I was changing also AdMob from former separate SDK to Google Play services SDK where AdMob is included now. I encountered the same problem - ad was loaded correctly, was clickable, but was invisible. Fortunaltely I am not the only one who has the same problem - see this interesting thred: https://groups.google.com/forum/#!topic/google-admob-ads-sdk/avwVXvBt_sM Unfortunately the proposed workaround (setting transparent color) does not work for Amazon. I also found strange behavior for LiquidM ads. In the end it looks like you have to find correct way for disabling / enabling HW acceleration for every ads SDK separately. It remindes me that your engineers were probably solving something like this in GameCircle SDK as for API >= 11 there must be HW acceleration explicitly disabled in manifest. Anyway, thank you for your hep!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.