Admob highly slowing game (framerate)

Hi guys, I’m facing a problem with Admob and Android.
I followed some tutorials in order to get ads working with my project and Ads are working, they appear well.

But I’m having trouble getting the quality of my game stable.

I have scene dedicated to Ads (I found it easier to manage the time of loading of the ad without interfering with other objects in the game), with the DemoScript provided.

I have a menu in another scene which consists in 3 buttons coming from the right to the left of the screen.

After we do what we want with the ad, we go back to the menu.

And here is the strange thing that I’m facing:

  • If I REQUEST a banner, it appears fine. If I change scene without other commands, then the game starts getting slower (buttons looks like they suffer to translate).

  • If I REQUEST a banner, and then Destroy it, then it’s the same problem.

  • However, if I REQUEST a banner, and then Hide it (with/without destroying it after) , then there are no problems, everything is going smoothly.

  • If I REQUEST a interstitial, without showing/destroying, then if I go back to the menu, I have no problem.

  • If I REQUEST a interstitial, Show it, it appears ok. But then I have the laggy problem on my menu. Same situation trying to destroy it.

So my question is, is it normal that the AdMob plugin slows my game that much (I tried a lot of things, I figured out that maybe dedicating a scene for the Ads would be better, but it didn’t solve anything, and I’m out of ideas). It looks like the objects are never destroyed but I don’t know, this is the demo script !

Check it out:

using System;
using UnityEngine;
using System.Collections;
using GoogleMobileAds;
using GoogleMobileAds.Api;

