Search Unity

Unity 2018 - WebGL lost 10 seconds to init on Chrome

Discussion in 'Web' started by unity_12funstudio, Jun 6, 2018.

  1. unity_12funstudio

    unity_12funstudio

    Joined:
    Jun 6, 2018
    Posts:
    2
    Hello everyone,

    My project build with WebGL, compression with Gzip and linker taget with asm.js. It is run perfect on Firefox with 1 second to init game. But on Chrome, my game lost 10 seconds to init. Is there a way to reduce boot time on Chrome?

    Thank all.

    My game link: http://res.12fun.net/Unity/12fun/index.html
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    • which OS?
    • have you tried WebAssembly?
     
  3. unity_12funstudio

    unity_12funstudio

    Joined:
    Jun 6, 2018
    Posts:
    2

    Attached Files:

    Last edited: Jun 6, 2018
  4. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    It's the same for me and it's like that since a long time.
    The loading is so fast in firefox compared to chrome.
     
    unity_12funstudio likes this.
  5. shb

    shb

    Joined:
    Oct 7, 2012
    Posts:
    23
    +1,
    for above URL,
    Safari, FF is pretty much fast like a few sec.
    but on Chrome it takes 10+ sec.

    Same for my game build too.
     
    unity_12funstudio likes this.
  6. Ace_Wu

    Ace_Wu

    Joined:
    Feb 10, 2017
    Posts:
    4
    +1
    Same for my game build too.
     
  7. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    So when you make a 2017.4 build Chrome loads that 10 seconds faster?
     
  8. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Chome has always been slow to initialize, even for wasm. The question is, are they ever going to do anything about their abysmal loading time?
     
  9. Ace_Wu

    Ace_Wu

    Joined:
    Feb 10, 2017
    Posts:
    4
    Does anybody know why Chrome's performance so different than Firefox?
     
  10. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    I suspect a few reasons, the biggest simply being Mozilla invented asm.js (which is also the foundation of wasm) and the compiler (emscripten) Unity uses for the webgl platform. You could say Mozilla has a head start. :)

    Harder to prove (more on the hand waving side), I think historically Google has tended to favor more of a JIT style compilation over AOT. That philosophy may or may not be the right approach for the web "in general" (a separate discussion), but I think it has proven not so effective for the types of web applications Unity produces. :D I bet even in this "wasm world" we now live in that Mozilla's wasm compilation stack is still non-trivially better than Google's due to their previous experience with AOT compilation.
     
  11. grobonom

    grobonom

    Joined:
    Jun 23, 2018
    Posts:
    335
    am sorry..... am so sorry.....
    but....
    you piss me off asking for webGL is slow at loading !!!!!!!
    YES IT IS !!!!!!! AND NOW WHAT ?????
    when you spend hours calculating lightmaps, reflmaps, pizzamaps....
    what is the problem with 45sec loading of your 3D scene ????????????????????????????

    there is much more important on webGL limts than the 'starting time' !!!!
    think about rendertextextures !!!!
    when you first played assassin's creed, didn't it take 2 minutes to load the level ?
    and did you suicide in the meanwhile ?

    3D is HEAVY !!!!!!!!!!
    bear the burden when it's worth it !
     
  12. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    WebAssembly in Chrome is not enabled by default...Experimental...
    chrome://flags/#enable-webassembly
    chrome://flags/#enable-webassembly-streaming

    Enabling these and using the big blue "Restart" button after enabling them helps.
    My almost empty project with just UI, 3 cubes and some colliders loaded up in 2 ~ 3 seconds on firefox. Chrome was about the same after enabling those experimental flags.
     
  13. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    chrome://flags/#enable-webassembly has been enabled by default for a while, unless you are running a pretty old version of Chrome.
     
  14. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Chrome version 67.0.3396.99 I still had to enable it myself.

    If I leave it on "Default" instead of "Enabled" Chrome takes longer to load and will give this message:
    [Unity Cache] WebAssembly module ‘/Build/Build.wasm.code.unityweb' not stored in the indexedDB cache due to the error: DataCloneError: Failed to execute 'put' on 'IDBObjectStore': #<Module> could not be cloned.
     
    Last edited: Jul 9, 2018
  15. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    This means the wasm compiled module could not be stored into IndexedDB. This simply means Chrome does not support wasm structured cloning yet. It's safe to ignore for the time being.

    Now, looking at the Chrome flags again, chrome://flags/#enable-webassembly's description is "WebAssembly structured cloning support.". So that makes sense (although it seems poorly named).
     
  16. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Safe to ignore but if I enable both those flags mentioned before, chrome does load faster, without that error message.
    Leaving the flags Default it takes longer to load than when it is enabled and getting that message.

    So I am uncertain now why enabling it explicitly makes it load faster than when set to default.
     
  17. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    sure, nothing prevents you from enabling it for testing purposes. That will speed up 2nd loads because the wasm compiled module is loaded from IndexedDB.
     
  18. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    There's also an #enable-webassembly-baseline flag in the pre-release versions (not entirely sure which Chrome channels have them, Canary definitely) that uses the new 'Liftoff' compiler, bringing initial non-cached startup times closer to that of Firefox's.