googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.37k stars 1.08k forks source link

Application loading time is much longer when using Google Admob library #1523

Closed michal-lorenc closed 1 year ago

michal-lorenc commented 3 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

  1. With admob plugin, application loading time in my case is 3-4 seconds. But without admob plugin my app starts immediately. Is there any way to make this plugin load after scene is loaded, so i can at least show loading screen to my users rather than black screen for a few seconds? (I don't init this plugin on start function)

  2. There is also a problem with performance when banner ad is being displayed. FPS might even decrease to 50%.

  3. Why google can not make at least one well working plugin for unity? Why all of your plugins are so slow, that i need to code them by myself in java and then make some wrapper in c# to handle that as i had to do with Google Sign In?

Of course most important problem is the first one. Would be cool to hear at least once solution to a problem from google.

stowy commented 3 years ago

Hello @Xazerekt thanks for your questions. Let me attempt to answer:

1 - When are you calling MobileAds.initialize? It's possible that this may be causing additional load time. You could consider adding a loading scene before the scene in which MobileAds.initialize is called to show while this is occurring. I'd check if this is indeed the cause by using logging to check the timing of UI appearing relative to the initialize call.

2 - Banner ads use webviews and these do unfortunately come with some computational overhead which can affect performance in some instances. If you would like to share a sample application we can take a look. You could try disabling video demand for banners in your AdMob account:

Screen Shot 2020-12-07 at 9 07 10 AM

3 - If you have specific concerns with the structure of this plugin and you feel that there is a more efficient way of architecting the plugin we're open to your feedback. I, as an AdMob team member, cannot comment on other Google plugins, I suggest that you contact those teams in regards to the plugin in question.

michal-lorenc commented 3 years ago

@stowy Thank your reply 👍

  1. It does not matter when I initialize it, i tested it by initializing in awake/start or after few seconds after game starts and it doesnt make difference. The problem occurs only if admob library is installed in unity. Without plugin installed loading times are good.

  2. That's good to know. I will try that. Will disabling video demands for banners will affect earnings or cpm?

stowy commented 3 years ago

No worries.

1 - does it occur if you don't call initialize or use the SDK at all? IE if plugin is included but not used.

2 - It will affect which ads are served and so could impact CPM yes.

michal-lorenc commented 3 years ago
  1. From what i see the problem is only visible if you don't use splash screen. Unity is able to show splash screen before loading the plugin. Without this plugin unity is able to launch first scene instantly (scene with ui only), but with plugin included it shows black screen for few seconds before first scene is loaded.

It also looks like unity is able to check if you will ever use the plugin in your code and based on that it will decide if it should load it on app start. It will load it on app launch, even if plugin is first time used in second scene.

I did not test if loading times are higher with library included but without any reference to this library in code, but I think that if you never reference this plugin then unity will not try to load it on app launch.

Good news is that splash image is shown before unity initializes plugins, so we can see splash screen first and after splash image first scene is instantly loaded without any black screens.

For me that's enough. As long as I can show at least splash image rather than black screen, everything is ok.

In case you would like to debug it, make two projects with empty scenes, just some simple ui. Turn off splash screen. In one project include library and a script to reference to that library and compare loading times between projects.

Thank you for your help, it's nice to see any support from a google employee for the first time. Have a good day :)

stowy commented 3 years ago

@Xazerekt no problem. Thank you I will verify this. I'm interested to see if this also occurs on iOS.

Mecze commented 3 years ago

Hello!

I have encountered a similar problem.

In our case, Admob takes several seconds (like half a minute) to initialize once we add a Production AdUnit and all the adapters have to initialize. With the Test AdUnits The load is much faster. Funnily, we have to stall the loading screen until Admob is fully functional to show an Initial Interstitial. Is there a way to speed up initialization?

kunny commented 1 year ago

Since there were no recent activities for this issue, we are therefore reluctantly going to close this bug for now. If you are still experiencing the problem, please file a new issue with the same description, what happens and system / network tracing / Charles logs.

All system setups can be slightly different, so it's always better to open new issues and reference the related ones.

Thanks for your contribution again!