Tauri vs. Electron – Real world application
levminer.com
levminer.com
This is not true, `nodeIntegration` has been disabled by default years ago in Electron 5.0 [1]. The default in Electron 20 will be a sandboxed renderer process that can't even read files from disk [2]. Security in Electron is great if you follow their security guidelines [3].
[1] https://www.electronjs.org/docs/latest/breaking-changes#plan...
[2] https://www.electronjs.org/docs/latest/breaking-changes#plan...
[3] https://www.electronjs.org/docs/latest/tutorial/security
As much as I love Tauri (and Wails), WebView requires to make sure the application renders exactly the same across all platforms. Sure, Electron comes with its downsides like the article rightfully points out. But having a UI that renders and behaves exactly the same on all platforms (thanks to the version locked Chromium bundled in the app) is really nice to have.
I wish there would be the possibility to bundle a renderer (maybe a more lightweight one?) with Tauri or Wails instead of using WebView.
It also widens attack vectors considerably when your entire userbase is all on the same probably-outdated build of electron-bundled chromium.
Mac users are probably a little more tolerant of this than non-Mac users, because of the general upgrade treadmill, but whether you can get away with it is a question only you can answer for your app.
If you also provide a web app, then the work needs to be done anyway.
Browser engines these days aren't so bad, especially if all you need from them is basic CSS for the UI. You still have a fully-fledged native language underneath it, so you're not limited to what Web APIs can do.
You might not have a choice. Sometimes even seemingly trivial APIs/features like SVG, flexbox, or audio/video behave slightly differently in different browsers, and it's easy to sink a lot of time into debugging these differences. I'm not saying the effort isn't ever worth it, and it's certainly better now than it ever was in the past, but I think you're underestimating the amount of work it takes to properly support a complex web app across all modern browsers.
With that said, if you're just using web technologies to throw together a UI to slap on your native app that does all the heavy lifting, then sure, maybe using something like Tauri is worth it. Even then, it might not be worth the QA burden of having to test all UI changes against every supported platform, and then the support burden of getting platform-specific bug reports.
Anyway, I’m curious about the svg and flexbox issues you mentioned. I have not experienced any differences with those across systems and browsers.
You're right, I keep forgetting that Microsoft has switched to Blink. It's still a pain if you're a Windows dev who needs to test on WebKit. Or is there an easy way to test that these days?
> I’m curious about the svg and flexbox issues you mentioned. I have not experienced any differences with those across systems and browsers.
To be fair, the differences I was thinking of were mostly between Gecko and Blink, so they're not really relevant to Blink vs WebKit. It's been many years since I've worked directly with SVGs, but I remember there being major differences between how different browser engines interpreted masks and some other features of SVG. I also think they scaled SVGs differently. The flexbox issue I'm thinking of had to do with how Gecko and Blink handled `height: 100%` inside a flexbox container that does not have a set height. I don't remember the exact difference, but I think Chrome assigned a height of 0 to the element, whereas Firefox greedily took up all of the available space, or something like that. Like I said, it's been a few years, so take all of that with a grain of salt. I just remember spending far too much time debugging those sorts of issues. :)
Unless I'm building an app that also needs to work on the web, I'm choosing Electron.
No matter the values and benefits, testing on another browser is to much of a hassle for most web devs.
I think having an alternative to the Google-centric monoculture that is Chromium is actually one of Tauri's big points.
I don't think that tools like htop or Process Explorer give us an easy at-a-glance answer to how much RAM multi-process browsers or Electron apps need. My current approach is to monitor the currently free RAM while at the same time closing the entire application. That delta at that moment is a more accurate representation of the app's memory consumption than summing up RSS values or working sets.
I still feel Electron is the best approach now.
While writing in Node is great if you don't know Rust, your users are being shipped an entire Node runtime, which has size, memory, and security issues. So in this case Electron has a "better" DX completely at the cost of the user.
Tauri has JS/TS APIs, but if you need to do extensive backend work then it requires some learning at the benefit of your users. After learning Rust myself, I'd say it's the benefit of the developers too, but that's just my opinion. :)
Though I do think it’s unrealistic that the legions of JavaScript devs are going to learn rust to make simple desktop apps because it doesn’t really have a reputation of being an easy language to learn.
No, it won't be. You gotta weigh years if not decades of Node/JS experience vs 0 years of Rust experience of the average dev. Development time will be far shorter too.
A big enough application will dwarf Chromium's memory usage with its own, but for smaller apps, the cost of running your own Chromium instance will dominate your app's memory overhead.
a) Compiled JS apps generally have to include a whole Javascript engine, which makes them significantly larger b) Rust is designed for shipping small static binaries, whereas Node is not; node.exe by itself is tens of megabytes, and you can only make it smaller by compiling it yourself from source. Deno has compiling static binaries as an explicit feature so it may fare better in the long run, but it's still limited by a)
As an example: I just tested on MacOS and a hello world program compiled with `rustc` is 378KB, whereas one built with `deno compile` is 74MB.
One additional thing from my experience, is if using Rust as a backend, the turnaround time for hot loading Rust changes is not trivial. This leads to longer times in building things vis-a-vis building in Electron with .ts/.js backend.
EDIT: found this: https://www.reddit.com/r/rust/comments/rhcnzt/mold_a_modern_...
$ cat ~/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]It's fair to believe this, given there's so much material out on the web affirming the fact. I've written about this at length in other places; applications with Electron pre version 5 [0] (released April 2019) were not secure. It's entirely possible and easy to build a secure Electron app today. I started building a secure app Electron template in 2020 [1] (that I still maintain) to address this security issue. I've also written about a history of the framework [2] and steps to build your own Electron app with today's best practices [3].
[0] - https://github.com/electron/electron/releases/tag/v5.0.0 [1] - https://github.com/reZach/secure-electron-template [2] - https://www.debugandrelease.com/the-ultimate-electron-guide/ [3] - https://www.debugandrelease.com/creating-a-simple-electron-a...
contextBridge.exposeInMainWorld('myAPI', {
send: ipcRenderer.send
})If you're loading first-party content into the view, then it's no less secure than running, e.g. a Node.js script (or Python, Ruby, C++ program, Rust program, etc.) as the current user. A program you downloaded being able to do things it's supposed to do is generally a feature, not a bug.
If you are loading third-party content, then sure, it's a completely different ball game.
It just means that nobody has written automated tooling to do this. The procedure is super easy and the implication that there is any security benefit to the way Tauri bundling works is fundamentally flawed.
Their exciting part is
> You can extend Neutralinojs with any programming language (via extensions IPC) and use Neutralinojs as a part of any source file (via child processes IPC).
still:
> Neutralinojs doesn't bundle Chromium and uses the existing web browser library in the operating system (Eg: gtk-webkit2 on Linux). Neutralinojs implements a WebSocket connection for native operations and embeds a static web server to serve the web content.
Comparison with Electron, Tauri and more: https://github.com/Elanis/web-to-desktop-framework-compariso...
I do not understand the second part of this sentence. What does it mean to use Neutralinojs as a part of any source file (via child processes IPC)?
So does this mean all these comparisons are between a web bundle that runs on an existing VM, and a web bundledthat came packaged with a VM? Because I thought the whole point of Electron was that all the dependencies came packaged together, even if that adds 100 megs to the install.
The good news is the built in webviews have come a long way since webcompat is much better across browsers, but it's still extra things to worry about and can produce problems on old MacOS or Windows pre-11.
See also:
This ends up often being my main contention with Rust, when making useful programs it often leads to large compile times mostly due to the linker. The mold linker can help greatly, but it's still not a great developer experience. Something I want to create in the future is a fully compiled Tauri application except it takes the webview sources at runtime, allowing a fast-as-possible development reload as long as you are only touching the frontend application and not the Rust side. On the Rust side there are a few options, one of them being developing something like WASM plugins on the backend where their individual dependencies are much less than a full application.
Only downside that the article rightly points out us the knowledge of Rust, which was new to me.
Also Tauri has Android & iOS targets on its roadmap too.
Tauri has "Other Bindings" on the roadmap, but, for now, this requirement is big limitation. imo, the article should have lead with that instead of burying it at #4.
That said, after playing around with Tauri a bit I have to say it makes it magnitudes easier to embed rust. So if your target is rust, it's a much nicer option.
Honestly, in certain crowds the opposite is true. Having to install updates for software that is for all purposes feature complete is incredibly annoying, if you don't need an actual bug fix for something that impacts your workflow.
Sure, there can be security concerns, like in software that's used to sign documents and whatnot, but for most local software for things like content creation, updates are a nuisance a lot of the time.
Consider something like LibreOffice - if things work for me, I don't want some update that could cause a flawed re-install to happen behind the scenes and lose some of my preferences, file history, or mess with anything else in my workflow along the way. I am okay with manually installing the latest version once per year or something.
For example, something like GitLab doesn't have automatic updates (in self-hosted versions) and seems to get by just fine with sufficiently scary update notices for serious CVEs, for example: https://about.gitlab.com/releases/2022/08/22/critical-securi...
Of course, those who just don't care won't even bother with those updates and the consequences are obvious. Automatic updates would prevent that, but then again, the backlash in the Ubuntu community for having snap packages on servers (and to a lesser degree on desktop) would suggest that that's just not enough to get people to buy into it.
One could also claim that server software and desktop software are entirely different beasts, but personally I'd prefer to update software on my desktop PC through apt or another standard mechanism (when I want, from sources I trust), as opposed to every piece of software deciding on their own bespoke update mechanism.
Personally, I don't really have a good answer. Both approaches are somewhat flawed, just in different ways to different folks in different circumstances.
> Personally, I don't really have a good answer. Both approaches are somewhat flawed, just in different ways to different folks in different circumstances.
You hit the nail on the head. It depends on the target market for your application. If your users do not expect to manually update, it’s probably a good idea to build an auto update mechanism that is opt-out or opt-in. It might not be worth it for other target markets though.
However, my point was that just because an application isn’t doing something critical, doesn’t make security vulnerabilities in that application harmless.
Each Electron app will load its own browser back-end in RAM, while all tauri apps will share the same runtime on disk and in RAM.
This makes for quite a big difference as the number of running apps grows.
I quite like the fundamental ideas behind Flutter (a lightweight GUI runtime that can produce consistent results across many platforms) so hoping these are already or on their way to being ironed out
I immediately felt really productive in Tauri/Svelte/rust. It just kind of clicked with me (completely new to Svelte, but been doing SPAs and JS desktop apps for some time as well as being in the rust scene for years). It was like the ease of electron, but with a better build framework for bundling rust. Really a good setup, easy to get into, easy and fast to build in.
I think Flutter is a really great UI framework. The way it's set up really makes sense and makes it fairly easy to structure the UI. That said, I really do not like Dart at all. I found it difficult to learn a new language and a new UI framework at the same time, and found myself pining for HTML/javascript again. flutter_rust_bridge obviously alleviated this a bit because it made it possible to move most of the logic into rust. I am honestly also worried about Flutter being a Google project. They tend to abandon projects quite a bit. I do like the promises of Flutter and didn't actually have any material issues with it. I think I might give it another go on the next app I build and see if I can get over the Dart hump.
I don't agree with this at all. Shipping an OS with no auto-update mechanism for apps is a no-go. Applications don't need to re-implement such basic functionality.
Imagine if every single desktop application had to re-implement this. The burden on developers would be huge, applications would be enormous, and the system would be a mess to manage or use.
Test CPU RAM GPU
Idle 1% ~ 80MB 0%
For the comparison, Sciter: Idle 0.01% ~ 40MB 0%
With startup time (minimal hello world) 200msAs of memory consumption: the bulk amount is in graphics backend - Direct2D in case of Sciter. I believe the same cap applies to Tauri and Electron.
Compared to Electron, this probably is actually an improvement, but I was kind of expecting Tauri to be a thin layer, ideally with an easy-to-add copyright notice (instead of "it is your responsibility to verify that you are complying with all upstream licenses" [1]).
However, if you have an app that has a lot of interactivity, using the web_sys API is a huge pain that basically caused me to end development on my side project. Working with DOM APIs in Javascript is so much easier than working with them in Rust.
I think the rust frontend ecosystem has a long way to go before it can really compete with javascript and the many existing frontend frameworks.
TL;DR: trying to use the native web view on Windows is horrible because there is no native web view and MS can't bundle software for their own platform.
Of course I suppose shipping any software for Windows is horrible...
Being sarcastic of course, but... hey maybe I'll take another look.
Microsoft's WebView2 has three distribution options: the "evergreen bootstrapper," the "evengreen standalone installer," and "fixed version" (where you embed a browser version in your installer).
https://developer.microsoft.com/en-us/microsoft-edge/webview...
Tauri supports all three of those mechanisms. If you choose to embed the browser directly in your installer, it adds 100MB+ to your installer size, but it's guaranteed to work anywhere. (They even support Windows 7.)
https://tauri.app/v1/guides/building/windows#webview2-instal...
MS keeps the evergreen bootstrapper URL stable specifically so you can download it programmatically, it’s not fragile. And if you choose to ship the evergreen bootstrapper yourself, you don’t have to update it.
The WebView2 runtime ships with Windows 11, major applications like Office, and they’re currently rolling it out to most Windows 10 installs.
We used to use a native webview in an app and found that our app (packaged as MSI) would not install in a lot of enterprise environments because they don't allow secondary installers not signed by the same key as the primary installer. That means no bundling or side loading Edge. They would also require special security policy review to install Edge, making the whole thing really painful.
If you are only targeting personal end users a lot of what I said may not apply but it absolutely does apply in enterprise.
P.S. We did finally drop Windows 7 support a while back but we still get asked for it regularly. We get asked for Windows XP every now and then. Enterprise.
Probably meant “stack”, right?
Used of “exited” (to exit) when you mean “excited” (to be excited).