Search Unity

TextMeshProUGUI.Awake() causing massive delay in loading built player (Android)

Discussion in 'Editor & General Support' started by Ethwood, Nov 23, 2020.

  1. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    I searched to the moon and back but apparently nowhere could I find anything about this method or it's descendants.

    1. Why is TextMeshProUGUI.Awake() taking 2800 ms at scene startup? What is it?

    Capture1.JPG


    I'm loading one big scene containing several textmeshes with about 4 common materials in total.

    The scene takes a cringe-worthy 23000 ms to load on a very old device (Lenovo P1A42 in this case, ancient phone), so I decided to deep profile. Amongst a lot of contributors to the load delay, the one that surprises me is this.

    Expanding further down, I see that TextMeshPro is trying to read a file on awake. Is there any way to see what files are being read? In fact, is there a way to see if even which gameobjects are involved in any of the calls via profiler?

    2. Why is Image.OnEnable() taking 784 ms at scene startup? What is it?

    Capture2.JPG


    3. Why is StringBuilder.AppendFormatHelper() taking 7243 ms at scene startup? What is it?

    Capture3.JPG

    In the third screenshot, you can see the three main causes for the 23 seconds load time marked by the three red lines. Now according to my understanding, the sub methods under PostLateUpdate.PlayerLateUpdateCanvases indicate that some Canvas in the scene is marked dirty and rebuilt.

    But previously to keep things clean and fast, I have divided up the main canvases to have sub-canvases with dynamic and static UI objects separated quite well. Then why is the Canvas being dirtied this much?

    Is there any proper way to understand what gameobject is exactly dirtying my canvas here? What's the role of StringBuilder.AppendFormatHelper() here anyway?

    ---------

    The main scene in question is being loaded with LoadLevelAsync with an initial loading bar scene.

    Also, any input on why am I facing 23000 ms in total will also be appreciated. I am lost at this point after optimizing a ton.

    Using Unity 2020.2.0b12 on Windows 10
     
  2. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    SOLVED. It's shocking how sometimes the little things make the biggest differences.

    I was using LZ4 compression previously. As soon as I disabled any compression in Build options (Kept it on Default), The load time went down from 1 minute 25 seconds to 10 seconds.