Search Unity

Questions about Build Report Tool

Discussion in 'Web' started by OOLE, Oct 24, 2016.

  1. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    Hi,

    first of all thanks for providing the build report tool (http://files.unity3d.com/build-report/). It's great and a good way to see whats going on inside of a WebGL build. Now that i played a little bit around with it i have a few questions.

    1. Here's a screenshot of the modules included in a WebGL build with no assets (only one scene with a main camera):



    I think the module Audio can be excluded by removing the AudioListener component from the main camera. But why are the modules CloudWebServices and UnityWebRequest added to the build? Is there any way to exclude them from the build?

    2. Here's is another screenshot of a WebGL build. The only thing changed (compared to the porject mentioned above) is that a Button-Prefab was added in the Asset folder:



    As you can see a lot of modules are added to the build and the size is 19MB instead of 11MB. The biggest module is "Physics". Is there a way to exclude any of this modules (especially the Physics)? Or is this the minimum number of modules for a project which uses the UI elements.

    I appreciate any hint how to reduce number of modules or the final size of the build. And thanks again for providing the build report tool ;-)
     

    Attached Files:

    tigerleapgorge and Ali_V_Quest like this.
  2. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    I have a similar request: while the build tool is pretty awesome for determining what's stripped, it would be nice if it listed dependencies too (e.g. what scripts and modules in your project are using physics). It's already been helpful though in it's current form, but adding dependencies would make it perfect.
     
    tigerleapgorge and Ali_V_Quest like this.
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Note that the Build Report tool is still in an early preview state. Some of the mentioned things are being addressed already.

    This is used by the HW Stats, which you can turn off in PlayerSettings. In 5.5 (or maybe 5.6, I forgot), Build Report will tell you this.

    Because it supports the case where UI elements can be occluded by a collider, The UI module, currently drags in Physics and Physics 2D. This has been fixed in 5.5 (in some cases we had to find these issues ourselves with the new build report tool, to become aware of them).
     
    tigerleapgorge and Ali_V_Quest like this.
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    5.5 will improve this a little by showing you which scene depends on a class when you have scene dependencies. For scripts, it is more difficult, as the dependencies may go very deep through many chained dependencies. We might support this in the future, but not before this feature actually ships with it's current feature set.
     
    tigerleapgorge likes this.
  5. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    Thank you for answering the questions! I build the test project with Unity 5.5 Beta and all the dependencies disappeared. The project is only about half of the size compared to the build with version 5.4. I think that's a huge step forward! Thanks again for the great work :)
     
    tigerleapgorge likes this.
  6. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    I just noticed that Physics and Physics2D Modules are added to the dependencies if you reference the UI-Module via Script:

    For example:
    ...
    using UnityEngine.UI;
    ...

    public class NewBehaviourScript : MonoBehaviour {

    private Button btn;
    ...
    }

    I think its the same if you add UnityEngine.Events or UnityEngine.EventSystems. Is it possible to fix this?
     
    tigerleapgorge likes this.
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Where can i find information on what is this tool and how it can be used ?
     
  8. OOLE

    OOLE

    Joined:
    May 13, 2015
    Posts:
    14
    If you use Unity 5.4 or higher you can just build a WebGL project and enter this page http://files.unity3d.com/build-report/. Then press the "understood" button and you will get a report about your last build.
     
    tigerleapgorge likes this.
  9. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    Is this always going to be the case? We reference the Unity's UI system in code (a lot) and thus physics does not get stripped (even though we don't use it, directly at least). I'd love to strip physics if possible (it's huge portion of our total code size).
     
    tigerleapgorge likes this.
  10. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Unity 5.5 should fix the dependency from UI to Physics and Physics2D.
     
    tigerleapgorge likes this.
  11. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    It kind of has. As noted by @OOLE, if you have UI objects in the scene (and not referenced in code), then 5.5 will strip physics from the build. I have confirmed that this works. However, if I create an empty project and include even just a simple script like this:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class Sad : MonoBehaviour
    5. {
    6.     public Button button;  
    7. }
    Then 5.5 (even using patch release 3) will include physics and physics 2D. Is this the expected behavior?
     
    tigerleapgorge likes this.
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    No, not expected. But I can reproduce. Will investigate.
     
    tigerleapgorge likes this.
  13. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Ok, I figured out the issue and made a fix. This will be fixed in 5.6.
     
  14. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    Hey Jonas, thanks for fixing this! I just tried it out in 5.6 and it does seem to be correctly stripping the physics (both 3D and 2D) in 5.6.

    I have a couple other questions for you about the build report tool, if you don't mind:

    * Other than OnGUI(), what might cause the IMGUI module to be included in a build? I've been trying to remove stuff from our project piece by piece to determine this, but even after removing external libraries we have 10,000 lines of code - I could use a hint :)

    * What is the UnityConnect Module? It always seems to be included, and it brings with it a few other modules. The only thing I can find called UnityConnect is the UnityConnectSettings.asset in the ProjectSettings. It looks like it's related to the Services window and settings, which we have totally disabled. I can't find any reference on Google. Whatever it is, I'm pretty sure I don't want it - so how do we remove this from our build?
    (Note: I think I figured this one out: if you don't check 'disable HW statistics', it looks like it pulls in all this Unity Connect stuff - checking that box removes about half a meg from the build.)

    * What kinds of stuff goes in the IL2CPP Generated module? Even in a blank project in 5.6, this is still about 8 GB. This can't be the core Unity engine stuff, since that's recorded separately (under Core Module, Physics, Audio, Animations, etc.). So what does it contain?

    Thanks much!
     
    tigerleapgorge likes this.
  15. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    I too am interested in the IL2CPP module. Mine is more like 12 mb. Is this user code? Why would a WebGL build even have CPP code? I thought it gets converted to js via emscripten.
     
    tigerleapgorge likes this.
  16. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Any GUI Scripting API will include it. This includes the Event class, which AFAIK is used by Unity new UI - so there may be a dependency from Unity UI to IMGUI at the moment.

    Seems you figured this out already. Unity 5.6 should explain this in the build report view.

    This is all the managed code in your project. This includes your own scripting code (All your user scripts), and managed dlls included in your project, but also, everything used from UnityEngine.dll and .NET system dlls (ie, mscorlib.dll, System.dll, etc). The Unity Engine modules which are listed separately only include the native code (ie all the parts written in C++). All managed code (ie, stuff written in C# or UnityScript) is in the IL2CPP Generated module.
     
  17. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    Thanks for the reply!

    Yep, my own tests seem to confirm this. If you have any script that has 'using UnityEngine.EventSystems', it will pull in the IMGUI stuff. It would be nice to break this dependency - doesn't seem to be any real reason for it. (I took a quick look through the UnityEngine.UI dll, and didn't see anything referencing IMGUI.)

    There's nothing that specifically explains this, as far as I can see - here's a screenshot of what I see from a build in 5.6:

    upload_2017-4-10_14-58-14.png
    I was able to figure it out, but it would be nice if it referenced something a bit more specific, like the ProjectSettings file that's causing it to be included. I'm sure that's a lot of work though :)

    Thanks, that's helpful! So in an empty project, the 3 MB that I see in Unity 5.6 would be the basic Unity dlls, and Core would contain the engine stuff (in C++). So when I look inside Core and see something like Component, that's the C++ implementation of Components that's binded to the C# implementation with the [MethodImpl(MethodImplOptions.InternalCall)] attributes?
     
  18. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    The 'Event' class is implemented by the IMGUI module, and used by UnityEngine.UI. I'd have to investigate if it might be possible to move 'Event' to Core module, but I think it might be too entangled with IMGUI code internally.

    You are right, but there should be. I'll investigate, maybe it broke (though there is an automated test to check that it should show up).

    Correct.
     
  19. LightYarn

    LightYarn

    Joined:
    Nov 18, 2012
    Posts:
    77
    Hey Jonas, can you confirm that this behavior is fixed in 5.6?
    I'm using 5.6.1p2 and the physics module still gets implemented:

    upload_2017-6-8_13-33-33.png

    In our whole project there is not a single line referring to Rigidboys, BoxCollider or Physics in general. Moreover there are no physic-components in our scene or on any prefab.

    I running out of ideas how to get rid of the physics module and it seems like it is still being pulled in via some weird connection/reference in Unity itself.

    Could it be TextMehPro? I doubt it....but as I said: I'm running out of ideas :-(
     
    Ali_V_Quest likes this.
  20. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    Yes TextMeshPro references physics in TMP_SubMesh.cs (you'll have to comment it out, assuming you don't use the feature!). And yes I can confirm physics stripping is fixed in 5.6 and 5.6.1 (I'll assume they didn't break it in p1 or p2).

    @jonas-echterhoff , do you know if this is intended? This effects us too obviously and I filled a bug report but the response I got was basically "by design". It would be nice to strip IMGUI.
     
    zephyo and LightYarn like this.
  21. LightYarn

    LightYarn

    Joined:
    Nov 18, 2012
    Posts:
    77
    Thank you @kognito1 !
    Unfortunately I'm using the free version of TMP and it comes with precompiled .dll files. There is no sourcecode I could edit. Damn, I really hoped to get rid of the physics module after rewriting our click-detection routine. It's kind of frustrating.... :-/
     
  22. Tinovdk

    Tinovdk

    Joined:
    Nov 28, 2013
    Posts:
    83
    Thanks indeed @kognito1 for finding that. Similar to @LightYarn, I am also using the free version of TMP. My project is very simple and only uses a few TMP texts. It seems that the inclusion of the TMP runtime DLL causes the physics module to be included in a WebGL build. I need TMP for dynamic white text to have an outline and drop shadow so that the text is readable on a bright background. This is not very nice to do with Unity's UI.Text.

    As a result, 25% of my build size is presumably taken up by the physics references in TMP_SubMesh.cs

    explorer_2017-07-28_01-22-11.png

    Maybe @Stephan_B is able to provide a solution?
     
  23. fwalkerCirca

    fwalkerCirca

    Joined:
    Apr 10, 2017
    Posts:
    57
    Has /files.unity3d.com/build-report been replaced by something else on 2018?
     
  24. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    In 2018 you can use the Build Report Inspector. Have a look at this talk for more info.
     
    tigerleapgorge and ortin like this.
  25. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221