Compile libadwaita application developed in Rust to WebAssembly

Is it possible, or will it be possible, to compile libadwaita applications developed in Rust to WebAssembly to be able to run the applications in a browser?

I don’t know the answer to your question, but just to add that you can display native libadwaita apps in your web browser with the Broadway backend: Gtk – 4.0: The Broadway windowing system

To be painfully blunt: No and no

The best you’ll get is Broadway, but unless you decide to ship a whole Linux VM you can’t run your app client side

It certainly seems conceivable that GTK4 could be ported to use Emscripten and WebGL, but AFAIK there has been no effort to do that. But then there is the complication that Emscripten seems to not be very well supported in Rust anymore.

You’ll need a display server in any case, so compiling GTK into wasm or JavaScript using emscripten won’t solve anything.

Thanks for the replies.

I had a look at egui:

“egui aims to be the easiest-to-use Rust GUI library, and the simplest way to make a web app in Rust.”

It runs in the browser when compiled to WebAssembly, demo.

I’m not sure how it handles Emscripten.

Sorry I can only use 2 links in each post.

I guess it is using its own display server eframe which comes with its own limitations.

The obvious solution would be to use egui, but it is just that applications using libadwaita is very compelling with all the recent development, giving many possibilities with having applications running both on desktop and mobile and the great looks, just look at Amberol :wink:.

Once again, thanks for your replies. Would have been a nice if it was possible, but not a game changer.

Yes, it would need a port with a new GDK backend using the DOM APIs through Emscripten, similar to what Qt has done: wasm\platforms\plugins\src - qt/qtbase.git - Qt Base (Core, Gui, Widgets, Network, ...)

You do not need to use Emscripten from Rust if using a pure Rust library, it is only needed for linking against C and C++ libraries that are built with Emscripten.

Other choices for targeting WASM from Rust are iced, or DOM-based libraries like Yew or Dioxus.

1 Like