News for hackers. Stuff that matters.
Re:WKWebView, an Electron alternative on macOS/iOS by bunnycorn on Wednesday December 26, 2018 @08:03AM (#18761937)
It 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.

Re:WKWebView, an Electron alternative on macOS/iOS by tokyodude on Wednesday December 26, 2018 @12:13PM (#18763214)
So, every time Apple updates WebKit your app breaks. We've gone through this in the past. There are multiple reasons Electron is a win.

1. It's cross platform

   Don't have to deal with the fact that Safari is missing these 12 APIs or has different edge cases
2. It's stable after shipping

   Users get a new version only when you ship. If you use the native widget then users get a new (often broken) version on every update by a 3rd party (Apple/MS/Google). Example: chrome just deprecated autoplay. If that bubbled into apps your app just broke. Electron could do the same but if you're testing like a good dev that break wouldn't make it to users. You as a dev would find it locally, deal with it, and only after ship to users.
so, no personally I don't want a shared widget. that sounds like going back to DLL hell or worse, just broken stuff.
Re:WKWebView, an Electron alternative on macOS/iOS by heywire on Wednesday December 26, 2018 @04:58PM (#18765284)
Doesn’t stable after shipping also mean that if a critical vulnerability is found in the version of electron/chromium that you’ve bundled, the user is vulnerable until you are able to issue a fix? What if the app itself is no longer updated?
Re:WKWebView, an Electron alternative on macOS/iOS by tokyodude on Thursday December 27, 2018 @02:32AM (#18768065)
How is that different than any native app? All native apps have that issue.
Re:WKWebView, an Electron alternative on macOS/iOS by watermelon0 on Thursday December 27, 2018 @08:12AM (#18769224)
Native apps can benefit from using shared libraries, which can be updated in such case. Using WKWebView ensures that vulnerabilities are patched as part of OS updates.

On OSes with sane package managers (e.g. Linux distributions) native apps can share all dependencies, so there is no need to recompile/redistribute each application using affected library.

Sadly, there is no such thing on MacOS (excluding brew/port) and Windows (or even iOS/Android), and even native Linux applications are moving towards bundling all dependencies in a single package.

Re:WKWebView, an Electron alternative on macOS/iOS by heywire on Thursday December 27, 2018 @09:02AM (#18769468)
Typically a native application will depend on shared libraries (or runtime such as jvm, .net) which can be updated independently of the application itself. That said, if the vulnerability is in the application code, you are correct, there would be little difference.
Re:WKWebView, an Electron alternative on macOS/iOS by bunnycorn on Wednesday December 26, 2018 @08:44PM (#18766556)
If you use the "API's": standard HTML and standard JS, like a good citizen, I really doubt that would be a problem. And if it is, it's you job to update you app, also Apple provides pre-release versions with good antecedence.
Re:WKWebView, an Electron alternative on macOS/iOS by disishhsha on Wednesday December 26, 2018 @08:28PM (#18766469)
Could you avoid using code blocks for text? They are very difficult to read on mobile.
Re:WKWebView, an Electron alternative on macOS/iOS by tokyodude on Thursday December 27, 2018 @02:34AM (#18768070)
blame HN, I didn't format them as code blocks. I put #.<space>text<cr><space><space><space>text which in any other context would be text not code
Re:WKWebView, an Electron alternative on macOS/iOS by tinus_hn on Wednesday December 26, 2018 @01:54PM (#18763896)
WebKit is free so you can bundle the library if you want. Or not.
Re:WKWebView, an Electron alternative on macOS/iOS by sime2009 on Wednesday December 26, 2018 @04:38PM (#18765170)
What is the point in that now? It is going to be a similar size as Chromium. You might as well just use Electron.

As a matter of fact, Chromium's/Chrome's engine Blink was forked off from WebKit back in 2013. Current WebKit is Apple's not-quite-as-well-updated version of the engine in old Chrome.

Re:WKWebView, an Electron alternative on macOS/iOS by lcnmrn on Wednesday December 26, 2018 @08:53AM (#18762124)
Each Electron app comes with a very specific versions of Chromium and Node.js.

They can't run on native frameworks. If native frameworks are updated old apps would break. If native frameworks aren't updated newer apps would break.

What you're asking was already tried with Adobe AIR and failed. Instead we need lighter alternatives to Node.js and Chromium.

Re:WKWebView, an Electron alternative on macOS/iOS by azhenley on Wednesday December 26, 2018 @09:22AM (#18762244)
I'm really starting to think it would be a good PhD dissertation project to (semi?) automatically reduce Chromium to the bare minimum needed for a given Electron app. The techniques could probably be applied to reducing any library and would be of interest to researchers in SE and PL, along with industry.
Re:WKWebView, an Electron alternative on macOS/iOS by DonHopkins on Wednesday December 26, 2018 @10:39AM (#18762622)
That's not just tree shaking, that's more like rainforest shaking!
Re:WKWebView, an Electron alternative on macOS/iOS by nickpsecurity on Wednesday December 26, 2018 @04:32PM (#18765121)
That's exactly what I thought. You just include what you use. Either developer does it on a confijguration screen, a tool does it with analysis on what code reaches what other code, or both. It would also help if Chrome is designed to make this easier.

eCos is prior work on OS side that made me always think of designing systems for easy stripping.

http://ecos.sourceware.org/about.html

Re:WKWebView, an Electron alternative on macOS/iOS by cat199 on Wednesday December 26, 2018 @11:35AM (#18762964)
> good PhD dissertation project

why?

would not existing static analysis/dependency pruning take care of it if someone had the time?

I don't see what would be 'novel' here from a theoretical point of view..

still a good project possibly though

Re:WKWebView, an Electron alternative on macOS/iOS by azhenley on Wednesday December 26, 2018 @11:51AM (#18763069)
That is the research of it, we don't know if existing techniques would work! And surely there are novel improvements that could be made, particularly for this specific application.

Also, I imagine there are many cases where static analysis would not be enough for the JS app.

Re:WKWebView, an Electron alternative on macOS/iOS by barbecue_sauce on Wednesday December 26, 2018 @02:13PM (#18764043)
Sounds more like an undergrad thesis.
Re:WKWebView, an Electron alternative on macOS/iOS by andai on Wednesday December 26, 2018 @03:57PM (#18764813)
An old man once said, "write the thesis you wish to see in the world."
Re:WKWebView, an Electron alternative on macOS/iOS by Andrex on Wednesday December 26, 2018 @05:47PM (#18765564)
Hm, would headless Chromium be a good starting point for this?
Re:WKWebView, an Electron alternative on macOS/iOS by cztomsik on Wednesday December 26, 2018 @04:21PM (#18765032)
shameless self-promotion https://github.com/cztomsik/node-webrender

(not production-ready but it might be soon good enough for really quick GUI prototyping using subset of web technologies - javascript + react + flexbox + styles)

HMR & react-devtools are already supported.

Re:WKWebView, an Electron alternative on macOS/iOS by m0dest on Wednesday December 26, 2018 @11:16AM (#18762830)
This concern about breaking only seems true for the Node.js side. The HTML/JS/CSS running in the web view should be pretty resilient to version upgrades; web devs are used to defensive, backward-compatible design that handles multiple browser versions.

The bridge itself is API stable. evaluateJavaScript:completionHandler: isn't going anywhere.

So the question is whether it's okay to use a native web view while still bundling your own V8 + Node. That seems like an improvement to me!

Re:WKWebView, an Electron alternative on macOS/iOS by dchest on Wednesday December 26, 2018 @01:25PM (#18763662)
The bridge itself is API stable. evaluateJavaScript:completionHandler: isn't going anywhere.

Historically, this hasn't been the case. Apple loves to deprecate stuff (although, thankfully, they are a bit slower to remove it). Before WKWebView there was a "stable" WebView.

Re:WKWebView, an Electron alternative on macOS/iOS by bunnycorn on Wednesday December 26, 2018 @08:47PM (#18766579)
And if my memory serves me well, you couldn't even use WK version with local files! Clearly indicating that was not the way to make UIs, but to browse the real web...
Re:WKWebView, an Electron alternative on macOS/iOS by jf- on Wednesday December 26, 2018 @09:25AM (#18762258)
Or maintain backwards compatibility. You don’t need to remove deprecated API features, just mark them as deprecated. It would add some size but it’s better than the alternatives.
Re:WKWebView, an Electron alternative on macOS/iOS by derimagia on Wednesday December 26, 2018 @11:57AM (#18763121)
Flutter does this. https://github.com/google/flutter-desktop-embedding looks for your local version of chrome. Curious if anyone has thoughts on it.
Re:WKWebView, an Electron alternative on macOS/iOS by dstaley on Wednesday December 26, 2018 @02:19PM (#18764085)
Flutter doesn't use Chrome. I think you're thinking of Carlo[1].

[1] https://github.com/GoogleChromeLabs/carlo

Re:WKWebView, an Electron alternative on macOS/iOS by derimagia on Sunday December 30, 2018 @11:08PM (#18792940)
I was, thank you for the correction
Re:WKWebView, an Electron alternative on macOS/iOS by inglor on Wednesday December 26, 2018 @08:34AM (#18762053)
Half 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.
Re:WKWebView, an Electron alternative on macOS/iOS by acdha on Wednesday December 26, 2018 @09:47AM (#18762369)
> 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?

Re:WKWebView, an Electron alternative on macOS/iOS by jf- on Wednesday December 26, 2018 @08:42AM (#18762088)
Having 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.
Re:WKWebView, an Electron alternative on macOS/iOS by saagarjha on Wednesday December 26, 2018 @08:49AM (#18762113)
> a shared electron runtime on each platform is an answer to some of its performance-related criticisms

Like…Chrome?

Re:WKWebView, an Electron alternative on macOS/iOS by jf- on Wednesday December 26, 2018 @09:31AM (#18762283)
Given 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.
Re:WKWebView, an Electron alternative on macOS/iOS by DonHopkins on Wednesday December 26, 2018 @10:40AM (#18762635)
Yes, that's the only answer, and it's a good one! It will be great and benefit everyone if Microsoft can pull that off on all platforms.
Re:WKWebView, an Electron alternative on macOS/iOS by c-smile on Wednesday December 26, 2018 @04:22PM (#18765039)
Check https://terrainformatica.com/2018/12/23/sciternode-versus-el... and discussion: https://news.ycombinator.com/item?id=18746408

In principle that is doable. Not sure about 100% compatibility as only WebKit (particular version) is 100% compatible with WebKit (particular version here). Edge is gone in that fight. Mozilla is standing but is not 100% compatible.

Re:WKWebView, an Electron alternative on macOS/iOS by izacus on Wednesday December 26, 2018 @09:35AM (#18762310)
Aren't those just called PWAs these days?