Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ROOOOCKSTAR · Oct 16, 2014 at 02:29 AM · androidadmobframerateslow

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
 
 }



Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image chrille · Oct 18, 2014 at 01:22 PM 0
Share

I'm facing the same problems as you do. I've noticed though, that some phones aren't affected by the problem at all, some phones are affected slightly while some phones are highly affected by the problem.

avatar image ROOOOCKSTAR · Oct 19, 2014 at 02:40 PM 0
Share

Hi chrille, thanks for the feedback. I don't have other available device so I can't say. I started a thread on the forum of the developer here, where he answered me twice, but he doesn't know really what the problem could be: https://groups.google.com/forum/#!topic/google-admob-ads-sdk/ZYYJvEY_OTQ

avatar image chrille · Oct 19, 2014 at 03:07 PM 0
Share

Well, he points out that the the combination of a web view and unity is very resource intensive. But what i find strange is that the lag is apparent on my Nexus 5, but not on a 3 year older Samsung Galaxy SII.. Anyway, as i said in another thread on the same problem; I'm avoiding banners altogether now. I'm using interstital ads ins$$anonymous$$d. They don't make the game lag and, in my opinion, they aren't as intrusive.

avatar image ROOOOCKSTAR · Oct 19, 2014 at 03:12 PM 0
Share

Well for me it's different I can't use Interstitial without lags, only Banners and use Hide(). I created ins$$anonymous$$d a scene where the user waits a few seconds, and a banner rect is loaded. If I get another device, I will keep you in touch. Btw, the developer answers quite fast, so don't hesitate to keep him informed :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unimechanic · Oct 16, 2014 at 01:34 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ROOOOCKSTAR · Oct 16, 2014 at 03:15 PM 0
Share

I did that also. Waiting for an answer asap. I will tell if I get an answer, or find a fix.

avatar image GabeGabe · Jul 16, 2015 at 08:08 PM 0
Share

Did you fixed it?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity Admob Lags and slows down game significantly. 1 Answer

GPU Graphics.blit huge time on android 0 Answers

Game skips at specific points in level (not garbage collector) 0 Answers

Missing AdActivity with android:configChanges in AndroidManifest.xml 0 Answers

OnApplicationPause takes more time when Application.targetframerate changed 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges