Search Unity

WebGL Optimization

Discussion in 'Web' started by mickfcna, Jul 1, 2019.

  1. mickfcna

    mickfcna

    Joined:
    May 13, 2019
    Posts:
    46
    Hi all,

    I work with Unity 2018.3. I did all my possible to reduce loading time of my game but it still too long for computers and even worse for mobile phones.

    Does the new version of Unity improve really the loading time in WebGl ?

    I have to change a lot of things on my current project to make it working with the last version of Unity so I would like to know before losing time on it.

    Thx !
     
    JamesArndt likes this.
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,200
    Last edited: Jul 1, 2019
  3. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    2019.1 also introduces the ability to use streaming instantiation, which while it somewhat improves initial load times (compiles as it downloads), also comes with the benefit of browser vendors taking this a step further and caching the compiled output specifically for this format. On Chrome 76 I'm finding subsequent page visits load within 1 or 2 seconds which is a huge step up from the previous 5 or 6 seconds I'm used to.
     
    fxlange, mickfcna and vb2s360 like this.
  4. vb2s360

    vb2s360

    Joined:
    Oct 7, 2015
    Posts:
    34
    Hi JJJohan, great to hear this. Did you have to make some changes on your server to allow streaming instantiation ?
     
  5. mickfcna

    mickfcna

    Joined:
    May 13, 2019
    Posts:
    46
    Ryiah thx I gonna update my version.
     
  6. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    Yes, you will have to serve the .wasm file that is produced with the Content-Type: application/wasm header. Also if you're using compression you'll have to ensure the correct Content-Encoding header is also set on this file (eg gzip or br) which is not optional for this file, else the streaming instantiation will not succeed.

    It's not a Unity specific feature so there should hopefully be appropriate guides for this for whichever server you happen to use - Nginx, Apache, AWS S3 etc.
     
    vb2s360 likes this.
  7. metaphysics

    metaphysics

    Joined:
    Nov 25, 2014
    Posts:
    2
    Has anyone had any luck with this. I have made the changes to get IIS to respond with the proper content-encoding header, which gets you past the "magic number" error, but then you run into the error "net::ERR_CONTENT_DECODING_FAILED" when it is trying to download the unityweb or wasm files

    @JJJohan