Future of Electron + WebViews #220
nwittwer
started this conversation in
Technology
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Reflex is fundamentally dependent on Electron and its implementation of
WebView, currently. We need to show accurate views of websites across different screen sizes.As you may know, Electron solves the infrastructure layer of building a hybrid (native + web) app and shipping it to Windows, Mac, Linux. This makes development much easier than maintaining native versions. But it comes with its own limitations as well.
Why use WebView instead of iFrame?
When first prototyping Reflex, we started with
<iframe>. But many websites blockiframeembeds on external websites. Trying accessing Google.com from an iframe for example. This is not a problem most the time when using aWebView.There's also other benefits when using
WebViewin Electron:Why use WebView instead of BrowserView?
Figma notoriously brought
BrowserViewto life in Electron. Read about that here. But they didn't need to display and manipulate embedded web content within the DOM; they mostly just needed a way to show one big web app view at a time. If you imagine Google Chrome's tabs, it's similar to that. But Reflex needs to be able to show a bunch of different web pages simultaneously, and the user is able to move them around and scale them up/down from the Reflex UI.While it could be technically possible, it's not clear why we would want to swap
WebViewwithBrowserViewin Reflex.BrowserViewcannot be embedded into the DOM. In order to move the position or scale of them on the screen, themainElectron process and therendererprocess need to communicate just to achieve something similar to whatWebViewgives us out-of-the-box. It is also not clear how much of a performance gain would be possible by switching toBrowserView, and therefore currently looks like a lot of extra development effort for minimal to no gains.WebViewalready runs in a separate process from the app, so it is efficient in that regard."Electron is RAM-heavy and bloated! Use another framework!"
I regularly check-in on the state of alternatives, since this isn't untrue. But as of December 2021, I still think Electron best suits the Reflex project.
WebViewcurrently.How about Microsoft's Edge "WebView 2" project?
Microsoft is building a project they call Edge WebView 2. This is being built mainly to power Microsoft's web-based apps like VSCode. Fundamentally both Edge WebView 2 and Electron's Chromium WebView are expected to perform similarly, as they both are based on the Chromium WebView technology. Electron adds a lot of nice APIs on top of WebView that Edge's WebView 2 implementation does not ship with. You can read about the differences between Electron's implementation and the MS Edge implementation here.
Currently Electron still offers the best combination of tools and APIs for Reflex.
Beta Was this translation helpful? Give feedback.
All reactions