Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Ads forces the game to restart after 1 to 3 seconds (on v5.1.1 but work perfectly on v4.4.2)

Discussion in 'Unity Ads & User Acquisition' started by eviltony, Nov 12, 2015.

  1. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Everyone, Unity Ads Team and unity-nikkolai.

    Please I need some help. I have a game and about to release it very soon. However I got into an issue with Unity Ads forces my game to restart after displaying an ads for 1 to 3 seconds, I am using the latest Unity (5.2.2.P3). Occasionally it displayed an ads up to 10 seconds on my nexus 5 then crashed(version 5.1.1 with OpenGL ES 3.0 V@104.0 AU@ (just for the reference)), but it works perfectly on Nexus 7 (Version 4.4.2 with OpenGL ES 2.0) and haven't got any issue that I know of.
    I spent a few days and couldn't work it out what is the root cause and I did google and checked out this forum. I haven't find any clue to solve this. I am not sure something I did wrong or there is a bug in Unity Ads.

    I created a quick test ad demo with empty solution and it works on both of my devices, so that confused me even more.

    However I noticed with the Nexus 5 (non working one) doesn't show the below 2 lines for my actual game in logcat at any time. But it displayed them with my test ads working demo and on Nexus 7 with my actual game.
    11-12 21:24:54.857 D/AdsUnity(21226): Calling loadAd() on Android
    11-12 21:24:55.134 D/AdsUnity(21226): Calling hide() on Android


    I highlighted the differences between 2 devices that showing in the log as below:
    Nexus 5 ( 5.1.1 non working) (sorry I have to use real ad to produce this error). As you can see for this case, the ads was displayed for approx. 1.2 secs (11-12 21:19:30.389 - 11-12 21:19:31.649)

    11-12 21:19:30.389 I/ActivityManager(751): START u0 {flg=0x10010000 cmp=com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity} from uid 10111 on display 0
    11-12 21:19:30.402 V/WindowManager(751): addAppToken: AppWindowToken{22519f96 token=Token{3b904eb1 ActivityRecord{208c2d58 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity t321}}} to stack=1 task=321 at 1
    11-12 21:19:30.516 D/Unity (19050): Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
    11-12 21:19:30.526 D/Unity (19050): Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
    11-12 21:19:30.850 I/Unity (19050): onPause
    11-12 21:19:30.905 W/ActivityManager(751): Activity pause timeout for ActivityRecord{47de817 u0 com.KTCT.XXXXXXXXXX/com.unity3d.player.UnityPlayerActivity t321}
    11-12 21:19:30.917 D/Unity (19050): Sensor : Accelerometer ( 1) ; 0.000595 / 0.00s ; MPU6515 Accelerometer / InvenSense
    11-12 21:19:31.207 I/Unity (19050): windowFocusChanged: false
    11-12 21:19:31.238 D/Unity (19050): [EGL] Attaching window :0x0
    11-12 21:19:31.320 V/WindowManager(751): Adding window Window{32e7f934 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity} at 11 of 18 (after Window{1790eaa3 u0 com.KTCT.XXXXXXXXXX/com.unity3d.player.UnityPlayerActivity})
    11-12 21:19:31.468 V/WindowManager(751): Adding window Window{3ba574a0 u0 SurfaceView} at 11 of 18 (before Window{32e7f934 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity})
    11-12 21:19:31.633 I/ActivityManager(751): Displayed com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity: +728ms
    11-12 21:19:31.649 I/WindowManager(751): Screen frozen for +744ms due to Window{32e7f934 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity}
    11-12 21:19:32.399 F/google-breakpad(19706): M A1A2F000 00000000 00FBD000 000000000000000000000000000000000 libunity.so
    11-12 21:19:35.229 I/WindowState(751): WIN DEATH: Window{1790eaa3 u0 com.KTCT.XXXXXXXXXX/com.unity3d.player.UnityPlayerActivity}
    11-12 21:19:35.229 W/WindowManager(751): Force-removing child win Window{2c986159 u0 SurfaceView} from container Window{1790eaa3 u0 com.KTCT.XXXXXXXXXX/com.unity3d.player.UnityPlayerActivity}
    11-12 21:19:35.239 I/WindowState(751): WIN DEATH: Window{32e7f934 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity}
    11-12 21:19:35.239 W/WindowManager(751): Force-removing child win Window{3ba574a0 u0 SurfaceView} from container Window{32e7f934 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity}
    11-12 21:19:35.440 W/ActivityManager(751): Force removing ActivityRecord{208c2d58 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity t321}: app died, no saved state
    11-12 21:19:35.504 I/ActivityManager(751): Start proc 19716:com.KTCT.XXXXXXXXXX/u0a111 for activity com.KTCT.XXXXXXXXXX/com.unity3d.player.UnityPlayerActivity




    On other hand, Nexus 7 (4.4.2) works fine.

    11-11 20:28:31.738 I/ActivityManager(691): START u0 {flg=0x10010000 cmp=com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity} from pid 22951
    11-11 20:28:31.858 D/Unity (22951): Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
    11-11 20:28:31.938 D/Unity (22951): Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
    11-11 20:28:32.049 I/Unity (22951): onPause
    11-11 20:28:32.089 D/Unity (22951): Sensor : Accelerometer ( 1) ; 0.001190 / 0.00s ; MPL Accelerometer / InvenSense
    11-11 20:28:32.139 I/Unity (22951): windowFocusChanged: false
    11-11 20:28:32.959 I/ActivityManager(691): Displayed com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity: +866ms
    11-11 20:28:33.049 D/Unity (22951): [EGL] Attaching window :0x0
    11-11 20:28:52.258 I/Unity (22951): onResume
    11-11 20:28:52.268 D/Unity (22951): [EGL] Attaching window :0x98b8fc18
    11-11 20:28:52.268 D/Unity (22951): [EGL] Attaching window :0x98b8fc18
    11-11 20:28:52.288 I/Unity (22951): windowFocusChanged: true
    11-11 20:28:52.348 D/Unity (22951): Sensor : Accelerometer ( 1) ; 0.001190 / 0.00s ; MPL Accelerometer / InvenSense
    11-11 20:28:52.378 D/Unity (22951): ANativeWindow: (1920/1200) RequestedResolution: (0/0) EGLSurface: (1920/1200)
    11-11 20:28:52.408 I/Unity (22951): The ad was successfully shown.
    11-11 20:28:52.408 I/Unity (22951): UnityEngine.Debug:Internal_Log(Int32, String, Object)
    11-11 20:28:52.408 I/Unity (22951): UnityEngine.Debug:Log(Object)
    11-11 20:28:52.408 I/Unity (22951): XXXXXXXXXX.GameManager:HandleShowResult(ShowResult) (at ..\Assets\Scripts\GameManager\GameManager.cs:2129)
    11-11 20:28:52.408 I/Unity (22951): UnityEngine.Advertisements.Advertisement:DeliverResult(ShowResult) (at C:\buildslave\unity\build\Extensions\UnityAds\UnityAds\Advertisement.cs:232)
    11-11 20:28:52.408 I/Unity (22951): UnityEngine.Advertisements.Advertisement:OnVideoCompleted(String, Boolean) (at C:\buildslave\unity\build\Extensions\UnityAds\UnityAds\Advertisement.cs:208)
    11-11 20:28:52.408 I/Unity (22951): UnityEngine.Advertisements.UnityAdsInternal:CallUnityAdsVideoCompleted(String, Boolean)
    11-11 20:28:52.408 I/Unity (22951):
    11-11 20:28:52.408 I/Unity (22951): (Filename: F Line: 0)
    11-11 20:28:52.408 I/Unity (22951):
    11-11 20:28:54.661 I/Unity (22951): 0
    11-11 20:28:54.661 I/Unity (22951): UnityEngine.Debug:Internal_Log(Int32, String, Object)


    =============
    I will try to look to see if I can load/initialise unity ads manually at the start while waiting for your help.

    Thank you.
    Tony.
     

    Attached Files:

  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Hi Tony,

    In case you cannot easily reproduce this issue with a small project, it could be related to how you call Ads in your game. Can you share some code?

    Thanks,
    Rasmus
     
  3. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Rasmus

    Thanks for your response. I uploaded my code where It called the adv. I also played with the time scale to 0 (pause the game before showing the ads) even though I know it should handle by the Ad. I tried both and same issue.
    I also tried to initialise the Ad manually at the start event and it actually showed up 1 missing line from previous post. but only display when it called at if (Advertisement.IsReady("rewardedVideo")) method
    D/AdsUnity(21226): Calling loadAd() on Android (displayed in catlog only isReady method is called)
    the video displayed up to 10 secs and it restarted my game so it is more progress and implicit initialise

    I managed twice to get the video complete when there are 15 secs ads with no issue.

    Again it has no problem with Android 4.4.2 device.
    Thank you
    Tony
     

    Attached Files:

  4. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    We have seen issues related to showing ads from Update(), in case Advertisement.Show() ends up being called multiple times, however doesn't seem to happen in you case as you set _allowInitialiseBuildPhase = false.

    At what point in your game is the ad shown, immediately on startup or after a while (e.g. end of a level)?

    -Rasmus
     
  5. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Rasmus
    When the game starts up, it will display game menu options canvas (mode = startGame) once a player selects the game mode, it will goes to build mode, then where the ads should be displayed after level 2 or 3 onwards.

    For the testing purposes I removed that code for now, and that code only call once when the level is completed, it allows player to build/upgrade unit for next level. I did test to show the ad on level 2 or 3 but same issue.

    Again I have no issue with Android v4.3.3. I will try to test on a different device with same android version to see if it works or not. I have limited devices to test, it will take a bit of time to do this.

    I found the Unity Ads implementation is quite easy but running into this kind of issue. I am pulling my hair out atm.

    Is there anyway I can check if which android version is running in the unityscript so I can disable the ads on certain android version? Just in case I cant find any solution for this. I may have to go that path if no option.

    Thanks
    Tony
     
  6. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    We haven't experienced similar issues here on Android 5.1.1, so would actually like to know what fails in your case (rather than just "blacklisting it" - which likely won't solve the problem as such). Anyways, if you want to disable ads for specific version of Unity, a search for "unity get android version" resulted in e.g. http://forum.unity3d.com/threads/how-could-i-find-which-version-of-android-is-running-my-app.243124/

    However, you were not able to reproduce this with your test app, right? In that case, I still suspect that something related to how Advertisement.Show() gets called could be the issue here.

    If possible, you are welcome to create a bug report on this (using Help->Report a bug) with your project files attached, and then I can take a closer look at it, also to see if we can reproduce internally. If you want to share your game project with us, just post the bug ID here or send to me in private message.

    -Rasmus
     
  7. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Thanks Rasmus

    I tested it on Samsung S6 (Android 5.0.2) and there is no issue. But Sony Xperia Z3 (Android 5.1.1) has the same problem, it forces the game after 10 secs (initialise it manually). The error seems to be consistent with (android version 5.1.1).
    My test app is empty, but my game uses ~250MB in memory.

    I either have the above error or the below before it crashed my game.

    I/WindowState(776): WIN DEATH: Window{1cb32ea2 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity}

    W/WindowManager(776): Force-removing child win Window{ea58255 (forced to kill my game here for some reason)
    SurfaceView} from container Window{1cb32ea2 u0 com.KTCT.XXXXXXXXXX/com.unity3d.ads.android.view.UnityAdsFullscreenActivity}

    I will try to replicate the issue with test app with part of the game. Then I will raise a bug defect.

    Does anyone has the any issue with Unity Ads on Android 5.1.1 or just me?

    Thank you
    Tony.
     
  8. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Rasmus
    I managed to test on Samsung Edge 6+ with Android 5.1.1 and it works fine. I don't understand why it happens to a certain devices with Android 5.1.1
     
  9. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
  10. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Still cannot repro here using Unity 5.3.1 and Android 5.1.1. Did you manage to repro this on a simpler project?

    Is it possible you can report a bug including the project files and PM me the bug id? Please also provide information about the specific device model in that case.

    -Rasmus
     
  11. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
  12. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    Idk how but I got this problem too :(
    Yesterday everything was working fine...
    Edit:
    And disabling UnityAds makes the app work fine, the demo proyect works fine tho o_O
     
    Last edited: Jan 8, 2016
  13. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    As stated in the linked thread setting Stripping level to Disabled makes UnityAds works fine.
    Seems like if unity was taking out a part of the assemblies of UnityAds that was actually being used. So when I Initialize unityAds on the first scene it crashes.
    A test could be to Initialize unityAds on the second scene and see whats happens.
    Setting stripping level to disabled increases my .apk size by 1MB its and affordable price to use it. Looking forward to an official path tho.
     
  14. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hey jc-drile77
    Even stripping level is disabled (default) my video ads can only be displayed a few times, then my game crashed. I just released my game last week with Rasmus's code to check for Android version so I can disable the video ads for 5.1.1. I waited too long and can't find the solution.
    I also tried to use Admob interstitial and have the exact same error.
     
  15. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    @eviltony, is there some way we can get access to the game, so we can test it here?

    -Rasmus
     
  16. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Rasmus,
    My game is released but no video ads for 5.1.1
    I can build a version in debug mode with unity ads, and I will send it to u.
    Thanks
    Tony
     
  17. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    Stripping level disabled is not the default state for me, try to update to 5.3.2 and disable stripping level and it should work.
    However the official patch will come in 5.3.3 thats its going to be realesed in around 3 weeks, so you can wait for it.
    I cant say much more as I started using Unity ads in 5.3.
     
  18. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Thanks jc-drile77
    I am using 5.3.0.f4. There is a particle system bug which plays only once in 5.3.2, all my aura units don't work with time interval so I will wait till may be to 5.4 (with other fixes including smoothing animation transition in animator, I waited for months for this fix as well, I ended up using Legacy animation instead)
     
  19. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    Np eviltony,
    for the ads you could integrate appOdeal, easy to integrate in unity (Comes with a package). what is does is basically choose the best offer by the advertiser (unityads included) and show it (appOdeal takes no profit from it). It gives no errors with strippin assemblies.
    Go Here
    About the particle system it´s fixed in 5.3.2.p1 (it was in 5.3.1) (fixed in the patch)
    https://issuetracker.unity3d.com/issues/particle-system-plays-only-oncef
    I would also check the 5.3.2 p1 and p2 release notes in case any other bug has been fixed there:
    http://unity3d.com/unity/qa/patch-releases?version=5.3
    And the 5.3.2 release notes:
    http://unity3d.com/unity/whats-new/unity-5.3.2
     
  20. eviltony

    eviltony

    Joined:
    Nov 10, 2015
    Posts:
    14
    Hi Rasmus and jc-drile77
    I built a test package for Rasmus and amazingly with my current version 5.3.0.f4, now the UnityAds works fine, It was never showed pass 4 videos ads before (every 2 or 3 levels per ads), It always crashed before that.
    I don't understand the under hood of this but it seems all good now. May be i used to test on 5.2.x version. Anyway it's all fine now for now.

    Thank you for your help guys.
     
  21. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    If you had the unity ads crash when stripping level is enabled its now fixed on Unity 5.3.2.p3 :)
     
    rasmus-unity likes this.