Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Lagging and Crash for Android

Discussion in 'Editor & General Support' started by cerman123, Jan 19, 2021.

  1. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    Hello,
    I make book app in unity. I have a performance problem. My book app has 300+ scenes and every scene has only one TMP, one next button, one previous button. I save the last scene index number read to playerprefs. My book app is getting very slow after 100. scene and getting closed. I deleted all of buttons and TMPs. I create 150 scenes as empty but I faced same problem. There is no problem when it runs on my Unity editor. There is a problem when I install it to my phone. My phone is Samsung S10 Plus and Android 10. I think, it is caching somethings this is why my book app is geting slow and getting crash. But I couldn't find why is. What can I do to solve this problem? Could you please help me? Thanks.

    Sincerely,
    Cem Erman
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    5,198
    Are you loading all of the scenes at once?
     
  3. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    No, User switches to the next scene after reading.

    Transitions between the first 20 pages are fast. After that, it starts to slow down. It shuts down after page 100.
     
    Last edited: Jan 19, 2021
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    10,304
    Try using the Profiler with a mobile build. I'd suspect you'll see memory usage continuing to increase. If so, you'll want to see what exactly is using the memory. Might need to do deep profile, or try the memory profiler package.

    https://docs.unity3d.com/Manual/ProfilerMemory.html

    Deep profiler is very memory and performance intensive in the Editor, so I don't recommend just letting it run or using it while running the game in the Editor. Just use it at different points to analyze what it going on at that time.
     
  5. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    Hello, Thank you so much for your interest. Deep profile worked in editor mode DeepProfileDataScreenshot.PNG but unfortunately I didn't understand datas. Screenshot is attached.
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,248
    Memory profiling in the editor is not recommended because the Editor has some unexpected (and for an issue in the build irrelevant) memory usage patterns.

    Here's how to connect the profiler to your phone. You might have to turn off mobile data so that the connection can go over WiFi.

    The Profiler Window's Memory Profiler Module does not show managed (C#) memory, only native (C/C++). Use the Memory Profiler package to get the full picture, as the managed heap seems to be the biggest chunk after the ExecutavleAndDLL size (and profiling which is irrelevant to your issue).

    Where does the text content to your book reside? I assume it's not in C# files? Are you using Reflection and/or generics? That execuable size is a bit big for mobile so I'm wondering how it comes up to that size. Have you turned on code stripping in your Player settings? Is this a Mono or an IL2CPP build?
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,248
    With the memory Profiler Package, try taking snapshot e.g. in level 1, 2 and 3 and then compare them to each other, also using the diffing function. See if something sticks around hat shouldn't and check this guide for finding memory leaks.
     
  8. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    Hello,
    I will make suggestion you said. I will give information about result. Thank you so much for your support and interest.

    PS : I added text every page manually as TMP
     
  9. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10

    Hello Martin,
    I tried to make things you said. I hope I have done correctly. My profile analysis data is attached. Unfortunately, I didn't understand nothing :)

    Test Scenario :
    First test was very fast till 50-60 pages and crashed at 128. page
    Second test was very slow and I think it crashed at between 70-90 pages.

    When I test I clicked next button fastly and again previous button. My app has only text this is why I trought that my app should work fast.

    Thank you so much for your support. I am grateful for your help.
     

    Attached Files:

  10. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    Hello Martin,

    I deleted all of app and I created 2020.1.11f but I faced same problem and deleted it. I created in 2019.3.6f again.
    I found the problem. I disabled Admob Banner script and my app worked perfectly but I enabled admob banner script again, my app has a performance problem is going slow down and crash. Unfortunately, I couldn't find a solution. The script I used is standart admob script. When I add banner object every scene and my book app is going very slow down and crash. Could you please give me a suggestion?

    I added Google Mobile Ads 5.4.0
    My unity version : 2019.3.6f

    Thank you so much for your support.

    Sincerely,
    Cem Erman

    Admob Banner Script:
    //using System.Collections;
    //using System.Collections.Generic;
    //using UnityEngine;
    //using GoogleMobileAds.Api;
    //using System;

    //public class BannerReklam : MonoBehaviour
    //{
    // private BannerView bannerView;

    // // Start is called before the first frame update
    // void Start()
    // {
    // //Initialize the Google Mobile Ads SDK.
    // //MobileAds.Initialize(initStatus => { });

    // this.RequestBanner();


    // }

    // public void OnGUI()
    // {
    // GUI.skin.label.fontSize = 60;
    // Rect textOutputRect = new Rect(
    // 0.15f * Screen.width,
    // 0.25f * Screen.height,
    // 0.7f * Screen.width,
    // 0.3f * Screen.height);
    // GUI.Label(textOutputRect, "");
    // }

    // // Update is called once per frame
    // void Update()
    // {

    // }

    // private void RequestBanner()
    // {
    // // These ad units are configured to always serve test ads.
    //#if UNITY_EDITOR
    // string adUnitId = "unused";
    //#elif UNITY_ANDROID
    // string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxx";
    //#elif UNITY_IPHONE
    // string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxx";
    //#else
    // string adUnitId = "unexpected_platform";
    //#endif

    // // Clean up banner ad before creating a new one.
    // if (this.bannerView != null)
    // {
    // this.bannerView.Destroy();
    // }

    // AdSize adaptiveSize =
    // AdSize.GetPortraitAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);

    // // Register for ad events.


    // this.bannerView = new BannerView(adUnitId, adaptiveSize, AdPosition.Bottom);

    // AdRequest adRequest = new AdRequest.Builder()
    // .AddTestDevice(AdRequest.TestDeviceSimulator)
    // .AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
    // .Build();

    // // Load a banner ad.
    // this.bannerView.LoadAd(adRequest);
    // }


    //}
     
  11. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    MartinTilo likes this.
  12. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,248
    Hi Cem,

    My apologies, I hadn't yet found the time to look at the profiler data.
    I'm still glad to hear you found a solution :) good luck with the game!
    Martin
     
  13. cerman123

    cerman123

    Joined:
    Mar 22, 2020
    Posts:
    10
    Hello Martin,

    No problem, I can understand your workload. Thank you so much for your good wishes.

    Sincerely,
    Cem Erman
     
    MartinTilo likes this.
unityunity