Search Unity

WebGL stripping

Discussion in 'Web' started by jareds, Apr 11, 2016.

  1. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Hi,

    I'm trying to reduce the side of my the .jsgz file created by Unity for my WebGL project.

    The instructions on this page (http://docs.unity3d.com/Manual/webgl-building.html) have been helpful. I'm looking at trying to reduce the number of classes included in the build. The page says:

    Unity does not yet provide a convenient way to see which modules and classes are included in a build, which would allow you to optimize your project to strip well. We are working on providing that information - in the meantime, you may want to look at the generated file Temp/StagingArea/Data/il2cppOutput/UnityClassRegistration.cpp after making a build, to get an overview of included classes and modules.

    I've been looking at the UnityClassRegstration.cpp file and I have a few questions.

    * I've created an empty project and this still uses a number of classes (31) that I would like to exclude if possible. Is there any way to do that, or are they required for all Unity builds? Some examples of classes that I'd like to avoid using include:

    void RegisterClass_Cubemap();
    void RegisterClass_Texture3D();
    void RegisterClass_LightmapSettings();
    void RegisterClass_LightProbes();

    * Using the new UI in my scene causes the inclusion of the Physics engine. Is there some way to avoid this? I see Physics2D is separate from Physics, and I don't need any Physics in my game so it would be nice to avoid including it.

    Thanks,
    Jared
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Some classes are used internally by the engine, adding these cannot be avoided currently.

    This I'd like to investigate in more detail. Do you have a small repro project which would let me analyze where this dependency comes from?
     
  3. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Thanks Jonas!

    I've created a bug and attached a sample project to it. Here's the link:

    https://fogbugz.unity3d.com/default.asp?788244_6tvd9hlf50os24t9

    If I have just the Canvas component, I only get the UI module, but if I add Canvas Scaler (or Text or Image or a number of other things) it adds Physics when it seems like it shouldn't. The project was created with Unity 5.3.5p1. If you need any more information, please let me know.

    On a somewhat related question. Do you have any tips on improving the loading time of WebGL projects (especially in IE11)? We have a client that requires IE11 support and I'm trying to do everything possible to make my project load quickly. We've reduced asset sizes, tried to remove code dependencies, moved content to asset bundles and a few other things.. just wondering if you have any other suggestions. I realize we are restricted by the browser's ability to parse the JS, just hoping there's something I can do to improve things (even slightly).
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    It seems that UI does indeed currently have dependencies into Physics for doing Raycasts for click detection. I'm talking to our UI team to see if this can be expressed in any way which would be more flexible about not always needing Physics (as that means dragging in a *lot* of code).

    As for IE11, sadly, I think that is almost a lost cause. While Unity WebGL content does - kind of - run, don't expect to get satisfactory results out of it.
     
  5. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Thanks Jonas. I appreciate you taking a look! If there is any update on this front, will my bug be updated? I'm just wondering how closely I need to be watching the release notes for a potential change.

    Regarding IE11, I understand it is almost a lost cause. This may be an impossible question to answer, but here it goes: if you were to focus on one area to try to improve the loading time what would it be? Would you focus more on reducing overall asset size (seems to impact the .data file) or code size (the .js file)? For reference or .jsgz file is almost 5MB and our .datagz file is 59MB. Is there anything codewise that you know performs poorly in WebGL (JS arrays et cetera)?
     
  6. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    are there any updates on this ?
    1. how to detect which unity modules are included in builds
    2. does ui still include physics system ?

    Thanks.
     
  7. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    open http://files.unity3d.com/build-report/ after building for WebGL, and you should be able to see which modules are included in the build.

    AFAIK it's fixed.
     
    polyflow3d likes this.