// Example script showing how to invoke the Google Mobile Ads Unity plugin.
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
	
	public BannerView bannerView;
	public InterstitialAd interstitial;

	void OnGUI()
	{
		// Puts some basic buttons onto the screen.
		GUI.skin.button.fontSize = (int) (0.05f * Screen.height);
		
		Rect requestBannerRect = new Rect(0.1f * Screen.width, 0.05f * Screen.height,
		                                  0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(requestBannerRect, "Request Banner"))
		{
			RequestBanner();
		}
		
		Rect showBannerRect = new Rect(0.1f * Screen.width, 0.175f * Screen.height,
		                               0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(showBannerRect, "Show Banner"))
		{
			bannerView.Show();
		}
		
		Rect hideBannerRect = new Rect(0.1f * Screen.width, 0.3f * Screen.height,
		                               0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(hideBannerRect, "Hide Banner"))
		{
			bannerView.Hide();
		}
		
		Rect destroyBannerRect = new Rect(0.1f * Screen.width, 0.425f * Screen.height,
		                                  0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(destroyBannerRect, "Destroy Banner"))
		{
			bannerView.Destroy();
		}
		
		Rect requestInterstitialRect = new Rect(0.1f * Screen.width, 0.55f * Screen.height,
		                                        0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(requestInterstitialRect, "Request Interstitial"))
		{
			RequestInterstitial();
		}
		
		Rect showInterstitialRect = new Rect(0.1f * Screen.width, 0.675f * Screen.height,
		                                     0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(showInterstitialRect, "Show Interstitial"))
		{
			ShowInterstitial();
		}
		
		Rect destroyInterstitialRect = new Rect(0.1f * Screen.width, 0.8f * Screen.height,
		                                        0.8f * Screen.width, 0.1f * Screen.height);
		if (GUI.Button(destroyInterstitialRect, "Destroy Interstitial"))
		{
			interstitial.Destroy();
		}
	}

	
	void Update(){

		if (Input.GetKey (KeyCode.Escape))
						Application.LoadLevel ("LevelChoice");
		}

	public void RequestBanner()
	{
		#if UNITY_EDITOR
		string adUnitId = "the problem is not here ;)";
		#elif UNITY_ANDROID
		string adUnitId = "the problem is not here ;)";
		#elif UNITY_IPHONE
		string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
		#else
		string adUnitId = "unexpected_platform";
		#endif
		
		// Create a 320x50 banner at the top of the screen.
		bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
		// Register for ad events.
		bannerView.AdLoaded += HandleAdLoaded;
		bannerView.AdFailedToLoad += HandleAdFailedToLoad;
		bannerView.AdOpened += HandleAdOpened;
		bannerView.AdClosing += HandleAdClosing;
		bannerView.AdClosed += HandleAdClosed;
		bannerView.AdLeftApplication += HandleAdLeftApplication;
		// Load a banner ad.
		bannerView.LoadAd(createAdRequest());
	}
	
	public void RequestInterstitial()
	{
		#if UNITY_EDITOR
		string adUnitId = "the problem is not here ;)";
		#elif UNITY_ANDROID
		string adUnitId = "the problem is not here ;)";
		#elif UNITY_IPHONE
		string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
		#else
		string adUnitId = "unexpected_platform";
		#endif
		
		// Create an interstitial.
		interstitial = new InterstitialAd(adUnitId);
		// Register for ad events.
		interstitial.AdLoaded += HandleInterstitialLoaded;
		interstitial.AdFailedToLoad += HandleInterstitialFailedToLoad;
		interstitial.AdOpened += HandleInterstitialOpened;
		interstitial.AdClosing += HandleInterstitialClosing;
		interstitial.AdClosed += HandleInterstitialClosed;
		interstitial.AdLeftApplication += HandleInterstitialLeftApplication;
		// Load an interstitial ad.
		interstitial.LoadAd(createAdRequest());
	}
	
	// Returns an ad request with custom ad targeting.
	private AdRequest createAdRequest()
	{
		return new AdRequest.Builder()
			.AddTestDevice(AdRequest.TestDeviceSimulator)
				.AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
				.AddKeyword("game")
				.SetGender(Gender.Male)
				.SetBirthday(new DateTime(1985, 1, 1))
				.TagForChildDirectedTreatment(false)
				.AddExtra("color_bg", "9B30FF")
				.Build();
		
	}
	
	public void ShowInterstitial()
	{
		if (interstitial.IsLoaded())
		{
			interstitial.Show();
		}
		else
		{
			print("Interstitial is not ready yet.");
		}
	}
	
	#region Banner callback handlers
	
	public void HandleAdLoaded(object sender, EventArgs args)
	{
		print("HandleAdLoaded event received.");

	}
	
	public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
	{
		print("HandleFailedToReceiveAd event received with message: " + args.Message);

	}
	
	public void HandleAdOpened(object sender, EventArgs args)
	{
		print("HandleAdOpened event received");
	}
	
	void HandleAdClosing(object sender, EventArgs args)
	{
		print("HandleAdClosing event received");
	}
	
	public void HandleAdClosed(object sender, EventArgs args)
	{
		print("HandleAdClosed event received");
	}
	
	public void HandleAdLeftApplication(object sender, EventArgs args)
	{
		print("HandleAdLeftApplication event received");
	}
	
	#endregion
	
	#region Interstitial callback handlers
	
	public void HandleInterstitialLoaded(object sender, EventArgs args)
	{
		print("HandleInterstitialLoaded event received.");
	}
	
	public void HandleInterstitialFailedToLoad(object sender, AdFailedToLoadEventArgs args)
	{
		print("HandleInterstitialFailedToLoad event received with message: " + args.Message);
	}
	
	public void HandleInterstitialOpened(object sender, EventArgs args)
	{
		print("HandleInterstitialOpened event received");
	}
	
	void HandleInterstitialClosing(object sender, EventArgs args)
	{
		print("HandleInterstitialClosing event received");
	}

	public void HandleInterstitialClosed(object sender, EventArgs args)
	{
		print("HandleInterstitialClosed event received");
	}
	
	public void HandleInterstitialLeftApplication(object sender, EventArgs args)
	{
		print("HandleInterstitialLeftApplication event received");
	}

	#endregion

}

You can also get in contact with the author of the plugin, who might know better what the problem is.