Search Unity

WebGL slow loading?

Discussion in 'Web' started by chillypacman, Apr 4, 2018.

  1. chillypacman

    chillypacman

    Joined:
    Oct 1, 2011
    Posts:
    71
    I think running up until 90% loading in the WebGL player is actually file downloading, but the last 10% where it's building the Unity webplayer is very slow and can be quite variable, I'm not sure why.

    Running locally on my machine using Firefox the load times can be quite reasonable (under 10 seconds for a small app) but running it in Chrome or Edge is always slow (closer to 20 seconds).

    After uploading the WebGL project to an Azure App service website the WebGL player usually takes about 20 seconds to load a simple app.

    Is there a way to profile why it's taking so long? Is this expected behavior for Unity's webgl player?
     
    tobizion likes this.
  2. johnsietsma

    johnsietsma

    Unity Technologies

    Joined:
    Jul 1, 2016
    Posts:
    8
    Hi there,

    How big is the build? I'd be curious to see both the code and asset sizes.
    Look in the build folder; the <yourproject>.data.unityweb file contains you assets and the <yourproject>.asm.code.unityweb file contains code and plugins. Can you let me know how big they are?

    Use this guide to help optimise the build: https://docs.unity3d.com/Manual/webgl-building.html

    Also use the Chrome web dev tools to check for errors, network issues, etc.
    tools: https://developers.google.com/web/tools/chrome-devtools/network-performance/
     
  3. Mybox

    Mybox

    Joined:
    Nov 8, 2015
    Posts:
    3


    Does this look like a normal loading time? Taking 25 secs or more, sometimes 40 secs.
     
  4. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Chrome has always loaded much slower for me, even for simple projects. 25+ seconds seems slightly high but not unheard of. Loading screens are a must. I would try removing any physics colliders so the build process strips the physics module out.
     
  5. PrisedRabbit

    PrisedRabbit

    Joined:
    Aug 14, 2012
    Posts:
    63
    I have the same issue. The simple hello world ui text project (about 3.5 mb) builded in webassembly starts in 8 seconds in Chrome (and in Chrome Canary), but in Safari it takes 3 seconds, in Firefox - <1 second.
    Our big project starts in 19 seconds in Chrome, in Firefox - 3 sec.
     
    Cfirzi likes this.
  6. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    I believe Chrome is slowly moving towards its newer tiered WebAssembly compiler (codename Liftoff) which is closer in performance compared to Firefox. I don't know which version it'll be landing in, but it can be enabled in the chrome://flags page for testing.

    Suffice to say this isn't Unity's (or Emscripten's) fault though.

    Google issue tracker: https://bugs.chromium.org/p/v8/issues/detail?id=6600&desc=2
     
    Cfirzi likes this.
  7. PrisedRabbit

    PrisedRabbit

    Joined:
    Aug 14, 2012
    Posts:
    63
    hm, with enabled WebAssembly baseline compiler it starts 2-3x faster.
     
    Last edited: Aug 17, 2018
  8. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    173
    How does one do that?
     
  9. PrisedRabbit

    PrisedRabbit

    Joined:
    Aug 14, 2012
    Posts:
    63
    It's enabled by default in latest version of Chrome
     
  10. tobizion

    tobizion

    Joined:
    Mar 16, 2019
    Posts:
    2
    Hi. Did you solve it? I have the same problem
     
  11. MindBuild

    MindBuild

    Joined:
    Oct 7, 2018
    Posts:
    22
    There are many different ways to improve loading times of applications. From removing plugins, reduce texture sizes and not using too many fonts.

    However, Android Chrome is really slow.

    Every other browser should be relatively fast. My app loads in about 10 seconds on all browsers, besides Android Chrome.
     
  12. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    300
    any news on how to improve loading time?
     
    sm_innov8 likes this.
  13. skilliza

    skilliza

    Joined:
    Jun 28, 2018
    Posts:
    1
    Change compression format to disable in player setting > publishing setting
     
    mickfcna likes this.
  14. mickfcna

    mickfcna

    Joined:
    May 13, 2019
    Posts:
    46
    @skilliza , the load is faster without compression ?