Search Unity

Framerate drops after Unity Ad runs - Android

Discussion in 'Unity Ads & User Acquisition' started by breban1, Aug 15, 2016.

  1. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    I'm having trouble with Unity Ads dropping the framerate on my game by 25% on an Android device after an ad runs (Samsung Galaxy S3 specifically). I've only tested on 2 Android devices at this point, but I'm worried this could get worse with a wider array of devices.

    The strange thing is, if I press the 'home' key, then go back into the game, the framerate pops back up again.I'm not using OnApplicationFocus/OnApplicationPause, so it's not something I am doing after the game comes back from the home screen.

    I am in communication with Unity Ads team, but they cannot replicate on their end.

    Does anyone else have this issue?
     
  2. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    This has been reported many times, but we've so far been unable to reproduce it.

    There's at least three theories about the cause:
    - Vsync (unlikely, since it occurs after the ad has played)
    - Garbage collection on Android
    - Android device reducing power intake to cool down

    It doesn't apparently affect all devices.

    I hope this helps.
     
  3. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    quick workaround is just having an enumerator yield null for 5 frames after getting a ShowResult when its done
     
  4. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    @mikaisomaa @AVOlight I tried the enumerator yield, but no luck. Thanks for the idea, it was worth a shot.

    The problem is that the framerate continues to remain low indefinitely after it drops from the Ad running. The only way to bring the framerate back is to press the "Home" key, then go back to the app. Note that I am not killing the app, then going back in. I'm just pressing the home key, then pressing the app icon again with the app still running. It's like Unity is still holding onto memory or something, then it gets refreshed after home and back.

    I actually duplicated the same exact thing on a Samsung Galaxy Note 4 today, so this is now happening on 2 of the 4 devices I've tried it on. I have no doubt this will bite me when release to a bigger audience.
     
  5. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
  6. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    @breban1 - we're trying to reproduce said issue. I'll post any findings here.
     
    breban1 likes this.
  7. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    I noticed something that may be related. When i build my project directly on the tablet and it starts, most of the time it won't run as it should. But if i close it and then just run it normally from the device it will run nicely.
    Perhaps it's something with the process of when the app is halted and going to the background and then brought back in?
     
  8. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    It's hard to tell if the framerate drops after an Ad, but I think it does. Is there a way to turn FPS on the screen?

    Also, is there a way to follow a post? I want to be notified by email when someone reply's to my post. I see the alert when I log in, but receiving an email would be better.
     
    AVOlight likes this.
  9. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    I got to test my game on a Samsung Galaxy Note 4 and a Galaxy S5 this past weekend, here are the results:

    Galaxy S5: No framerate drop after Unity Ad runs
    Galaxy Note 4: Framerate drops ~30% after Unity Ad runs.
     
  10. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    Thank you @breban1 for checking. haven't added an FPS panel for it. mostly trying to make sure there isn't any major lag issues.

    yea bit confused about how it works; but pretty sure i get an email on the first reply after i've replied on a thread
     
    breban1 likes this.
  11. ericdstock

    ericdstock

    Joined:
    Aug 16, 2016
    Posts:
    1
    Hello I am experiencing the exact same issue reported in this thread. I run my game and get 60fps on an Android tablet. Then after showing a Unity Video Reward Ad, the game has an inconsistent frame rate. The gameplay quality is noticeably reduced due to this.

    I am using Unity 5.5.

    Previously I was using and older version of unity (Sorry I don't have the version...it was either an earlier version of 5 or Unity 4). I enabled the "Multithreading Rendering" feature when I built the game. When the game was built and launched, I noticed a very similar situation. I was getting an inconsistent frame rate. I found a few links related to this problem which told me to disable "Multithreaded Rendering". I did this and the problem went away. http://www.torestudios.com/news/unity-android-gfx-waitforpresent-issues/

    I have included the previous info as the frame rate slow down is the same. Perhaps this can help you track down what the problem is. It seems possible that there are resources created during the display of Ads which are not properly cleared up. (Ex// missing a thread.join call)

    I am hopeful Unity will be able to find a fix for this issue. Otherwise I won't be able to release my game with Unity Ads.
     
    breban1 likes this.
  12. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    @ericdstock thanks for jumping in!

    I still haven't had any luck resolving the issue, maybe your multithreaded problem will give the Unity team some ideas. Unity team hasn't had any luck fixing either unfortunately.

    On the multithreaded options: I have multithreaded rendering on and I have consistent framerates before an ad runs (60fps). As a side note, I now default my game to targetFPS to 30 and the issue isn't noticable. After an ad runs my game stays at 30fps, it isn't jittery like it is when I set it to 60fps. I know it's a sucky option, but it's an option nonetheless.

    I have a feeling most teams default to 30fps and never notice the issue we're having, OR there is some difference in our projects that cause the issue.

    I've had this issue since Unity 4.6 (using 5.4.1p2 now).

    Brian
     
  13. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    @ericdstock I forgot to ask, does your FPS recover when you press the home key on your device, then go back to the game? Not rerunning it, just maximizing it again?

    Brian
     
  14. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    78
    @breban1 I have the exact same problem, and when i press me home button and go back to the game, even if it only takes a fraction of a second, it returns everything to normal. Some part of memory must unload when going to home screen, so I would think its a memory issue?
     
    breban1 likes this.
  15. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    The problem isn't just a FPS drop for a few seconds after an ad runs, it lowers the FPS indefinitely until you press the home key, then go back to the game.

    My game starts at 60fps while playing, as long as I want to play, but immediately after a Unity ads runs, it goes down to ~42fps (very jerky/inconsistent looking), and continues like that for the remainder of play.

    I did try yield null just in case it was a fix, but it did not fix the problem.
     
  16. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    @benjamminlaner If you could send Unity your project along with a link to this post it may help them track this problem down. It has to be happening to more customers than just us few that are responding.

    I'm still defaulting my game at 30fps, but it looks SO much better at 60.
     
  17. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Do you have the last version of unity ads?

    I remember now that long time ago I saw this issue on some device. After showing an ad the framerate drops.
    But seems that it was solved or I changed something that made it solved. Not sure.
     
  18. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    p3dart-es I'm using the latest revision of Unity Ads 2.x, and have been using Unity 5.4.3p4, so I'm pretty caught up. I had a few weird issues with 5.5 so I didn't fully integrate to it.

    Maybe you did something to solve the issue. If you use SC, can you check your checkins for 'fixed framerate issue'? You never know!

    And yes, it's only happening on certain devices, although the ones that I have access to it is happening on 50% of them (2 of 4).

    Thanks!
     
    Last edited: Jan 15, 2017
  19. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    sorry, what did you mean with SC?
     
  20. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Sorry, lazy typer...

    If you are using source control, can you look at your commits to see if there are any obvious descriptions that mention "framerate" or something to do with ads and framerate?
     
  21. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Ahh, no I don't use source control. If I remember what I did I will post it here.
     
  22. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    i got similar issue, my framerate drop down , until i disable the wi fi then my framerate goes back to 60 fps. you guys find a work around? i ll try to disable multithread if that solve the issue.
     
  23. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    I ended up just setting my target framerate to 30fps because it doesn't seem to show itself at 30fps. 60fps it still happens for me. Sorry I don't have a better answer.

    I haven't heard the wifi disable though, I'll have to try that for the heck of it. Not that it solves the problem. Does your framerate go back to 60 if you press the home key, then go back to the game?
     
  24. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    116
    I had the same problem with rewarded video!

    I am using Fyber`s mediation (with UnityAds, AdColony, AppLovin, Vungle) and after the rewarded video my FPS drops from 60 to 30-35 on Nexus 7 2013 (Android 5.1.1). See the screenshot in attachments.

    The problem is solved. Add this line to your AndroidManifest.xml:
    Code (CSharp):
    1. <uses-sdk android:minSdkVersion="16" />
    16 - is my Minimum API Level (Android 4.1 'Jelly Bean'). In my case it helped.

    Versions:
    Unity 5.4.5
    FyberUnityPlugin-8.12.18.12.1
    fyber-unityads-2.1.0-r1v2

    P. S. For the experiment, I tried to use native UnityAds without Fyber and my FPS does NOT drops after the rewarded video. But this variant does not suit me. I need Fyber.
     

    Attached Files:

    mikaisomaa likes this.
  25. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Thanks for the info!

    My manifest is:
    <uses-sdk android:minSdkVersion="10"/>

    Which is Gingerbread 2.3.3 - 2.3.7 API level 10. I will try using min API 16 and see if it solves the problem for me. Although, I think I was using a higher version than 16 when I first saw this problem. Stay tuned...
     
  26. JMormul

    JMormul

    Joined:
    Feb 14, 2016
    Posts:
    3
    Hi,
    did you find a solution to your problem? I have exactly the same issue, the framerate drops after playing an ad and the only way to get it back to 60 fps is pressing the Home button.
     
  27. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    116
    @JMormul
    I wrote the solution above. Try it.
     
  28. JMormul

    JMormul

    Joined:
    Feb 14, 2016
    Posts:
    3
    I think I solved my issue:

    Edit -> Project Settings -> Quality

    V Sync Count -> Don't Sync

    Now the framerate doesn't drop! Hope that helps!
     
  29. JMormul

    JMormul

    Joined:
    Feb 14, 2016
    Posts:
    3
    Thanks, but this didn't help in my case.
     
  30. ColourlessJune

    ColourlessJune

    Joined:
    Mar 21, 2016
    Posts:
    1
    This happens to me too, but after I turn off the bluelight filter app the problem goes away.
    Maybe some other app is interfering with your app?
     
    Last edited: Feb 18, 2018
  31. JayFiraja

    JayFiraja

    Joined:
    Oct 1, 2013
    Posts:
    12
    This is happening to me as well lately, not sure how to fix it
     
  32. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Sorry for the late reply, but my V Sync Count is set to Don't Sync and the problem exists.

    Also, changing the API level to 16 did not help in my case.
     
    Last edited: Jul 14, 2018
  33. jmansa

    jmansa

    Joined:
    Apr 13, 2012
    Posts:
    75
    Hi, I am having the same issue, although on iOS. I have AdMob banner ads and when the banner changes it drop from 60fps -> 33fps. It stays there until I either pauses the app and go back into it, or when AdMob refreshes to a new banner.

    Did any of you find a solution?
     
  34. TheGering

    TheGering

    Joined:
    Nov 26, 2012
    Posts:
    29
    Did you find any solution to this issue? I just encountered the same
     
  35. lasdoo5

    lasdoo5

    Joined:
    May 18, 2018
    Posts:
    16
  36. vitaliykot98

    vitaliykot98

    Joined:
    Jul 31, 2020
    Posts:
    1
    I had FPS drop after collapse and expand the application when Vulkan API was used.
    Try disable Auto Graphics API and use only OpenGLES3. It helps in my case
     
  37. tsukasa42

    tsukasa42

    Joined:
    Jul 31, 2021
    Posts:
    5
    Using IronSource/LevelPlay, having the same problems.
    Game works great up until the point that an ad plays.
    After that happens, it drops. It gets slightly worse after each ad is shown.