Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

optimize WebGL DLL Dependencies

Discussion in 'Web' started by OOLE, Jul 21, 2015.

  1. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    Hi,

    i try to optimize my WebGL build. In the Editor.log file it shows the following dependencies:

    Dependency assembly - Mono.Security.dll
    Dependency assembly - System.Core.dll
    Dependency assembly - System.dll
    Dependency assembly - mscorlib.dll
    Dependency assembly - UnityEngine.UI.dll
    Dependency assembly - UnityEngine.Networking.dll
    Dependency assembly - UnityEngine.Analytics.dll

    According to this post i removed some of the references and rebuild the project in MonoDevelop without any errors. So it seems that some of the dll files are not used in my code. When i build the WebGL application the removed dll files are still listed in the Editor.log.

    I also made a build of an empty WebGL project and it seems that this dependencies were added by default. Is there any chance to reduce this list of dll files.

    By the way i'm using Unity 5.1.2

    Any help would be very appreciated :)
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Can you confirm that any of these DLLs (the code in them) actually makes it into your WebGL game, even if you're not using them ?
     
  3. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Our WebGL platform, uses IL2CPP as scripting backend, which automatically strips all unused managed code. So, if you are not using these DLLs, they will not be included in the final build.
     
    liortal likes this.
  4. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    Hi,

    thanks for reply. Okay good to hear that :)

    I was just confused why e.g. the UnityEngine.Analytics.dll is listed in my Editor.log file as dependency and also appears in the "managed" folder of my project (about 38kb large, same size like in the "not stripped" folder). I definitively don't reference this one in my code and also checked the "disable HW Statistics" setting in the player settings (if this is related to the DLL).

    I just tried to optimize the export of my WebGL application and thought every dependency listed in the Editor.log will be inserted into the final code (at least a stripped part of the DLL). The export of my project is about 4.5MB large (compressed) and the included DLLs are the largest part of that (around 3.9MB = 88% of the whole build size).

    Related to this topic i have another question about the stripping. For example when i use only UI-Buttons in my GUI class, does it make any difference when i reference like that:

    using UnityEngine.UI.Button;

    instead of

    using UnityEngine.UI;

    Again thanks a lot for replying.

    I attached the Editor.txt of the last build if its of interest.
     

    Attached Files:

  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    These numbers are not really relevant for WebGL, as they measure dll size before the il2cpp conversion, so they say little about the final build size.

    No, no difference.