WEB build with ECS?

Hi,

Every time I attempted to make a web game using ECS, I landed on crashes at runtime.

What’s missing for us to be able to build a game for WEB using unity ECS, Jobs and Burst ?
Is the issue the rendering ? will WebGPU help ?
Is it burst ?
Is it due to multithreading not being natively supported on all web browsers ?
Are there any ETA on when those missing piece would become available ?

Is there a work around like (disabeling burst and/or jobs, use the non hybrid renderer) to at least be able to make a functional demo even if it’s not full perf ?

Support for Jobs (C# multithreading) and Burst.

Entities has had some on/off issues with web builds, probably because it isn’t nearly as well exercised as for other platforms. In principle it’s supposed to work, albeit with little to no benefit due to it running only singlethreaded, non-bursted code.

No. Work is ongoing. In large parts it really depends on browser / webassembly supporting all required technical features from what I understand, so parts of it is not in Unity’s hands.

You can scrape some more info here and there in some long-running threads but … that’s the gist of it.

Sure. For one, use the latest Unity 6, this should build fine again with subscenes (there was a serialization issue and I believe it got fixed in 20f1).

If you make a simple test with a subscene and a boilerplate system, not using any Jobs or Burst features or any assets initially (other than built-in primitives), you should be able to build and run it. If even the minimal test doesn’t build and run, try a non-DOTS project first to see if you have any general build issues.

Then you can start adding to it but you will need to frequently build and test on the web (this is generally true for web dev as it is such a finicky platform of platforms on platforms).

Make sure you test on Chrome and Firefox at a minimum. And consider the general platform limitations. Devs sometimes have issues because they use the regular “quality” URP renderer, not the one for mobile with tuned down quality.

Personally I wouldn’t recommend Web-DOTS at this point unless you like to work with what I would call an experimental feature.

1 Like

ECS isnt supported in web - it was at one point due to project tiny but they shelved it, and ECS doesnt work any more

1 Like

Is that the official state of things now? I recall the latest issues had been fixed, and it used to work just a few months back.

1 Like

There are a number of components to ECS that all have issues with the web.

  • Burst/Jobs: no multithreading on web, so performance will be significantly less than other platforms.
  • Subscene Loading: they tend to have trouble with the web because the web has its own file system management (there are no local files), and changes are often made without testing on the web. I’ll make sure this gets looked into if it’s currently broken.
  • Graphics: the entity renderer makes use of compute shaders, so this will only potentially work with WebGPU (though work on it for WebGPU has not been started).

It is definitely a goal to get ECS working with web, at least in some form, even if limited to WebGPU and the performance isn’t as good as other platforms. But we are not there yet. For graphics, WebGPU is in active development, entity graphics will be looked at with that. There continues to be research into C# multithreading, which will be a huge win for the web but has some very difficult challenges.

4 Likes

Any chance Unity can poke Google or other authorities to push multithreading on web? Feels like this is currently the bottleneck in implementing more advanced features.

WASM does support multithreading, and Unity can do native C/C++ multithreading with it. The issue is with C# garbage collection with multithreading, which doesn’t work because of WASM security policies. It is an active area of research involving Google, and I will be the first to throw a party when it gets figured out.

4 Likes

I’ll be second! But don’t want to ruin your party, so I’ll just join yours hehe. :laughing:

Previously Project Tiny was solving these problems. Any plan to bring it back soon?

Project Tiny is no longer in development and there are no plans on bringing it back. For the record, Project Tiny did not solve the C# multithreading problem. It did allow for very small builds by only supporting a limited set of features, but C# multithreading was not part of it. There are some other efforts going on to help with the build size issue, including the WASM stripping tool that’s being developed and should ship soon. And C# and/or Burst multithreading will come at some point, it is a very important performance tool.

1 Like

I am also following this topic very closely! Looking forward to seeing Google/other parties move forward on this very complex topic