10 ms·
WKWebView, an Electron alternative on macOS/iOS
- gamerextremepop 8y agoJf- u are son of bitche, your father is a rabid dog and you will die with death of a crazy flea laced dog. U think u are soo smart? Post your name and address, then we'll see who the fuck you are.
- jbverschoor 8y agoEmm... nativescript?
- DonHopkins 8y agoNativeScript is cool -- I really like it. But as far as I understand it, there's a bit of a fatal problem going forward on iOS, last time I looked at it a year or so ago (I'd be thrilled if they've come up with a way to address this problem): The iOS NativeScript bridge uses the old deprecated UIWebView and JavaScriptCore's Objective C integration stuff that lets you directly call back and forth between Objective C and JavaScript. However, that Objective C bridging stuff is not supported on WkWebView, since it runs in a separate process, and has a different way of sending messages to the web browser, but not calling native code directly or passing pointers to objects or buffers in memory. Why would you want to do that? To get direct access to an array of binary floating point numbers, or the pixels of a canvas or WebGL texture, instead of converting to and from JSON, or serializing images as data urls with base 64 encoded png files, for example. (Yech!) You can send messages back and forth to WkWebKit, but that's vastly less performant than the direct calling UIWebKit JavaScriptCore bridging stuff, which operates in the same process and memory space. And the NativeScript iOS integration layer is totally dependent (built on top of) on the way the JavaScriptCore bridging stuff works, and would have to be completely rewritten from scratch (and be much less efficient and require a lot more plumbing on both sides), in order to support that kind of out-of-process messaging to WkWebKit. The great thing about NativeScript is that gives you has such an efficient high bandwidth interface to native code from JavaScript. But it just necessarily uses an old crappy JavaScript engine with no JIT. One of the best thing about using WkWebKit is that the Just In Time compiler is enabled, so it's blazingly faster than running JavaScriptCore in the same process (which has it disabled, since non-Apple apps aren't allowed to write to code memory). Of course it depends on how much of your application is written in JavaScript and would benefit from the JIT, and how much it depends on calling and sending data back and forth between native code and JavaScript. But the NativeScript way of doing things makes many assumptions that would make it very slow with RPC messaging instead of direct calling. PhoneGap/Cordova is fine using WkWebKit because it uses a JSON messaging interface in the first place, not the more efficient higher bandwidth Objective C bridging stuff. It's JavaScript/Objective C bridge is much simpler than NativeScript, and people don't use it the same way that NativeScript is designed to be used. NativeScript, as cool and amazing as it is, is deeply tied to old technology on iOS, JavaScriptCore and UIWebKit.
- bunnycorn 8y agoIt would be nice to have an Electron 100% compatible framework (drop-in replacement) that instead of using Chrome, it would use Apple's webviews that are of course based on WebKit. It would be faster and take much less RAM, specially when multiple Apps are open and they could use the shared library. Also, now that Chromium is going to be part of Windows, the same would also be a good idea, I think.
- inglor 8y agoHalf of electron is being able to leverage the Node.js ecosystem and Chrome APIs. Creating a "drop in" replacement would require a ton of work and constant keeping up-to-date.
- acdha 8y ago> leverage the Node.js ecosystem and Chrome APIs Aren't those fairly discrete areas with fairly different levels of work? Doesn't most of what's on NPM run in WebKit / Gecko these days, anyway, since people commonly deploy client-side?
- jf- 8y agoHaving a shared electron runtime on each platform is an answer to some of its performance-related criticisms. Hopefully this is what Microsoft are going for with chromium and the github acquisition. There would still need to be compatible equivalents on Mac and Linux however, or it would render the endeavour pointless.
- saagarjha 8y ago> a shared electron runtime on each platform is an answer to some of its performance-related criticisms Like…Chrome?
- jf- 8y agoGiven that electron is not chrome, no, not chrome. A specially made, backwards compatible chromium/node/whatever bundle, that developers can build against without fear of having their apps broken by future API changes.
- glenrivard 8y agoThink it will be Flutter. There is already some support for desktop. Here is the project https://github.com/google/flutter-desktop-embedding https://github.com/google/flutter-desktop-embedding
- bunnycorn 8y agoThe author is wrong in one point, Electron is not based on Chrome, it's based on Chromium, and you don't need to trust Google because it's 100% open source.
- ___alt 8y agoBy default, Chromium still integrates heavily with Google services. See project ungoogled-chromium for details: https://github.com/Eloston/ungoogled-chromium https://github.com/Eloston/ungoogled-chromium
- hannasanarion 8y agoSince when does electron make you log in with Google?
- pritambaral 8y agoIntegration with Google services does not require logging in to Google services. For a benign example: using Google search For a less benign example: your browser/device/network being tracked for ads when using Google search
- hannasanarion 8y agoElectron is not a search engine or a browser, and it does not serve ads.
- pritambaral 8y agoGoogle Play Services (on Android) is not a search engine or a browser, either. Google Home does not serve ads, either. My original comment's grand-parent did not claim if Electron was a browser or a search-engine, or if it showed ads, just that it is not necessarily independent of Google services just because it's built from Chromium.
- interfixus 8y agoThe most obvious Electron alternative on any platform is of course doing things the way we sort of used to: Get your toolkits and compilers out, your hands dirty, and your integrity clean and code some honest to God desktop applications. If you absolutely need to do web primitives inside your app, well then, html engines used to come in a few megabytes and no external deps. If your webcode needs the entire Chromium monstrosity bundled in order to run, someone has been doing something entirely wrong.
- outadoc 8y agoThe most obvious counter-argument: one shared codebase vs. your five. Native is awesome when you have the money.
- arcticwombat 8y agoMeh, I write cross platform applications, single code base, and compile to native executables on Windows, Linux, and Mac with no problem and no extra Chromium bloat. FreePascal + Lazarus.
- TomMarius 8y agoHow do I run that on web, the most important platform today? I'm also not aware of any comparable community like Node.js has. And I say that as someone who was writing Pascal professionally ~5 years ago.
- arcticwombat 8y agoWe're not talking about web applications, we're talking about Electron. But sure, if you want to do Pascal on the web there are things like Smart Pascal.
- TomMarius 8y agoWe're talking about ways to do multiplatform applications, which includes the web. You suggested Pascal but that doesn't run on the web without changing the code. Enclosing the application in Electron shell does not mean it's the only way it's going to be ran, actually most of the time you do it because you already have a web application and a server.
- tiborsaas 8y agoIf you throw out cross platform support it's hard to call it an alternative :)
- saagarjha 8y agoIt’s pretty cross-platform, if you swap out “WKWebView” with “your platform’s native web view”.
- rasengan 8y agoJust use gtk WebKit or qt WebKit and you’re good to go. For the record, WebKit originated from KDE[1]. [1] https://en.m.wikipedia.org/wiki/WebKit https://en.m.wikipedia.org/wiki/WebKit
- nicoburns 8y agoYeah, at that point the most obvious alternative is Cocoa!
- shubhamjain 8y agoMacGap framework [1] builds on the same idea. In fact, it predates Electron and was being used by Slack. The size of the compiled binary would be just ~350KB. [1]: https://github.com/MacGapProject/MacGap2 https://github.com/MacGapProject/MacGap2
- Void_ 8y agoWow, I used this in 2012. I think it was originally written by Alex MacCaw of Clearbit.
- tbrock 8y agoI don’t understand why the entire browser engine needs to be bundled with each app. Why not have libchrome or a libelectron that moves more slowly than chrome six week release cycle (maybe do 6 months) then have apps build to it and share the library.
- lcnmrn 8y agoDevelopers target a runtime with very specific APIs. If the runtime changes developers wouldn't even bother to write the apps. If Electron apps would specify requirements instead of bundling the whole runtime, you will have to wait for the runtime to be downloaded the first time the app runs. You will still end up with multiple versions of the same runtime running on your system.
- tbrock 8y agoIs it possible to stabilize the runtime or is it moving too quickly?
- deleted 8y ago[deleted]
- DonHopkins 8y agoNot for all applications, but for enough applications to make it well worth it.
- szemet 8y agothe entire browser engine needs to be bundled with each app No. It depends on the package manager. E.g: https://www.archlinux.org/packages/community/x86_64/electron/ https://www.archlinux.org/packages/community/x86_64/electron... A shared electron package used by a few different apps: see the "required by" column... As electron gets more popular, this will be the standard in Linux distributions (at least historically thats how dependencies handled there), Windows has different standard (self contained everything) so there it is the normal way - everybody already used to it for decades...
- yakubin 8y ago> It is cheap And so the results look cheap.
- lazyjones 8y agoThe web and its technologies are far from stable, cheap and simple to learn. And browser-based UIs are pretty much where native UIs were 30 years ago, just a bit slower. Cross-platform: yes, if you ignore the fact that there are only 2 browsers left, both being buggy and incomplete (as they've been for many years) and with no other implementation in sight, or even remotely feasibly for small to medium-sized companies or teams. Also they're so bloated and isolated from the native environment that you might just as well install a Linux virtual machine and call it a cross-platform UI. No, thanks. I'll wait for a better cross-plattform UI solution.
- skybrian 8y agoThis isn't an actual critique, it's just dismissal. "Buggy" is just an adjective. Don't do this.
- diminish 8y ago> pretty much where native UIs were 30 years ago, In reverse, I would argue, Hundreds of "Native UIs", most of them obsolete or dead, have shown to be incapable to express cross-platform, flexible layout capabilities of 1990s HTML/CSS combo. The most recent, yearly updated mobile OSes appear to be cooler, however we'll see in 10 years how they will end up.
- lazyjones 8y ago> In reverse, I would argue, Hundreds of "Native UIs", most of them obsolete or dead, have shown to be incapable to express cross-platform, flexible layout capabilities of 1990s HTML/CSS combo. But most haven't. If you want the capabilities of the HTML versions unable to even center vertically or requiring invisible images to format tables, there are plenty of UI to choose from. Qt, Wx are extremely capable nowadays.
- arcticwombat 8y agoLet's move away from hiding browsers in windows and pretending they're not browsers hiding in a window. FPC + Lazarus, native executables, cross platform.
- throwahoy 8y agoYou’ve mentioned this several times now as though it’s some magic sauce that everybody is missing. But it’s not like FPC/Lazarus is the only portable GUI solution — Qt, Fox, Swing, SWT, Gtk etc. also exist, and don’t require a fringe language (and I say that as someone who did Turbo/Borland Pascal and Delphi development for more than a decade). What Lazarus offers is a Delphi-type form builder tool, but that seems a lot less interesting in this day and age of heavily customized UIs that aren’t static grids of square components — in particular, we increasingly rely on responsive layouts and smooth animations between them. Moreover, I’ve yet to see a FPC app (or any app for that matter that isn’t Electron or web) that doesn’t look like an old fashioned Windows-style GUI app. Do you have any examples?
- eklavya 8y agoQML apps look modern and quite good really.
- arcticwombat 8y agoIt's not magic sauce, it's a counter-point to the "Electron gives you cross platform deployments" argument. Yes, there are many GUI toolkits, the LCL creates native applications while some others do not, but it's certainly not the only one. It's the one I prefer so I use it as an example over QT, Swing, JavaFX, etc. Lazarus form builder let's you create forms very quickly and easy, and OS themed design. If you want other types of GUI designs you can do that too, though personally I prefer standard OS design. As far as static grids and square components, I think you're looking at old stuff.. You can make things as squiggly as you like, and of course you can always use images and colors to design your GUI and let your imagination run wild, and it'll look entirely non-native. Responsive design isn't that challenging either, use anchors and smart design. I don't have any examples of desktop applications I've made, that look like web-apps, no, but I might make some after you giving me this idea, and I'll be doing it with FPC/Lazarus.
- gok 8y agoThis reads like someone hired a consulting firm to send out surveys asking why people don't like Electron apps, without really understanding the problem. None of the four bullet points actually address real issues. The security problem isn't that Google is bad at security (they're among the best really). The problem is that Javascript code is generally written with the expectation that it will run in a web browser's highly locked down security context. Performance is really the same issue: web apps are authored wastefully. For use cases where you visit a web page for a few minutes then leave that's fine, but when you then let that code run for hours with no sandbox you will inevitably hit perf issues. Write native apps. If you can't afford that, just make a web page.
- izacus 8y agoElectron also has a lot of hardening features from chromium disabled as is strongly discouraged by Google as unsafe to use for apps.
- smaddock 8y agoThis seems to be changing as of recently this year. There have been many security-related changes including making options such as Node integration disabled by default [1]. Support for renderer process sandbox is also available [2]. [1] https://github.com/electron/electron/pull/14284 https://github.com/electron/electron/pull/14284 [2] https://electronjs.org/docs/api/sandbox-option https://electronjs.org/docs/api/sandbox-option
- LaGrange 8y agoAlmost nobody can afford that, not anymore. If your application can be written in Electron and provide 80% of your features, someone's going to do it and eat your business alive. Especially if they can figure out how to leverage network effects to use their users to drag your committed users away. Unless you have a core feature that _can't_ be implemented in Electron for some reason (I guess you're writing a game or something similar?), or have some other mechanism for locking your users in, writing a native app in 2018 is just putting your employees livelihood at stake. It's not cool or fair at all, sure, but hey, us Marxists were telling you this will always happen for over 150 years now, and y'all still acting surprised.
- deleted 8y ago[deleted]
- vidanay 8y agoI still live in the world of heavy desktop native apps (WinForms & WPF) and one thing I've never been able to understand about all of these Electron discussions is what benefit does Electron bring in the first place? Why not simply run the application and connect to it using the local browser instance? For convenience a link can be placed on the users desktop.
- deleted 8y ago[deleted]
- preommr 8y agoYou get access to some features that a browser doesn't allow like better access to a file system or taking a screenshot. Plus it gets rid of visual clutter like the tab bar and treats your app like an actual application rather than a simple website for viewing.
- arcticwombat 8y agoHow is that a selling point though? People using desktop toolsets never even have to think about that "problem" because it just doesn't exist when you're using the right tools. There are three types of tools for every job.. * The right kind * The wrong kind * The wrong kind but we'll make it work Electron hits squarely in the third category by hiding the browser and webserver and pretending it's a real desktop application.
- todd3834 8y agoIt’s all about cross platform support. The reason you will see advantages listed this way is because the web browser is the real competitor here. So when people talk about what Electron can do they are comparing to the most obvious alternative of a web app.
- arcticwombat 8y agoThe web browser is not the real competitor here, that's a web developer fallacy if ever I saw one. As soon as you move to the desktop, you're competing with the desktop toolsets. People comparing Electron to the browser is missing the entire point of what Electron is for, which is pretending to be a native application.
- ynniv 8y agoThis is how Apache Cordova (previously PhoneGap) works. [https://cordova.apache.org/ https://cordova.apache.org/]
- PascalW 8y agoI posted this earlier in an Electron discussion, but there are a couple of libraries that take this approach cross-platform, like zserge/webview [1] and Tether [2]. [1] https://github.com/zserge/webview https://github.com/zserge/webview [2] https://github.com/quadrupleslap/tether https://github.com/quadrupleslap/tether
- DonHopkins 8y agoWkWebView is a huge improvement over UIWebView on iOS or WebView on macOS. However on macOS it is missing one important feature (to me at least) that used to work with WebView: You can't capture the image of the web browser window any more. You used to be able to go something like: NSBitmapImageRep *bitmapdata = [view bitmapImageRepForCachingDisplayInRect: bounds]; [webView cacheDisplayInRect: bounds toBitmapImageRep: bitmapdata]; Or: [NSView cacheDisplayInRect:(NSRect)rect toBitmapImageRep:(NSBitmapImageRep *)bitmapImageRep] But that's a synchronous API, and since WkWebView runs in another process, it requires a remote procedure call, so Apple simply returns a blank image from that call now. https://stackoverflow.com/questions/31969950/wkwebview-cachedisplayinrect-screenshot-in-os-x https://stackoverflow.com/questions/31969950/wkwebview-cache... I think the iOS way of capturing a screen snapshot from WkWebView still works, though, but I can't remember off the top of my head... However, Apple added a new method to Safari, but last time I checked it was only in the beta Safari and not supported in the version installed on the operating system. (When you make a WkWebView it uses some specific framework that's not necessarily the latest beta version of Safari you've installed.) //iOS func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping (UIImage?, Error?) -> Void) //macOS func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping (NSImage?, Error?) -> Void) But the problem with this method is that it takes a totally different rendering path ("this is a software painted snapshot"), so some stuff may look different, and WebGL stuff doesn't appear, and it's a whole lot slower than cacheDisplayInRect used to be). https://stackoverflow.com/questions/46842384/wkwebkit-takesnapshotwith-snapshotconfiguration-not-working-on-ios-device https://stackoverflow.com/questions/46842384/wkwebkit-takesn... This bug describes the problem and the issues and the less-than-ideal solution: https://bugs.webkit.org/show_bug.cgi?id=161450 https://bugs.webkit.org/show_bug.cgi?id=161450 Summary: [Cocoa] No reliable way to get a snapshot of WKWebView
- ken 8y agoI hear a lot that WKWebView is an improvement, but all I see are some pretty significant limitations compared to WebView: - no screenshots - no printing - no user stylesheets - no cmd-F find - no delegate method for hover-over-link - no access to container NSScrollView (on macOS) - harder to customize context menu (AFAICT) - ignores URLProtocols (10.13 added a new way to implement custom protocols for WKWebViews with a completely different interface than NSURLProtocol/WebView) I'm dreading the day when Apple is going to require me to 'upgrade' my WebView to WKWebView. All I want to do is supply a byte stream containing HTML, and have it displayed in an NSView, with standard features. This doesn't seem like an obscure case, or a difficult problem. I don't understand why none of Apple's web views ever had simply a load(stream:NSInputStream) method. This was hard with WebView, and WKWebView made it a lot harder.
- mgliwka 8y agoRails Turbolinks utilizes this technique for iOS: https://github.com/turbolinks/turbolinks-ios https://github.com/turbolinks/turbolinks-ios Video explanation/demonstration: https://youtu.be/SWEts0rlezA https://youtu.be/SWEts0rlezA
- SiDevesh 8y agoRecently there has also been some interest in making chrome usable as a runtime to load web content as/in native apps, especially since with native webview the experience would vary across different platforms (windows 10 below will try to load it on ie!), i was working on https://github.com/SiDevesh/Quark-Go https://github.com/SiDevesh/Quark-Go using the cool https://github.com/zserge/webview https://github.com/zserge/webview library, recently started redoing it with https://github.com/GoogleChromeLabs/carlo https://github.com/GoogleChromeLabs/carlo
- anaisbetts 8y agoThis is literally what Slack moved from years ago, because it was very problematic, let me tell you why since I'm the one who did it. * Adding new APIs was a huge pain in the ass, you had to write all of this ugly bridge code in Objective C, and the APIs ended up being super unnatural on the JS side. As a result, desktop integration wasn't done much since it felt like a "Black Magic" type thing. Writing new APIs in Electron is Just JavaScript, so you can make something much more natural. * We could literally do fuck-all for people running old versions of macOS - you can't upgrade Safari on old machines, you just Get What You Get. For awhile, every YouTube video on older macOS versions had a pink shade to it. Users write in, "This is clearly wrong!" "Yep, but we can't fix it. Sorry." * And big spoiler - WKWebView uses _basically_ the same amount of memory give-or-take a few MBs as Chromium. It's the content that sets the memory usage bar, not the host.
- saagarjha 8y ago> WKWebView uses _basically_ the same amount of memory give-or-take a few MBs as Chromium It really doesn’t. A “Hello, World” WKWebView is a couple of megabytes. The same in an Electron app is hundreds of megabytes.
- xpaulbettsx 8y agoThis is a useless comparison. Once you're hosting an actual app, the content matters way more.
- saagarjha 8y agoMessages uses webviews and manages to do much of what Slack does with a tenth of the memory footprint. I still have not found any evidence for your claim that Electron and WKWebView use the same amount of memory.
- xpaulbettsx 8y agoYou're literally comparing two completely different apps. If you want to compare Apples to Apples, host 5 teams in Slack, in both Chromium and WKWebView
- ori_b 8y agoThe problem with electron isn't electron -- it's the standards that it's built on. Replacing one flavor of it with another doesn't move the needle significantly.
- Entangled 8y agoThis is perfect for writing compact and portable web apps. I built a basic chrome that runs an index.html page and everything linkable after that and all I have to do is inspect myweb.app file and change whatever html, css or js I want. Simpler impossible. And with a little help from Swift I can have all the power of macOS in my hands. It is neither a hammer nor a nail, it just works for some specific purposes.
- see-ya-99 8y agoElectron and other wrappers are just shit in my opinion as these consumes a lot of precious resources. Maybe devs instead of being lazy suckers could start to worry about this aspect.
- aaaaaaaaaab 8y agoGive it a few years. We’re at the limits of what’s photolitographically possible with silicon. As soon as Moore’s law halts all this wasteful crap will go down the shitter.
- mdhughes 8y agoCross-platform is the key problem. If I want to write a Mac-only app, I can do that in Objective-C/Cocoa, and be quite happy. For Linux, native means fighting with primitive C and X11 or Gtk, etc., which I can do but I loathe it. For Windows, I have no idea, C# maybe? I'd rather eat broken glass than install Windows and find[ed.] out. So if I'm doing cross-platform, my current working choices are Electron, Java, FreePascal/Lazarus, or Scheme. Electron's easy to build all three platforms on, performance is OK despite the bloated example of Slack. Java would need to bundle the JRE everywhere, and I've been largely Java-clean for 10 years. Lazarus is semi-broken on Mac currently, only 32-bit like stone age tools, Cocoa port is unfinished. Maybe they'll get their shit together someday, I like it when it works. Scheme native binaries are hard and experimental, but getting better. Using a WKWebView on Mac, then writing a completely different wrapper on Linux & Windows, is unacceptable for my uses. So my actual shipping code is Electron.