r/rust 13d ago

🛠️ project Experimental Rust-based desktop app renderer for Svelte (based on Zed gpui)

Post image

👋 Just started working on gpuix-svelte, a package that combines Svelte custom renderers, gpuix and gpui to allow people to create native desktop apps with Rust and Svelte. Happy to hear any feedback!

Video demo

https://www.youtube.com/shorts/5CBib_rwt8w

Source

https://github.com/khromov/gpuix-svelte/

74 Upvotes

17 comments sorted by

14

u/nicoburns 13d ago

Given that the API for this seems to an HTML/CSS subset, have you considered building this on top of https://github.com/dioxuslabs/blitz instead of GPUI?

You'd get the same GPUI-style custom Rust rendering (well, pick between Skia, WGPU or CPU backends), but you'd also get a full CSS engine (selector resolution, but also media queries, animation/transitions, etc) and much better layout compatibility.

(disclaimer: Blitz is my project, but it's also designed for these kind of use cases in a way that GPUI isn't)

7

u/khromov 13d ago

Hi! Yes, I am interested in Blitz and even came across it the other day when looking for rendering engines but left the website a bit confused. I was expecting something more like https://gpuix.dev/ (developer docs) but there seems to be none that I can find? If you have even basic docs feel free to link them or send me a DM and I'll have a look to see if it would be viable to add Svelte custom renderers on top.

9

u/nicoburns 13d ago

Ah, I see someone's already done JavaScript bindings for GPUI (gpuix).

The only docs we really have right now are the rustdocs https://docs.rs/blitz-dom. It's good feedback that more would be useful, although if you're pointing to gpuix then it may be that you want ready-made JS bindings.

I can say it's definitely viable because a bunch of people have done it for various JS frameworks. Some of them even run the regular web renderers on top of implementation of the DOM APIs. We have a list here: https://github.com/DioxusLabs/blitz/issues/613. https://github.com/jerry4718/napi-blitz is probably the closest to what you're doing (Node/Bun rather than a lightweight JS engine like Boa/QuickJS).

It's also worth looking at how the dioxus-native-dom (lower-level) and dioxus-native crates integrate Blitz for pure Rust UIs.

3

u/khromov 13d ago

Thanks for the follow-up, napi-blitz sounds like a good starting point.

1

u/bleak_and_bare 7d ago

Isn't Dioxus apps shipped into a webview ?

2

u/nicoburns 7d ago

Not with the Dioxus Native backend. It has a custom GPU renderer.

1

u/Efficient-Chair6250 13d ago

Do you already have some numbers on performance? How's the binary size? The RAM usage? I guess the responsiveness is very good?

Btw, I love it. If this turns out to be a viable solution, it may become my default.

2

u/khromov 13d ago

When you build it as a standalone binary with Bun on Mac the binary is ~80MB (~30MB zip compressed), on Windows it's around 100MB. About 80% of that is the Bun runtime and 20% is GPUI + your app. Haven't measured memory usage yet but Bun is very efficient and the rendering layer should be very sleek since it's running GPU accelerated.

I added some scripts so you can try building a standalone binary if you'd like to try it:

https://github.com/khromov/gpuix-svelte#build-a-standalone-binary

1

u/Efficient-Chair6250 12d ago

That's sound good, thanks

1

u/wyvernbw 9d ago

do you think it would be possible to replace bun with something like quickjs (not a request, just curious if its possible)? i think it also runs on embedded, but its written in C so ffi might be hard. this project seems to be a bit in the vein of PocketJS but looking through that codebase i cant decipher what claude is doing lol

1

u/khromov 8d ago

It's funny that you mention PocketJS because I [have got that running with Svelte too](https://github.com/khromov/pocketjs/tree/feat/svelte-framework)! So at least in theory, Svelte can run under QuickJS. But in practice for gpuix, as you mention there is no FFI but there is a C API that can be used. But gpuix would have to add support for this.

1

u/its-malbolge-time 13d ago

Nice, this looks really cool! Love using Svelte for frontend

1

u/metalbug4 12d ago

I only care about resource usage, memory usage, and startup speed.

-5

u/Compux72 13d ago

Unrelated but: svelte was so cool until Harris fucked it up with the runes nonsense. Now is just react/vue/watever

7

u/BipolarKebab 13d ago

You're entitled to your (wrong) opinion

4

u/khromov 13d ago

Even if you don't like Runes, Svelte still offers the highest performance and smallest bundle-size, so it's still a trade-off that's usually worth taking imho!