Factorio in web assembly
Moderator: ickputzdirwech
Factorio in web assembly
(It took me 6 hours to compile simple "Hello, world!")
, because factorio is written in c++ and uses sdl2, and there's a tool called emscripten, that you can check out, for compiling c++ into web assembly (there's also a lot of tutorials on how to use sdl with it on the internet). There would be a few complications, like where to store saves and other stuff, but you will come up with something for sure ! (you can fe. store all that stuff on your servers, in the cloud and get rid of steam cloud for the steam version of the game)Re: Factorio in web assembly
I agree. The browser wouldn't magically download 1.5 GB of assets faster than the ZIP file, so you'd have to wait for the browser hosted version too
Anyway, we use SDL but are not completely built on top of SDL. Meaning, we'd have to port at least rendering to WebGL (or something that can run in browser.) We can't port rendering to SDL, because SDL doesn't provide all the graphics features we need.
Re: Factorio in web assembly
Yeah, but still doing such boring and hard stuff like porting opengl to some shit that runs in the browser wouldn't be that hard for such a big team with a lot of time and money. You can still make it just for the seek of it, can't you? I never saw a big pc game being ported to wasm, maybe you will be the first one to do so?
Re: Factorio in web assembly
I don't want to do boring stuff But if anyone on the team is interested in making this work, they can put time towards it if they want to. But I wouldn't expect it to happen anytime soon or possibly ever
Also I was interested in performance of WebAssembly, and it's hard to tell what would be impact on Factorio be compared to native code, but I saw there is a limit of 4 GB of memory, and it is unclear to me, if the limit is for single allocation (like you can't have an array larger than 4 GB, that would be fine), or all allocations combined (that would be big problem, major reason we stopped making 32bit builds)
Re: Factorio in web assembly
Currently 4 GB is a hard limit, however 64 bit addressing is on the way - already available in chrome behind a flag and in firefox nightly: https://webassembly.org/roadmap/
Hi-res textures take up around 800 MB. Streaming sounds/music on-demand saves another ~140 MB off of initial download.
Not saying that it is viable or easy, but at least it seems not impossible.
Hi-res textures take up around 800 MB. Streaming sounds/music on-demand saves another ~140 MB off of initial download.
Not saying that it is viable or easy, but at least it seems not impossible.
Re: Factorio in web assembly
The 4GB limit applies to all allocations made through the WebAssembly VM. But keep in mind that this wouldn't include memory allocated outside the VM, like code and graphics, so a WASM Factorio would still be less resource-constrained than the Switch port (for example).posila wrote: ↑Wed Nov 16, 2022 9:12 am Also I was interested in performance of WebAssembly, and it's hard to tell what would be impact on Factorio be compared to native code, but I saw there is a limit of 4 GB of memory, and it is unclear to me, if the limit is for single allocation (like you can't have an array larger than 4 GB, that would be fine), or all allocations combined (that would be big problem, major reason we stopped making 32bit builds)
WASM64 is also under development, but I don't know what the current status of support and tooling for that looks like.
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Factorio in web assembly
I won't lie, Factorio in a web browser sounds cool and all, but I'm not sure I see the point. One can download the zip version and put it to a thumbdrive, then change the needed config files to save all the needed appdata to the thumbdrive as well, and now you have a portable version that can go between multiple computers without having to redownload between each one and keeps its save games and mods with. Unless, of course, you're trying to use this on a computer that has had the USB ports or other needed things for zip Factorio to run locked out... (*cough*work pc*cough* )
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics