Interstitial ad flickering

242 views
Skip to first unread message

Juan Carlos Ospina Gonzalez

unread,
Sep 23, 2015, 6:17:04 AM9/23/15
to Google Mobile Ads SDK Developers
Hello,

I have a Cordova app that loads an interstitial ad (PublisherInterstitialAd) . When the ad appears on screen there is a horrible flickering when the ad fades in/out. Any idea how to solve this on an INTERSTITIAL (PublisherInterstitialAd) ad?

Tested on 

Nexus5 - Android M
Samsung Galaxy Tab 2 - Android L

Thanks.

Vu Chau (MobileAds SDK Team)

unread,
Sep 23, 2015, 12:53:30 PM9/23/15
to Google Mobile Ads SDK Developers
Hi Juan Carlos,

Since you see the issue in a Cordova app, we would also like to obtain confirmation on whether the issue also occurs in our native Android sample app.  Could you give it a try and let us know your findings?

You may also privately send us the ad unit IDs for the interstitial so we can also take a look.

Thanks,

Vu Chau
Mobile Ads SDK Team

Juan Carlos Ospina Gonzalez

unread,
Sep 24, 2015, 3:47:54 AM9/24/15
to Google Mobile Ads SDK Developers
Vu,

I have finally figured out the problem and it's a bit of an obscure topic and has nothing to do with Cordova. For the sake of the sanity of future developers, i hope it becomes mentioned in the documentation for PublisherInterstitialAd in the future.

Here's the deal:

It's hard to say exactly what's happening behind the scenes of PublisherInterstitialAd, but what caused the problem for me was that i was doing a locale configuration change in my Application class. What triggered the issue was:

Configuration config = getBaseContext().getResources().getConfiguration();

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    config
.setLocale(mLocale);
   
} else{
    config
.locale = mLocale;
}
getBaseContext
().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

Where:

mLocale

is a Locale object that contains a change to the Locale.

Once i removed this, the flickering stopped. 

Here's the flickering by the way https://www.youtube.com/watch?v=AfKbrw2qQmg

What this suggested to me is that perhaps by handling the configuration change myself, the flickering would stop:

...
<application
        android
:name="com.myapp.myapp"
        android
:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
        android
:allowBackup="true"
        android
:hardwareAccelerated="true"
        android
:icon="@drawable/icon"
....
 
But that doesn't do it. Doing the same for the activity doesn't help either.

So... is there a way this should be handled to avoid having PublisherInterstitialAd do whatever it is it is doing and void this flickering?

Thanks

Vu Chau (MobileAds SDK Team)

unread,
Sep 24, 2015, 4:52:31 PM9/24/15
to Google Mobile Ads SDK Developers
Hi Juan Carlos,

I'm not seeing this flickering after adding the code that manipulates the locale.  Perhaps I'd need you to shed some light on how your mLocale object is defined.

On the device where you see the issue happening, is the device using a custom ROM?  Does this issue happen on other devices as well?

Thanks,

Vu Chau
Mobile Ads SDK Team

Juan Carlos Ospina Gonzalez

unread,
Sep 25, 2015, 3:00:12 AM9/25/15
to Google Mobile Ads SDK Developers
Vu,

I was changing the region and language in the locale object to "force" the whole app's Locale preference. The code is placed at the Application level, that is, an Application subclass rather than an Activity.

      // internal reference a modified Locale
    private Locale mLocale = null;

    @Override
    public void onCreate()
    {
        super.onCreate();
        
        //get device region and language
        Locale locale = Locale.getDefault();
        String lang = locale.getLanguage();
        String region = locale.getCountry();

        Log.d(TAG, "original country code: " + lang + "-" + region);

        //read the available locales
        String filteredRegion = "DE";
        String filteredLanguage = "de";
       
        // .. a bunch of if's here, can't share for privacy reasons...
     
        Configuration config = getBaseContext().getResources().getConfiguration();
       
if (!config.locale.getLanguage().equals(filteredLanguage) && !config.locale.getCountry().equals(filteredRegion))
       
{
           
Log.d(TAG,"forcing "+filteredLanguage+"-"+filteredRegion);
            mLocale
= new Locale(filteredLanguage, filteredRegion);
           
Locale.setDefault(mLocale);

           
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                config
.setLocale(mLocale);
           
} else{
                config
.locale = mLocale;
           
}
            getBaseContext
().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
       
}


filteredLanguage and filteredRegion are two Strings that i do filtering on ... but basically the values would end up being either "es" and "ES" or "de" and "DE" respectively. 

The devices did not have any custom ROMs. The Nexus 7 and 5 have stock versions of Android, although Samsung has the Samsung version. 

It seemed to me like the interstitial is re launching itself. It's a very similar effect to what you see when you forget that your Activity can be re-created multiple times with configuration changes and you have put the request code on the onCreate method of your Activity... but im speculating. 

I don't have a lot of time available today, but ill make sure to create a sample project on github to duplicate the bug consistently and share it here, hopefully before Monday.  

Thanks for being prompt to reply, i really appreciate it. 

Tristan Emrich

unread,
Sep 25, 2015, 6:53:33 PM9/25/15
to Google Mobile Ads SDK Developers
Hi Juan Carlos,

When you get the chance, can you please send a sample that reproduces the issue.  That will make it easier for us to debug and see what might be causing the interstitial flickering.

Thank you!

Juan Carlos Ospina Gonzalez

unread,
Sep 26, 2015, 12:39:17 PM9/26/15
to Google Mobile Ads SDK Developers
Vu, Tristian

I duplicated the setup with the Application subclass but you were right that the Locale configuration change was not enough to trigger the problem. Even though removing it solved the problem for me, there might be other factors that also contribute. I have to experiment more to figure out a minimum setup to reproduce this issue.
--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/b1K4Ow59eWY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tristan Emrich

unread,
Sep 28, 2015, 12:14:24 PM9/28/15
to Google Mobile Ads SDK Developers
Hi Juan Carlos, 
Thank you for keeping us updated.  Please let us know if you have any additional questions.

Tristan

On Saturday, September 26, 2015 at 9:39:17 AM UTC-7, Juan Carlos Ospina Gonzalez wrote:
Vu, Tristian

I duplicated the setup with the Application subclass but you were right that the Locale configuration change was not enough to trigger the problem. Even though removing it solved the problem for me, there might be other factors that also contribute. I have to experiment more to figure out a minimum setup to reproduce this issue.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages