Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Extremly Slow Resources.Load() (File Read) on Android

Discussion in 'Android' started by YanickFrehner, Aug 8, 2022.

  1. YanickFrehner

    YanickFrehner

    Joined:
    Mar 10, 2020
    Posts:
    2
    Hi There,

    since we have updated my Unity Project from 2020.3.36f1 to 2021.3.7f1 we are experiencing very long startup times for our application on android. Looking in the Profiler tells me that Resources.Load() is taking a very long time to load some scriptable objects used by two plugins we are using. Like 20 Seconds or so. Before this update of Unity it was working as expected.

    Do Any of you guys have u clue, what could be causing this issue or how this is happening. Is anyone experiencing the same issue as me?

    Here is a screenshot of the profiler on first frame:
    https://i.imgur.com/hZRtgjc.png
     
  2. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    Funny, I went the other way (2021.3 to 2020.3.34) and I'm experiencing the same Resources.Load taking seconds instead of milliseconds.

    If you found a solution, maybe it would apply for the downgrade as well? By the way, there is a serious MotionEvent JNI error in that version of Unity if you are using the legacy input system. It will crash after about 25000 taps.
     
  3. ArthurAulicino

    ArthurAulicino

    Joined:
    Sep 4, 2018
    Posts:
    4
    I'm having the same issue preventing me from upgrading from 2020.3.34 to 2021.3.x.

    I found it happens when I build with LZ4 or LZ4HC compression enabled. Default compression mode works, but the build size is huge.

    I've been trying to create a sample project to file a bug report, but I'm having difficulty reproducing it outside my project.
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,693
    If you have gradle templates, aaptOptions.noCompress might be wrong, and your files get double compressed. The easiest way to check this is to open apk with 7z and check the Store method, if it's Deflate then it means it's compressed in APK.
     
    Last edited: Aug 19, 2022
  5. ArthurAulicino

    ArthurAulicino

    Joined:
    Sep 4, 2018
    Posts:
    4
  6. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    Thanks for pointing in the right direction. In my case the magic noCompress flags were ['.unity3d', '.ress', '.resource', '.obb', '.unityexp'] although this is a project downgraded from 2021.3 so it may be unusual
     
    adfan likes this.
  7. tokiyashi

    tokiyashi

    Joined:
    Jun 18, 2021
    Posts:
    2
    This solved the problem for me as well. Thanks a lot for directing me in the right way!

    I've renamed the launcherTemplate.gradle, baseProjectTemplate.gradle, and gradleTemplate.properties files; and then recreated them through the "Build Settings" again. This solved the performance issues with the File.Read operations.
     
  8. Akjer

    Akjer

    Joined:
    Sep 7, 2017
    Posts:
    5
    this fixed my problem.
     
  9. Ariel_SneakyPanda

    Ariel_SneakyPanda

    Joined:
    Feb 21, 2021
    Posts:
    1
    You saved me a lot of frustration and time. thanks.

    Copy pastable:


    noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')



    }**PACKAGING_OPTIONS****PLAY_ASSET_PACKS****SPLITS**
     
  10. thiagolrosa

    thiagolrosa

    Joined:
    Feb 22, 2017
    Posts:
    59
    Omg, that was it! Thanks for the help! =)
     
  11. gagasik

    gagasik

    Joined:
    Jul 29, 2019
    Posts:
    25
    Thank you Guys. You are awesome :D
    I can't describe how I feel now.
    Had the same problem , after upgrading from 2020, searched for issues, nothing found. Then started to change to addressables , spent 3 weeks, and today found the thread , which points to this thread. :D AND .... It worked MAN :D Thank you guys.
     
  12. jpriyas

    jpriyas

    Unity Technologies

    Joined:
    Jun 9, 2021
    Posts:
    2
    Apologies for the inconvenience. Our docs have now been updated to warn about the `launcher.Template.gradle` changes.
     
    gagasik likes this.