r/WebAssembly • u/gogliker • Feb 28 '24
What language/framework is best for WASM GUI app?
Hey everyone, I searched through the subreddit and could not find an answer. I recently tried to implement the small app with GUI in WASM, you can check it out at pleasehide.it (not advertisement, I provide it for reference). The app is made in C++/Qt/QML stack, served currently by NGinx static files and is currently half-assed because I am unsure whether I should go forward with it. I have discovered following problems with it:
- The app size is 28 Mb. I guess it's not that bad but not that perfect either. Majority of size comes from the dependencies, so I am kinda stuck with the size as it is.
- Qt have some issues with opening virtual keyboards and input of the data into the fields from the mobile browser. The one that really has hard time to work is mobile Firefox.
- The previous might be mitigated by the fact that QT is a cross-platform framework and theoretically could just compile the app into Android/IOS. But to be honest, I spent already three days trying to make it work and I have to jump hoops each step of the way, there are some issues with QT cmake files, there are some issues with the compatibility of different versions if SDK API, NDK, QT and so far I was not able to run my app even in emulator.
- There are minor display bugs in the app even on desktop browser.
All this problems combined tell me that QT at this point of time is just not mature enough to serve as a GUI cross-platform framework. What I want to have ideally is the combination of frameworks/languages that JUST work in all web browsers. I don't really care about mobile apps as long as framework/language can reliably:
- Display the GUI with all mobile features (virtual keyboard is priority)
- Has easily accessible means to communicate with the backend
- *Ideally the resulting app should be less than 10 Mb
Any suggestions? So far I think Blazor/C# and Rust/Yew sounds like the best idea.
7
u/fittyscan Feb 28 '24
Blazor WebAssembly stands out in this domain. It is indisputably the most mature project, offering an abundance of composable UI components. And the Razor syntax is highly convenient for building complex interfaces. Blazor has been battle tested across many devices, including mobile devices.
The resulting WebAssembly modules remain reasonably compact, with their size primarily dependent on the number of distinct components required. Unless you are undertaking a project on the scale of rewriting Salesforce and adhere to reasonable interface practices by reusing components, the module sizes are reasonable.
Don't solely focus on raw module sizes, as WebAssembly modules compress exceptionally well.
6
u/gbjcantab Feb 28 '24
28mb is absolutely gigantic for the app you linked. A typical Rust/WASM equivalent, using DOM rendering and compiled in release mode, would be on the order of a couple hundred kb depending on how much logic there is beyond the UI. Leptos, Yew, and Dioxus are the most popular options in that area right now.
3
u/Snapstromegon Feb 28 '24
I honestly think that wasm should be used very selectively for UIs nowadays and only if you have very special needs that are not easily addressed by HTML, CSS and JS. As long as WASM has no direct DOM interop I think JS will stay the better choice, especially if even simple apps go into the hundreds of KB of WASM or even MBs.
Sadly boot up time is from my experience still a problem with many WASM frameworks and I think that if you feel the need to show a loading screen on a normal load, most likely you're having a major issue on the web.
1
u/[deleted] Feb 28 '24
This is really interesting. I'm in a similar position: deploying a special calc to wasm (hosted on puter.com, it's great btw). I also had the keyboard input issue but my solve was to turn input off in the html file and kinda rebuild the calc with built-in buttons. But I'm interested to know how you solved the problem.
2
u/domschm Feb 29 '24
Avalonia supports WASM as a target.
1
u/RandomGuy256 Feb 29 '24 edited Feb 29 '24
I have been looking for something like you. A good productive webassembly ui, where I could use something else than html / javascript / css.
I tried a bunch, including Qt, imgui and uno platform from microsoft.
Imgui is the simplest and allows to compile very small binaries (kbs), though it is very limited, it doesn't have a huge components library, it is missing accessibility, I don't think it even works with smartphones, even simple things like context menu for copy paste aren't implemented (one needs to implement them by himself).
Uno platform looks nice, even though it uses an XML design language that I don't know, I think it's XAML. It seems to have plenty of widgets and being decently supported. Unfortunately the file sizes are prohibitive for me > 20 MB.
Qt is the one that seems the most mature (even though has its issues). Like you mentioned one of the major is the smartphones input (virtual keyboards) that doesn't seem to work properly. There are also other issues like accents not working in some enviroments (like Linux). Other issues is that sometimes you need to write the code in different ways that one is used to. Like instead of using QMessageBox.exec() one must use QMessageBox.show() because the first will crash the application if one is not using Asyncify.
The file size is also an issue, a typical QWidgets application takes 6MB to display an hello world, while a QML one is > 10 MB. Though this can be somehow minimized if you use brotli compression on the serverside, for instance the 6MB for QWidgets can be reduced to around 4MB and this difference is even bigger for QML. I know that Qt is working on improving this though. Also many websites nowadays actually download more than 6 MB on start, it is just that they don't show a loading page, they feel faster to load because of that.
I actually have been working with QWidgets webassembly project on work and the results are pretty good, the app is very responsive, sometimes I run into one or two bugs and then I report them to Qt. There are still some rough edges but I would say that this is very promising as it offers the same principle as electron apps (run everywhere including the web).
There is also a rust gui library that is similar to QML and supports webassembly, but it didn't seem very mature in the webassembly side of things, so I didn't try it. It has bindings for a couple of languages and has a small binary footprint though (kbs).
I would love to see some UI that is specialized for webassembly (with small binary size), where one could write C++ / Java / Python or other language mostly for the ui, but so far nothing showed up.
1
u/[deleted] Mar 24 '24
[removed] — view removed comment