Hi, the last few days i'm doing some testings with the WebGL export in Unity pro...and i'm really shocked about the filesizes Unity is producing!?! Compared to the Marmoset Toolbag/Viewer the same model, no textures,both started with an empty scene and one light: Unity WebGL 29MB - Marmoset 2,1MB. What the.... is going wrong?!?!? Which Screws have to be turned to make the filesize not that big ? Just for notice - no textures are used yet. Thanks for any hint in advance
Are you looking at a development or release build? Also, which version of Unity? And, did you read the "Distribution size" section here: http://docs.unity3d.com/Manual/webgl-building.html ?
Hi! I'm using the realease build with Unity Pro 5.3.3 Yes i have read that "Distribution size" and my settings are like explained in this artice. It's just a standard scene with one light, no textures and one model ( FBX 900KB - 51K Verts ). The only 3rd Party asset is a handler for touch/swipe input - without this asset same WebGL size.
Which files are how big exactly? You can probably optimize the asset sizes to use mesh and texture compression to get the build size down.
Am I right to say that the WebGL Distribution is still quite large as it basically has to have the whole Unity Engine in there too? I imagine that as WebGL Distribution improves the Distribution build might be able to strip out a ton of parts that are not actually used in the final WebGL game/ Thanks Jonas and please do share any further information as/when you can.
Unity is already stripping the things that are not needed in your game. So if you have no reference to i.e. Physics, then this will be stripped from the final build. So you have to be careful to not drag in stuff you don't actually need.
Jonas, thank you for this link. In my WebGL build of a recent game, I had about 75MB and after following this advice (mostly the crunching of textures and optimization of models) it reduces to 17MB. Very nice!
@mcroswell great to hear you could slim down your build from 75mb to 17mb but I think 17mb is still far too big for the web. How are your experiences with the 17mb build? What are your main users? We have a lot of users from emerging countries and they struggle to even parse 17mb of JavaScript with their devices. @alphakanal how did you solve the problem of build size? Did you give up or did you find a solution? @Schubkraft are there any efforts to further improve stripping of unused code? Is it possible to further modularize the engine code so that there are more options to strip code or is there no more space left for improvement?
@stephanwinterberger Yes we are still working on better and more granular stripping. But the "easy" big gains are behind us so now we have to wrangle with problems that are way deeper into how Unity as a whole works and is setup. In 5.5 we made some smaller gains by doing additional stripping of duplicates on the final JS output itself and are also offering optional brotli compression improving the download size through better compression.
@Schubkraft great to hear that there is progress going on for us especially physics add a lot of JS which we (probably, at least I think so) don't need. So let's see with what you guys come up in the future. I'm really excited
If you don't need PhysX make sure it is not used anywhere by accident and then it will get stripped automatically. If you are on 5.4 try the beta of our build report which will tell which systems are included in your build and why. Just make a build as usual and then go to http://files.unity3d.com/build-report/ click the button and then you'll get the info. We're working on making it more useful, prettier and included in the editor, but it is a good start to help you figure out what is happening with your builds.
@Schubkraft thanks for your response. I'll try the tool you linked as soon as I have time. But I think I didn't explained my problem very well. Yes I need the PhysX but I don't need the whole PhysX. And therefore there is a huge overhead for us. Ideally there would only be some function/classes compiled from PhysX into our JS and not the whole PhysX. Yeah, but I'll check the link http://files.unity3d.com/build-report/ later
Ah yes. We are aware of this problem but doing this kind of granular stripping is not an easy task. We made some small steps for example if you are not using cloth or a wheel collider we are stripping that stuff out of the PhysX since we could separate this nicely. We would like to get there long term, but there is a ton of work that needs doing for that and as always, priorities/resources etc.
@Schubkraft great to hear that there is progress on reducing the build size also for builds with PhysX. Haha so you have the same "problems" as everyone hope this issue will get high priority and a lot of resources since it is the biggest problem for us. But I can see that there are many other challenges which are also important and maybe effect more people than just me.