Closed samreid closed 1 month ago
Self assigning to see why density went from 4MB to 15.6MB
The density-buoyancy-common/images/*.ts files take up 12.2MB before compression.
I tried running grunt profile-file-size
but I don't trust the results:
~/phet/root/density$ grunt profile-file-size
Running "profile-file-size" task
summary:
TOTAL: utf-8: 15590787 (100%) 14.87 MB gzip: 10006228 (100%) 9.54 MB
images: utf-8: 0 gzip: 20
sounds: utf-8: 0 gzip: 20
webpack (includes assets): utf-8: 0 gzip: 20
preload: utf-8: 0 gzip: 20
strings: utf-8: 0 gzip: 20
license: utf-8: 0 gzip: 20
details:
utf-8: 15590787 (100%) 14.87 MB gzip: 10006228 (100%) 9.54 MB ROOT
Done.
I found the instructions in https://github.com/phetsims/chipper/blob/2e189c04dddd4f8531997d3f68717a6f884be39e/js/grunt/profileFileSize.js#L8-L9 and got a more trustworthy result:
~/phet/root/density$ grunt profile-file-size
Running "profile-file-size" task
summary:
TOTAL: utf-8: 15913176 (100%) 15.18 MB gzip: 10149752 (100%) 9.68 MB
images: utf-8: 12089901 (76%) 11.53 MB gzip: 9026476 (88.9%) 8.61 MB
sounds: utf-8: 92688 (0.6%) 0.09 MB gzip: 51605 (0.5%) 0.05 MB
webpack (includes assets): utf-8: 14315729 (90%) 13.65 MB gzip: 9634178 (94.9%) 9.19 MB
preload: utf-8: 1170343 (7.4%) 1.12 MB gzip: 340789 (3.4%) 0.33 MB
strings: utf-8: 333479 (2.1%) 0.32 MB gzip: 149243 (1.5%) 0.14 MB
license: utf-8: 50236 (0.3%) 0.05 MB gzip: 10317 (0.1%) 0.01 MB
js axon: utf-8: 47917 (0.3%) 0.05 MB gzip: 12505 (0.1%) 0.01 MB
js brand: utf-8: 37598 (0.2%) 0.04 MB gzip: 14522 (0.1%) 0.01 MB
js chipper: utf-8: 3588 gzip: 1498
js density: utf-8: 111606 (0.7%) 0.11 MB gzip: 69311 (0.7%) 0.07 MB
js density-buoyancy-common: utf-8: 12469476 (78.4%) 11.89 MB gzip: 9077825 (89.4%) 8.66 MB
js dot: utf-8: 119938 (0.8%) 0.11 MB gzip: 27693 (0.3%) 0.03 MB
js joist: utf-8: 195676 (1.2%) 0.19 MB gzip: 65938 (0.6%) 0.06 MB
js kite: utf-8: 136921 (0.9%) 0.13 MB gzip: 31949 (0.3%) 0.03 MB
js mobius: utf-8: 13928 (0.1%) 0.01 MB gzip: 4415
js phet-core: utf-8: 11480 (0.1%) 0.01 MB gzip: 3787
js phetcommon: utf-8: 4488 gzip: 1532
js scenery: utf-8: 708706 (4.5%) 0.68 MB gzip: 161982 (1.6%) 0.15 MB
js scenery-phet: utf-8: 76245 (0.5%) 0.07 MB gzip: 32039 (0.3%) 0.03 MB
js sherpa: utf-8: 69836 (0.4%) 0.07 MB gzip: 17691 (0.2%) 0.02 MB
js sun: utf-8: 114755 (0.7%) 0.11 MB gzip: 28210 (0.3%) 0.03 MB
js tambo: utf-8: 100150 (0.6%) 0.1 MB gzip: 48769 (0.5%) 0.05 MB
js tandem: utf-8: 45507 (0.3%) 0.04 MB gzip: 12170 (0.1%) 0.01 MB
js utterance-queue: utf-8: 28263 (0.2%) 0.03 MB gzip: 7359 (0.1%) 0.01 MB
This shows that Bottle, Boat, Diamond, etc are ending up in the density build for some reason. Images are the main reason for the large file size.
DensityBuoyancyScreenView imports Duck, Boat, Bottle. DensityMaterials imports 37 textures. I do not see a trivial way to isolate those modules. Are the mystery textures like DIAMOND used in Buoyancy or Buoyancy Basics? Probably not. Let's discuss how much time and complexity we want to invest in reducing the file sizes.
We discussed and agreed we would like to prune the sizes where possible.
We went through this today, and it feels like some image files added a while back were very high-res (i.e. Plastic and some metals). At least 100 times bigger than the other textures. We could down-scale them to improve file size.
For now I'm just leaving the comment but will take a look later.
5.1M | density_all_phet.html
This was achieved by downscaling the images from 1024x1024 to 256x256. And it's barely noticeable in the sim:
I also think there's room for improvement. As some textures are not actually used in density but they are imported anyways. But could be a minimal return at this point.
Also, I honestly feel like the normal and roughness maps are not adding that much...
I confirmed density_en_phet.html is now 4.8MB and buoyancy-basics_en_phet.html is 4.9MB, so this issue seems good to close. Nice work @AgustinVallejo. Closing.
For the phet brand _en files: Density is 15.6MB Buoyancy is 16MB Buoyancy: Basics is 15.7MB
This is much larger than other recent simulations. For instance, Projectile Data Lab is 3MB.
So we should make sure this is well explained and warranted, or see if it must be pruned. We know this is a large simulation, and it also brings three.js + mobius (rendering) and p2 (physics).
In contrast, the published version of density is 4MB