Show HN: Firefox in WebAssembly

developer.puter.com

240 points by coolelectronics a day ago


This is the entire Firefox browser rendering to a <canvas> element. Gecko, all UI components, and the Spidermonkey JS engine are all compiled and running in WebAssembly.

Here are a few things you might find interesting:

- This is fully end to end encrypted! We use the WISP protocol for TCP-over-websockets.

- There is a novel WASM->JS JIT for experimental site speedup

- This port cost over 25k in opus/fable tokens for debugging and JIT research

This was just a fun experiment to push the boundaries of WebAssembly. For a more usable "browser in browser" experience, we also built https://github.com/HeyPuter/browser.js that eats a bit less RAM.

yjftsjthsd-h - a day ago

>This port cost over 25k in opus/fable tokens for debugging and JIT research

> This was just a fun experiment to push the boundaries of WebAssembly

I'm a huge fan of the project, but I have to ask. If spending $25k is a "fun experiment", where exactly is your threshold for serious work?

tech234a - 21 hours ago

Loosely related to porting the Firefox engine in unusual places: here is a project that ports Firefox's Gecko rendering engine to iOS as a sideloadable app (normally Apple only allows its own WebKit rendering engine in iOS apps): https://github.com/minh-ton/reynard-browser

coolelectronics - a day ago

Oh and for anyone asking, you can run firefox-wasm inside firefox-wasm inside firefox! I only got this to load once though since it gets pretty unstable at that level.

ksmithbaylor - a day ago

I can’t help but think of Gary Bernhardt’s 2014 talk, “The Birth and Death of JavaScript”: https://www.destroyallsoftware.com/talks/the-birth-and-death...

degamad - a day ago

I'm so glad this exists, I've been considering doing something like this for a few months.

I recently got a TV based on VIDAA os, a locked-down linux-based OS where everything is rendered from Web pages. It has a built-in browser that doesn't support ad-blocking (I suspect VIDAA is profiting from showing ads on the TV), and you can't install new apps unless they're Web pages.

This would hopefully allow one to run Firefox within the existing browser, then install uBlock Origin within Firefox... I know what this weekend's project is going to be...

pjsg - 2 hours ago

This is amazing -- but there is something wrong with (maybe) the WebGL or color rendering. If you go to https://pskreporter.info/pskmap then the ocean should be blue (and it is blue in a native firefox). However it is a shocking shade of pink in the wasmified version.

Still, it is amazing that it works at all!

azakai - a day ago

Prior art: WebKit.js, the WebKit rendering engine ported to JS

https://github.com/trevorlinton/webkit.js/

thx67 - 3 hours ago

Firefox ESR in Debian12, won't start. 140.12.0esr (64-bit)

This is the entirety of the log message.

    [chrome-demo] chrome assets + engine wasm ready
    [gecko] warning: unsupported syscall: __syscall_madvise
    [gecko] embed-xul: main() on the app pthread (PROXY_TO_PTHREAD)
    [gecko] embed-xul: GECKO_GL_PASSTHROUGH=0
    [gecko] embed-xul: GECKO_COARSE_CLOCK=1
    [gecko] [libxul] abort: Assertion failed
    [gecko] Aborted(Assertion failed)
smalltorch - 10 hours ago

I think it should check if my browser is compatible before downloading 50+ mb.

brewmarche - a day ago

Can’t get it running on Firefox 152.0.6 (aarch64), no extensions.

  [chrome-demo] chrome assets ready
  [gecko] warning: unsupported syscall: __syscall_madvise
  [gecko] embed-xul: main() on the app pthread (PROXY_TO_PTHREAD)
  [gecko] embed-xul: GECKO_GL_PASSTHROUGH=1
  [gecko] embed-xul: GECKO_COARSE_CLOCK=1
  [gecko] embed-xul: GECKO_GPU=1 (GPU/WebRender->canvas rendering)
  [gecko] xul_init: GRE dir = /gre
  [gecko] Pthread 0x11051000 sent an error! blob:https://developer.puter.com/edc1bd0a-b844-4a18-a69a-63dd49dc304a:8906: SecurityError: Security error when calling GetDirectory
MajesticHobo2 - a day ago

Browser sandboxing is now fully solved.

devttyeu - 12 hours ago

Oh wow didn't expect this to be either possible or this perform so well.

Also fascinating how small the wasm binary is. I made a Wasm port of FreeCad (also had a fairly popular thread here a few days ago) but that image was close to 300MB uncompressed / 90MB compressed with Brotli.

