Unity Webgl Issues and Solutions

During my extensive interaction with unity WebGL, I found different things that are difficult to handle in unity WebGL or Unity Webgl has some serious limitations (But nevertheless I have managed to stream large 3D area in unity WebGL with asset bundles). I have made this post in order to show you Unity3D WebGL issues sheet and if you are interested to see what technologies or toolchain Unity WebGL using behind the Scene then check this post. So, without a particular order here is the list of unity webgl limitations with relevant references for your further research. 



1. You cannot use Threads in unity WebGL. Here is the error that you will get when thread try to start:
SystemException: Thread creation failed.
UnityLoader.js:4   at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
GameDev Question
Unity Forum
Unity Webgl Doc
Update: Unity claim that in Version 2019.1.0 they have added multiple Multithreading support but it was not working according to my test and now I also find this that there was bug with the problem which has fixed in Unity 2020.1.0 and Unity 2019.4.7 (untested)

2. If you are continuously pressing any keyboard input key and meanwhile you lost focus to WebGL canvas in the browser, the input will still work even after releasing the key. The situation may get worst in the Edge browser.
Ref:
SE Question
Maybe resolved in Unity 2019.3.0 but I have tested and still the same problem is happening.

3. There is no unload method for WebGL in the browser. But in the recent unity version from (Unity 2019 beta), you can use quit function. But there is still a problem that memory cleanup is not done after executing the quit method.
Ref:
SE Question
Unity Forum
SE Question

4. File Reading or writing not allowed.
Ref:
Unity Forum
File reading possible workaround is to convert your files into string. Like with U3D you can convert excel to a CSV file and use CSV file string. Check U3d Excel Github

5. There is no way to detect an error in JSLib File that you usually write for interaction with browser script (JS). The error will be shown in the browser after building the player for WebGL. This can be time-consuming if your WebGL takes too much time to build. Remember for faster build time you can either disable compression or you can use GZip compression instead brotli. 
Ref:
SE Question

6. You cannot send an array data type SendMessage function when interacting with Unity player in the browser.
SE Question

7. You cannot get return value from sendMessage function.
SE Question

8. Don't use WWW.LoadFromCacheOrDownload for loading asset bundles. It is a memory consumer.
SE Question

9. Firefox keeps increments the memory when you refresh your Webgl page in the browser.
The same problem can happen in chrome if you view WebGL page with chrome dev Tools open.
SE Question



10. Unity Webgl Don't support on mobile browsers. You may run it but without any guarantee.
SE Question

11. Sometime your Webgl will not load in the browser. Open the console and you will get "[UnityCache] indexedDB database could not be opened Error". Solve by extending the time.
Unity Forum
Update: Unity Claim that he has resolved this error in Unity 2019.2.0

12. GPU instancing can be killing.
Unity Forum
GameDev Question

13. If your webgl taking to much CPU usage, then you can control it through by setting Application.targetFrameRate to a desireable number. Or you can also use Run in Background check to stop the application if it loses browser focus.
Unity Docs

14. Be default your webgl canvas will consume all keyboard input in the browser. You can use this (WebGLInput.captureAllKeyboardInput) to switch keyboard input control with other page elements and unity WebGL canvas.
Unity Docs

15. You may lose your Scripting define symbols when converting to the unity WebGL platform. (Make sure a backup of your scripting define symbols)

No comments:

Post a Comment