Unity WebGL

3 min. read

Unity: WebGL

Use the profiler to to determine what upload
Development build
Automatically connect profiles

Look at Reserved Total

Total memory required = (Reserved Total) + (15-20 Mb) + (Multiple of 16)

2 Gb is the limit

Asset Bundles loads 8 x times more memory

Use this package:
WebGL Template
https://assetstore.unity.com/packages/tools/gui/responsive-webgl-template-117308

UWebGL Input
https://assetstore.unity.com/packages/essentials/tutorial-projects/ime-input-for-unity-webgl-64933

Cached Memory:
https://assetstore.unity.com/packages/essentials/tutorial-projects/cachedxmlhttprequest-71538

WebGL Sockets:
https://assetstore.unity.com/packages/essentials/tutorial-projects/simple-web-sockets-for-unity-webgl-38367

Streaming Audio
https://assetstore.unity.com/packages/essentials/streaming-audio-source-for-unity-webgl-75612

Memory Usage
setInterval(function() { if (typeof TOTAL_MEMORY !== ‘undefined’) { try { var totalMem = TOTAL_MEMORY/1024.0/1024.0; var usedMem = (TOTAL_STACK + (STATICTOP - STATIC_BASE) + (DYNAMICTOP - DYNAMIC_BASE))/1024.0/1024.0; console.log(‘Memory stats - used: ‘ + Math.ceil(usedMem) + ‘M’ + ‘ free: ‘ + Math.floor(totalMem - usedMem) + ‘M’); } catch(e) {} } }, 5000);

Performance
https://blog.kongregate.com/unity-webgl-memory-and-performance-optimization/
https://github.com/kongregate/Unity-WebGL-Utilities
https://blog.kongregate.com/unity-webgl-memory-optimization-part-deux/
https://blog.kongregate.com/managing-game-loading-memory-in-webgl-with-unity/
https://github.com/GalvanicGames/unity-game-loader
https://blog.kongregate.com/unity-webgl/
https://blog.kongregate.com/locust-io/
https://blog.kongregate.com/lambda/

Custom Template
https://github.com/greggman/better-unity-webgl-template

https://docs.unity3d.com/Manual/webgl-templates.html

https://ocias.com/blog/full-browser-window-unity-webgl/

https://docs.unity3d.com/Manual/webgl-building.html

https://docs.unity3d.com/Manual/webgl-memory.html

https://docs.unity3d.com/Manual/webgl-deploying.html

https://docs.unity3d.com/Manual/AssetBundles-Building.html

https://ocias.com/blog/how-to-set-up-a-unity-webgl-template/

https://www.linkedin.com/pulse/everything-you-need-know-unity-webgl-building-hulusi-onder/

https://blogs.unity3d.com/2016/09/20/understanding-memory-in-unity-webgl/

https://www.linkedin.com/pulse/everything-you-need-know-unity-webgl-building-hulusi-onder/

References
Unite 2016 - Practical WebGL Advice from the Field
https://www.youtube.com/watch?v=6-S-P7ekdBc

https://www.youtube.com/watch?v=2h2NDUQnGuo

http://researchandprogram.blogspot.com/2020/01/unity-webgl-issues-and-solutions.html

https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html

https://docs.unity3d.com/Manual/webgl-deploying.html