(btw none of my wasm CAD ports seem to run, each with slightly different flavors of missing wasm features it seems - I have them linked on https://magik.net if you want to debug for whatever reason)

lxe - a day ago

It's kind of ironic how this doesn't work in Firefox.

sangeeth96 - a day ago

edit: I misunderstood, that's $25k not 25k tokens :/ time to log off.

this is so rad! 25k tokens is a lot less than i thought this'd take -- what were the difficult bits in the porting process? also, was firefox preferred because parts of it are already in rust?

zerof1l - a day ago

All the network traffic from that browser is routed through a server. My IP inside that browser was in India and on CloudFlare network. I don’t particularly trust Puter. Why not route traffic through my actual browser?

- a day ago
[deleted]
simonw - a day ago

This is amazing. I loaded up https://developer.puter.com/labs/firefox-wasm/ in Chrome and I've visited a bunch of sites, it works really well.

Then I opened up https://developer.puter.com/labs/firefox-wasm/ in Firefox-in-WebAssembly-in-Chrome

... and sadly it didn't load. I got this in the startup log:

  [log] [chrome-demo] chrome assets ready
  [warn] [gecko] warning: unsupported syscall: __syscall_madvise
EvanAnderson - a day ago

I've been waiting for this to happen.

The websites that don't want you to block ads will serve you an obfuscated "inner browser" that will render their site. All your ad blockers, etc, are rendered moot.

Once accessibility is solved this is absolutely going to be a thing on major websites.

pmarreck - 21 hours ago

Impressive and surprisingly performant, but what's the use-case?

If anything, this is an ad for WASM!

virajk_31 - 13 hours ago

I checked internet speed inside and outside the wasm, and inside wasm its 10x slower, what could be the reason?

eqrion - a day ago

> There is a novel WASM->JS JIT for experimental site speedup

I would love to see the details for this. SpiderMonkey had an attempted wasm32 JIT backend, but it was never finished.

edit: Apparently it also has some sort of WebAssembly interpreter backend too, which SpiderMonkey doesn't have.

throwaway2027 - a day ago

Obligatory https://www.destroyallsoftware.com/talks/the-birth-and-death...

luciana1u - a day ago

25k tokens to port Firefox to WASM. by 2027 we'll be spending 25k tokens to port WASM back to native because someone will benchmark it and find the WASM version is 3% faster.

koolala - a day ago

What makes it require that WASM extension you need the flag for in Firefox? Was there really no way to work around it or polyfill it for it to work? It is performance critical?

ksdme9 - 18 hours ago

fun how this doesn't work on my firefox

poulpy123 - 14 hours ago

Yo, I've heard you like browser so we've put a browser into your browser

elmer2 - a day ago

I would be careful with this demo. When you go to whatismyip.com, it's showing: 104.28.233.73. Someone could use this to cloak their IP address and do some damage.

voidUpdate - 17 hours ago

What are the $25k in tokens for? Does firefox's build system not allow building to wasm?

andai - a day ago

The description mentions a similar project browser.js which apparently has some real use cases, what are they?

rmac - a day ago

on mobile chrome / Android I can't get the following to work :

- IME / keyboard doesn't pop on any field

- copy paste

- scrolling with touch

- ai side panel

What works on mobile :

- Extensions !

This is so sick great work; did you try webgpu?

https://imgur.com/a/nWFCraP

ohonbob - a day ago

Since coolelectronics posted his firefox wasm here ill post my sideproject (we worked on these around the same time), Webkit In WebAssembly (And actually modern and usable! Unlike the older trevorlinton/webkit.js project)

https://github.com/theogbob/WebkitWasm

Not as polished as the firefox port but is a fully working port of webkit ported with fable, opus and some glm 5.2.

bawolff - 18 hours ago

> This is fully end to end encrypted! We use the WISP protocol for TCP-over-websockets.

Umm, that doesn't sound right. By definition, i dont think you can be end2end encrypted in a web browser, since your server controls what code is run by the web browser. Puter would fully be able to spy on you if they were so inclined because they control what wasm you load.

som - a day ago

... doesn't support Firefox mobile apparently :D

mdlxxv - a day ago

"Yo dawg. I herd you like web browsers, so I put a browser in your browser, so you can browse the Web while you browse the Web".

l1ng0 - a day ago

Great, now I can finally make an Electron.js application with code made for Firefox!

SpyCoder77 - a day ago

No mobile support

chews - 21 hours ago

Yo dog, I heard you like browsers, so I put a browser in your browser.

jedisct1 - a day ago

"This browser doesn't support WebAssembly JSPI, which Firefox WASM needs to run."

elombn - 14 hours ago

[dead]

- a day ago
[deleted]