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.
  2. Dismiss Notice

Bug Android build DOTS with Play Asset Delivery - IL2CPP more than 150 Mb size

Discussion in 'Entity Component System' started by hojjat-reyhane, Nov 27, 2022.

  1. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    49
    Hi,
    We use Entities 0.51.1 in Unity 2021.3.11.
    The usual procedure of building a DOTS project with IL2CPP isn't working and the game will freeze on the splash screen. So we have to use Build Configuration in order to use Entities and build with Il2CPP.
    But, the problem here is that the project size is more than 150 Mb and the solution is to use Play Asset Delivery for building.
    We're completely stuck! Reducing the project size isn't an option.
    How do you think we can solve this problem?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    Are you using subscenes?
     
  3. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    49
    The weird thing is that we're not using Subscenes!
    I searched the whole project for it, but couldn't find any Subscene.
    We immigrated from Entities 0.11 to 0.51.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    There's an issue with Platforms plugin where resources are not compressed;

    If you're not using subscenes, you can disable catalog loading which causes crashed in release builds.
    Use a custom bootstrap for that, and you'll be able to build with default build pipeline.

    E.g.
    https://forum.unity.com/threads/doe...led-automatic-bootstrap.1171117/#post-8355027

    Though you'd need to modify Entities package to set some methods from internal to public.
     
  5. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    49
    Thanks.
    To have a custom bootstrap I have to dig into the Entities package and know about the workflow, right?
    But isn't there an easier solution?!
     
  6. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    What you want is to strip GameObjectSceneUtility.AddGameObjectSceneReferences() call.
    Which is what causing an exception (crash in release builds) due to missing resource catalog built for the subscenes (if built by default build pipeline).

    Its not that difficult really. See Entities -> AutomaticWorldBootstrap.cs;

    Declare UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP as project define, and initialize world on your own.
    E.g. call DefaultWorldInitialization.Initialize:
    Code (CSharp):
    1. #if UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
    2.    // Mimic what AutomaticWorldBootstrap does, but without calling into SubScene conversion
    3.    public static class AutomaticCustomWorldBootstrap {
    4.       [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    5.       private static void Initialize() { DefaultWorldInitialization.Initialize("Custom Default World"); }
    6.    }
    7. #endif
    Then you'd need to dig into Entities package and mark some methods public. Simplest way is to copy paste DefaultWorldInitialization & figure out whats marked as internal. Alternatively, use custom bootstrap from the different thread I've posted. Its for 0.51 and you'd figure out what methods needs to public pretty fast.

    Otherwise just performing default world initialization should be enough.

    Then you can build with default build pipeline just fine. Though subscenes won't be available obviously.
     
    Last edited: Nov 28, 2022
    hojjat-reyhane likes this.
  7. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    49
    Thanks a lot, @xVergilx.
    You saved our project. :)
    I tested with the default build pipeline and Play Asset Delivery. Both worked well.
     
    xVergilx likes this.
  8. HotYearKit

    HotYearKit

    Joined:
    Dec 4, 2018
    Posts:
    9
  9. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    49
    Thanks.
    But this is not related to my problem with the Entities build pipeline.
    Also when you want to publish a game with more than 150 Mb size on google play, it's better to use Play Asset Delivery.