Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Official IL2CPP Build Time Improvements - Seeking Feedback

Discussion in '2021.2 Beta' started by joncham, Feb 24, 2021.

  1. pradotech

    pradotech

    Joined:
    Oct 17, 2019
    Posts:
    35
    I could build for Android using Master compiler after changing Stripping Level to Medium (I was using Low) and switching from .NET Framework to .NET Standard 2.1. Details below:

    •Unity 2021.3.9f1
    •Faster runtime
    •Compression: LZ4HC
    •API Compatibility: .NET Standard 2.1
    •Compiler Configuration: Master
    •All architectures (ARMv7, ARM64, x86 and x86-64)
    •Managed Stripping Level: Medium/High
    •I also removed some unused scripts from project.

    Build completed without any errors.

    Hope it keeps working and maybe that helps someone.
     
    Chibi_Phoenix likes this.
  2. Elapotp

    Elapotp

    Joined:
    May 14, 2014
    Posts:
    98
    Thank you, @pradotech .

    Any differences with other levels and compiler settings (like apk/abb size, on device performance)?
    Can't test myself on Unity 2021.3.9f1, cause there is a crash on launch
     
  3. pradotech

    pradotech

    Joined:
    Oct 17, 2019
    Posts:
    35
    I didn't try other settings after I found this working one, but I'm almost certain that the managed stripping level on low is the main reason for the build errors.
     
  4. Chibi_Phoenix

    Chibi_Phoenix

    Joined:
    Nov 12, 2019
    Posts:
    4
    OMG THANK YOU SO MUCH!!!
    This was driving me crazy for the past week... suddenly my project couldn't be build anymore, but this does seem to work!
     
  5. PoweredOnSoftware

    PoweredOnSoftware

    Joined:
    Apr 10, 2015
    Posts:
    8
    hello i'm having an issue with Generics & IL2CPP with Unity 2021.3.11f1

    i'm trying to use YoutubeExplode which depends on System.Text.Json

    https://www.nuget.org/packages/YoutubeExplode/6.2.5#dependencies-body-tab

    but i keep getting errors related to missing methods when use IL2CPP (both .NET standard 2.1 and .NET framework paths)

    https://github.com/Tyrrrz/YoutubeExplode/discussions/679#discussioncomment-4639222

    i tried adding a link.xml, and disabling Strip Engine Code, and low / disabled stripping levels, to no avail

    NOTE: when i switch to Mono scripting backend, it works. But then I can't target ARM64 / v8a :(

    which means i can't publish to google play https://i.imgur.com/BoBXowU.png

    any suggestions or guidance would be greatly appreciated

    ---

    **UPDATE**


    derp, i was still on unity 2021

    i've upgraded to Unity 2022, to take advantage of Full Generic Sharing,

    but now I have a new error:

    1. K:\Code\Nreal-Unity-Demos\Android\unityLibrary\src\main\Il2CppOutputProject\Source\il2cppOutput\System.Text.Json3.cpp(11890,11): error: no viable overloaded '='
    2. V_3 = L_12;
    3. ~~~ ^ ~~~~


    Full build output:

    https://gist.github.com/jakedowns/4e1462e6b877d348539cc4d20fead3e5
     
    Last edited: Jan 11, 2023
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    This error usually means there are two competing implementations of System.Threading.Tasks.ValueTask in your project. Is there a System.Threading.Tasks.Extensions.dll somewhere? If so, you can remove it, because the it is already implemented in the .NET base class library that ships with Unity.
     
  7. Reboorn

    Reboorn

    Joined:
    Jun 21, 2017
    Posts:
    6
    Hello,

    I am struggling with an issue in Unity (v.2021.3.28f1) while building Android. I've noticed that using the Master mode always fails. Even if I set the code trimming level to Medium as others have suggested, it still fails.

    I came across an issue here: [https://issuetracker.unity3d.com/is...y-asset-and-il2cpp-scripting-backend-selected], suggesting that these problems may be due to the NDK version or gold link. Following this, I took the step of upgrading the NDK to r23, and switched to using lld link, but to no avail.

    The main objective I'm aiming for is to optimize the il2cpp library as much as possible by the time I'm ready to publish the final version. As part of this, I've tried leveraging SetAdditionalIl2CppArgs to add "--linker-flags" and "--compiler-flags" into the mix during the build process. By enabling -Oz and -Wl,--gc-sections, I've managed to shave off around 5mb of space; a small victory, but I'm certain that there's more that can be done on this front.

    I've noticed that Unity’s latest iteration now supports LTO, which prompted me to try using -flto in Unity 2021. Unfortunately, this also ended in failure. At this point, I'm somewhat at a loss, and would truly appreciate any assistance or advice you may have to offer.

    I am deeply committed to ensuring that the final release is as optimized as it can possibly be. I feel like I've exhausted all avenues available to me, so any insights you could provide would be sincerely appreciated. I strongly believe that with your guidance, I can overcome these challenges.

    Looking forward to your kind assistance!
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I don't think there are too many other options to make the code smaller. It seems like you have tried all of the ones we know about as well. Sorry, but I don't think I can be much more help!
     
    Reboorn likes this.
  9. israellot_yp

    israellot_yp

    Joined:
    Jan 26, 2022
    Posts:
    4
    Using faster (smaller) build we face this exception
    Code (CSharp):
    1. An unresolved indirect call lookup failed
    Managed to trace it back to double interface calls apparently.
    An instance casted to an interface that calls another interface method.
    Still working on a repro, but MessagePack library is one example of code throwing this exception.
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    This definitely sounds like a bug in IL2CPP. Can you submit a bug report if you can get a reproduction?

    https://unity.com/releases/editor/qa/bug-reporting
     
  11. unity_EF10D58E7EA9ED42741F

    unity_EF10D58E7EA9ED42741F

    Joined:
    Feb 1, 2023
    Posts:
    2
    JoshPeterson likes this.
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Thank you, we will investigate this.