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?
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/
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.
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.
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
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.