Ghostty compiled to WASM with xterm.js API compatibility

github.com

33 points

kylecarbs

an hour ago


4 comments

mitchellh 9 minutes ago

Holy shit Kyle. I had no idea you were working on this. This is amazing. Your patch is also very instructive on what you need me to do for you to make this more reasonable.

I'm guessing that performance of this relative to xterm right now isn't... the best, mainly because the way you're grabbing the viewport seems expensive. I'm curious though if you did any benchmarks?

One thing you probably really want to expose is the new RenderState API: https://github.com/ghostty-org/ghostty/blob/main/src/termina... You're doing per row line grabbing currently which is probably pretty slow. The RenderState API is stateful and produces the state necessary to create a high-performance, delta update renderer. It's what our production GPU renderers are now built on (but the API itself is compatible with any kind of renderer). It'd be better for you.

After all that, I'm very curious even at this rudimentary level what the performance on various benchmarks look like compared to xterm.js.

Excellent work!

  • kylecarbs 3 minutes ago

    We spent little time on performance so far, this is more of a POC that will hopefully become a drop-in replacement for xterm.js over time.

    I'll swap it over to the new RenderState API and post some benchmarks!

    Many kudos to y'all, we were shocked how simple it was to hack this together.

someguy101010 24 minutes ago

nice one kyle! you could add https://github.com/wasmerio/webassembly.sh and have a fully featured in browser shell with support for installing packages!

  • kylecarbs 21 minutes ago

    I'll do this for a much improved demo!

    Currently you need the command-line to try it, which is an unfortunate UX.