Hacker News new | ask | show | jobs
by SigmundA 1820 days ago
Wonder why WebView2 would be any better than Electron? They are both Chromium based and if kept ups to date should be almost identical, would it just be saving disk space and sharing some memory since it would be using a single install of the browser engine?
5 comments

I'm using WebView2 on a project at the moment, inside a WPF (dotnet core) app.

One thing I've been having some fun with is the ability to host a REST dotnet core API inside the same application and then calling Javascript functions/updating the UI on an HTTP request.

It's very handy if you have multiple applications on the same machine (or the same application on multiple machines on a LAN) and you want them to talk to each other.

Also, I couldn't find a way to build a normal Windows installer with Electron (if there is please let me know), but was able to use Wix to build one for my WPF/WebView2 app.

Intrigued by this approach!

Is the source shareable?

We have an enterprise app that was originally built as a UWP application via Xamarin.Forms (Hot mess, I know. But the decision predates me).

We've been prototyping a rebuild in React and Electron but if we could port into WebView2 and reuse a lot of our existing business logic with a port into a local api layer a lot of time could be saved.

I'm a web guy, so not sure how the nuts&bolts of this would work. Does the WPF app bootstrap a REST API on localhost on startup that is callable?

I'll fire a POC onto Github and edit this comment with the link...

Edit: Here you go - https://github.com/jmkni/HnPocWebview2

> I couldn't find a way to build a normal Windows installer with Electron (if there is please let me know)

https://www.electronforge.io/config/makers

- WiX MSI

- Squirrel.Windows

Are your options here. I had more luck with Squirrel than WiX.

With auto-update support.

Oh nice, will keep this in mind, thanks
> Wonder why WebView2 would be any better than Electron?

Because its under their own control. Using a platform you control is great if you actually have the resources to maintain it.

Don't they own GitHub which employs most of Electron's contributors?
The community around Electron still has specific expectations. With an actual framework of their own they can safely make maintaining compatibility with the APIs their products use a top priority and also introduce questionable and Windows-specific things which probably aren't welcome in Electron.
They could always fork electron, it would have been first thing to do, unless they are expecting to do lot of radical changes which is quite hard to do on electron perhaps
On a single PC it probably wouldn’t matter that much, but if distributed at scale, the savings in bandwidth could be enormous. Electron is quite large after all.

Teams shipped with incredibly outdated versions of Electron for a very long time.

Keeping up the latest electron is f@$king impossible.

It takes months/years to get all clients updated. By then you are already running on an outdated version.

Is integrating auto-update functionality not standard part of distributed application tooling by now ?
Sure, if the user has proper permissions.

But when you are a small app running on a corporate citrix, APP-V, or whatever locked-down environment you are out of luck.

You will be able to update the app running inside electron without much of an issue. But you won't be able to download and execute a new exe.

Enterprise deployment setups have a lot of their own flavour. However the ownership is on dedicated IT dept to keep the apps updated on your system and rest of the fleet.

Microsoft has the network to train, enable and get IT to administer these kind changes. They are after all able to get windows patches in fairly regularly at higher frequency than ever before in windows 10.

Sure there were will be some small minority like still active XP users , you sell extended support or whatever to either enable them or you can stop support.

I played with WebView2; while possible to save some disk space, the memory is (surprisingly) worse than Electron, and the API surface is also not as rich.

I like the idea of using a (system-deployed) WebView in general, but this implementation needs more work.

Shouldn’t it also help significantly with memory usage, if the user is also browsing the web or using other WebView2 apps?