cocos-engine
cocos-engine copied to clipboard
CC3 Engine Code double size from CC2
In CC3 the cc.js engine file seems to be quite a bit larger than in CC2. It's still huge after disabling all the features I don't need. Are you looking into making it smaller or isn't it possible?
CC3 (2200 KB)

CC2 (1011 KB, Over 100% smaller!)

And this one from CC3 is with almost every feature turned off:

I'm guessing there are something from 3D that is not cleaned up in the engine, even though you create a fully 2D game? This has a big effect on total bundle size of games.
@Ronsku yep, we are still trying do more effort on it. Can i know where will you publish your games?
Thanks @minggo, great to hear! I only publish for web-mobile platform, let me know if I can help testing in any way.
Thanks @Ronsku , i will ask your help if needed. Can i know more about the web-mobile platform? What's the limitation of the platform, for example, size limitation. And how can you earn money from it?
@minggo, No limitations really, just like any website or software you want it to be loading as fast as possible to your users. Doubling the size of the engine causes bigger loading times and a worse user-experience. Earnings comes from user satisfaction and from the same logic as loading a webpage. If the webpage you are going to is loading for too long you might leave it and the company would lose a potential customer.
I think loading times are always very important for a good UX. You want to play, not watch a loading screen.
@Ronsku thanks for the information. How long it takes based on your testing? And what's the loading time is acceptable?
@Ronsku thanks for the information. How long it takes based on your testing? And what's the loading time is acceptable?
That's a very difficult question to answer, since it is all based on server and user connection and also user's device that needs to run the code, launch the Web Canvas etc. The smaller the better without of course sacrificing features. This is why the "Feature Cropping" is a thing in Cocos Creator, to make the final bundle as small as possible while maintaining the features you've selected for your game. This way you wouldn't for example need to download all 3D features in a 2D game or DragonBones, unless you use it. Just as examples.
Problem in this case is that the CC3 final built code with most features cropped out is still double the side of the final build of a CC2 game.
Thank you @pandamicro for picking this up. Highly appreciated!
@pandamicro and @minggo
I have confirmed that CC package size has gone up again in CC 3.5 slightly
from
CC2: 1011Kb
CC 3.4: 2,200kb
CC 3.5: 2,247kb
This is also with removing Marionette system from previous test
Almost everything removed and package still big.
I'm not sure what is making it so massive, but it hurts loading times a lot.
Yes, we have identified some optimization points, such as eliminating built-in effects and optimizing the decorators, and in version 3.6, we will optimize these part
Yes, we have identified some optimization points, such as eliminating built-in effects and optimizing the decorators, and in version 3.6, we will optimize these part
Amazing, can't wait! I will be a very big boost to the game loading :)
@holycanvas Does this help in native env as well?
@holycanvas I really hope this ticket will be taken seriously, because it is actually causing a lot of problems for me currently.
Having over 2x size on cc.js doesn't only cause 2x loading downloading time, but the worst part is that especially on slower devices parsing of huge JavaScript files is really costly.
I have huge difference between loading CC2 and CC3 games. I was even struggling a bit in CC2 to get good loading times. Now in CC3 it just takes way too long with this massive 2.2Mb chunk of JavaScript. Of course I run it through GZIP, but it's still double the size from CC2.
Can you help me understand what is the main reason behind the size? Are there any way to manually clean up features not used?
Yes, we have identified some optimization points, such as eliminating built-in effects and optimizing the decorators, and in version 3.6, we will optimize these part
How about "Feature Cropping"? It doesn't seem to affect the bundle size if you check out most of the packages form the feature cropping in project settings.
For example in 2D games, I'm just guessing that the whole 3D library is packaged with it, even though it is not selected in the feature cropping.
Some Google Lighthouse stats, on a game with most features removed 😬
Non-GZIP

GZIP:ed

Same on CC 2 Gzip:ed, not great, but much better:

@Ronsku Have you tried the build setting "Erase module structure(experimental)"? That option will flattern import chain.
@shrinktofit No I had not tried that one before. I tried it now with an empty project. Here are the results:
Feature Cropping:

Build Settings WITHOUT "Erase module structure(experimental)"

Build Settings WITH "Erase module structure(experimental)"

Size of the Engine code is exactly the same 😞
@Ronsku Well this option is dedicated to project scripts, not engine :)
@shrinktofit I see, but didn't help with loading speed for me at least. Engine size is the issue
In v3.6, we will remove effects.js from the engine to achieve two goals
- Reduce engine package size by 20% - 30%
- Improve engine initialize speed by only loading necessary shaders to GPU
This is also described in https://github.com/cocos/cocos-engine/issues/10529, so we will complete the last in v3.6, and I'm moving this issue to v3.7 so that we can keep tracking further optimizations
@holycanvas How is the progression of this task ?
@holycanvas How is the progression of this task ?
@holycanvas Is this ready for 3.6 already. Am I able to see fetch it as a custom engine already or is this a build in editor feature somehow?
@holycanvas Is this ready for 3.6 already
@Ronsku Yes, In 3.6, all builtin effects had been removed from engine
in 3.6.0 beta we've gone down from 2.2mb to 1.7mb in size of the built engine (77.3% of previous). When GZIP:ed it went down from 743Kb to 603Kb (81.2% of previous)
Compared to CC2 the difference is still big: CC2: Gzip:ed: 380Kb CC3: Gzip:ed: 603Kb (59% bigger)
Thanks for your testing. In v3.6, we have optimized some effect. and In v3.7, We will optimize the module and decorator and so on.
Update from CC 3.7.0 I just ran a very basic 2D game build with no 3D features in the feature cropping and only a few 2D things picked. The engine size is even bigger than before 2330 KB compared to CC2 which currently run around 990 KB
CC3:

CC2:

Update on CC 3.7.0
By Removing
- 2D Physics System
- 2D Intersection Algorithms
- 2D Particle System
We come down to 1796 KB, but that's still Double the size of CC2 and loading is not only download size, but also weaker devices Evaluation and CPU time going through all of that code.

@PPpro @holycanvas @pandamicro "PPpro removed this from the V3.7 milestone on Dec 5, 2022"
Are there any plans to bring this back? This and scene swapping performance https://github.com/cocos/cocos-engine/issues/11503, are the main reasons I have to stick with CC2 instead of CC3.
I need to be able to create 2D games that loads fast and efficiently. CC2 is already much slower and bigger than than for example PixiJS, but still in an acceptable range. While CC3 becomes so slow and heavy that it's not an option anymore :(.
I and a lot of other people really wants to swap to CC3 to get all the other benefits from it, but we're unable due to this.
@Ronsku we are improving modularization these days. Then developers can use features they want. It will be released in v3.8, which is planned to be released in June.
3.7.2 Update, engine size has remained close to 2mb (2x size of CC2)
Result of build:

Sorry, we adjusted this issue plan to milestrone 3.9
Sorry, we adjusted this issue plan to milestrone 3.9
Okay, thanks for the update! Hoping so much for a great size reduction and speed of initial load, so that I can swap from CC2 to CC3 before it becomes CC4.
Thanks, let me know if I can help in any way!