Factorio in web assembly

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Blay
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Nov 14, 2022 12:39 pm
Contact:

Factorio in web assembly

Post by Blay »

TL;DR
Compile factorio to web assembly and host it on factorio.com.
What ?
I suggest, that the devs should compile factorio to web assembly and host it on factorio.com for users, that bought the game (web assembly allows you to run an native app in a normal internet browser). That process should be straightforward
(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 :D ! (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)
Why ?
Because being able to play factorio everywhere without installing anything would be cool! :mrgreen: :mrgreen:

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Factorio in web assembly

Post by posila »

Blay wrote:
Mon Nov 14, 2022 9:06 pm
Because being able to play factorio everywhere without installing anything would be cool! :mrgreen: :mrgreen:
You can already do that by downloadin ZIP package instead of installer.

Blay
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Nov 14, 2022 12:39 pm
Contact:

Re: Factorio in web assembly

Post by Blay »

posila wrote:
Mon Nov 14, 2022 11:20 pm
Blay wrote:
Mon Nov 14, 2022 9:06 pm
Because being able to play factorio everywhere without installing anything would be cool! :mrgreen: :mrgreen:
You can already do that by downloadin ZIP package instead of installer.
Either ways, you have to wait.

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Factorio in web assembly

Post by posila »

Blay wrote:
Tue Nov 15, 2022 2:28 pm
Either ways, you have to wait.
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 :D

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.

Blay
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Nov 14, 2022 12:39 pm
Contact:

Re: Factorio in web assembly

Post by Blay »

posila wrote:
Tue Nov 15, 2022 2:35 pm
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 :D
I didn't think about that before xd

Blay
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Nov 14, 2022 12:39 pm
Contact:

Re: Factorio in web assembly

Post by Blay »

posila wrote:
Tue Nov 15, 2022 2:35 pm
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.
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? ;) ;)

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Factorio in web assembly

Post by posila »

Blay wrote:
Tue Nov 15, 2022 8:21 pm
... doing such boring ...
I don't want to do boring stuff :D 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)

User avatar
atomizer
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Sep 22, 2018 3:18 pm
Contact:

Re: Factorio in web assembly

Post by atomizer »

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.

duskwuff
Burner Inserter
Burner Inserter
Posts: 17
Joined: Wed Aug 15, 2018 1:36 am
Contact:

Re: Factorio in web assembly

Post by duskwuff »

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)
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).

WASM64 is also under development, but I don't know what the current status of support and tooling for that looks like.

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Factorio in web assembly

Post by posila »

duskwuff wrote:
Sat Nov 19, 2022 6:44 pm
a WASM Factorio would still be less resource-constrained than the Switch port (for example)
True

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Factorio in web assembly

Post by FuryoftheStars »

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* :D )
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

Post Reply

Return to “Ideas and Suggestions”