Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Windows.UI.Xaml.Controls.WebView where possible on Windows #85

Closed
chris-morgan opened this issue Jan 22, 2018 · 29 comments
Closed

Use Windows.UI.Xaml.Controls.WebView where possible on Windows #85

chris-morgan opened this issue Jan 22, 2018 · 29 comments

Comments

@chris-morgan
Copy link

There are plenty of serious reasons to prefer EdgeHTML to MSHTML; Edge is a more modern target than IE, with various features that you can’t get on IE.

In Universal Windows Apps, Windows.UI.Xaml.Controls.WebView uses IE11 on Windows 8 and Edge on Windows 10.

I don’t know how you would go about doing it and I’m not certain it’s possible to do both in the one binary (though I imagine it is), but the ideal situation is to try to use the UWP WebView where possible, before falling back to the old MSHTML.

I expect this would require using some C++/CX.

I expect that implementing this will involve quite a bit of research and development, but it should be possible and is very desirable.

@quadrupleslap
Copy link

i'm working on this right now. also, this would sort-of solve #76.

@ajusa
Copy link

ajusa commented Jan 23, 2018

Also, it might add HDPI support as well

@quadrupleslap
Copy link

Hmm... I made a rip-off of this library at quadrupleslap/tether, and it uses the UWP control, but there's a few problems:

  • I still need to translate the C++/CX code into WRL code so that (a) it'll work with MinGW and not just MSVC, and (b) so that cross-compilation might work.
  • It's forced to use the UWP sandbox, so users need to install their app with an AppManifest even when testing AFAIK, which is incredibly tedious.
  • You can't just spin up the main loop, it needs to run forever as far as I can tell, which doesn't work well with this library's API.

@ghost
Copy link

ghost commented Feb 12, 2018

@quadrupleslap
Looks really cool.

@delaneyj
Copy link

Could this be ported back to webview?

@jmerriweather
Copy link

Could we use Microsoft/cppwinrt once Windows 10 RS4 is out so we don't have to mess with the AppManifest stuff? If I understand correctly it would also enable Edge webview to work on older versions of Windows as well, however would need to be compiled on Windows 10 RS4+

@ghost
Copy link

ghost commented Apr 19, 2018

@jmerriweather NIce find.
Its a minefield with Windows these days. This api sound slike Microsoft actually committing to an api.

They sound like this is the one true API going forward, but the repo has not had any commits for 4 ot 5 months. I dont get it.

is Windows 10 RS4+ available ? I have to admit i am lost with all their flux.

@edwardchanjw
Copy link

Is this possible to support GTK on Windows? Like certain library that support using GTK on both OS etc, but here we support native browser and selective like GTK.

@quadrupleslap
Copy link

@jmerriweather Unfortunately (as best I can tell), that just removes the dependency on C++/CX, so I guess it could theoretically help with cross-compilation, but you still need an AppManifest and to participate the whole Microsoft sandboxing mess.

@edwardchanjw I don't see why not. Do you want GTK with an Internet Explorer fallback, or the ability to use GTK instead of Internet Explorer?

@kofredwan13
Copy link

Can it be used in Android applications?

@quadrupleslap
Copy link

quadrupleslap commented Apr 22, 2018

@edwardchanjw Whoops, I forgot: if you want to use Webkit2GTK instead of Internet Explorer on Windows, you might be able to just pass -DWEBVIEW_GTK=1 instead of -DWEBVIEW_WINAPI, like you would on Linux, and link as required (kind of obvious now that I think about it).

@kofredwan13 This library cannot currently be used in Android applications.

@mehrvarz
Copy link

Hi. I tried passing -DWEBVIEW_GTK=1 instead of -DWEBVIEW_WINAPI. With pacman from MSYS2 I installed gtk3, toolchain and base-devel. I got stuck because pacman does not offer a webkit2 target (anymore?) as required for webview.h. And the webkitgtk-2.22.2 I installed by hand fails due to #include errors: <webkit2/webkit2.h> does not exist in webkitgtk-2.22.2. How can I solve this? @quadrupleslap?

I am no Windows expert by any stretch. But I made some really nice Linux and macOS apps with Webview and Go. I posted #191 a while back.

@PaintNinja
Copy link

PaintNinja commented Dec 8, 2018

I've found a repo where someone has dabbled with the new APIs that allow for some UWP features to be used within Win32 apps. Maybe this could be adapted to support EdgeHTML in webview for rust?
https://github.com/bwalderman/rust-modern-webview
https://docs.microsoft.com/en-us/uwp/api/windows.web.ui.interop
or alternatively https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/webview

@quadrupleslap
Copy link

quadrupleslap commented Dec 9, 2018

I'll have a go at adding support for this to zserge/webview, but I'm not sure whether this will support Microsoft's apparent migration to Chromium.

@PaintNinja
Copy link

PaintNinja commented Dec 9, 2018

Thanks! I'm looking forward to it. :)

Even if this doesn't support the migration to Chromium, EdgeHTML is still a huge upgrade from IE11 in both performance and web standards compatibility.

@quadrupleslap
Copy link

Okay, just waiting for Windows' October 2018 Update (1809) to be rolled out so that I can use AddInitializeScript.

@PaintNinja
Copy link

PaintNinja commented Dec 15, 2018

The October 2018 update has been out for a while now... https://m.windowscentral.com/microsoft-begins-re-rollout-windows-10-october-2018-update
If you haven't already gotten it automatically, you could try manually checking for updates in the settings app.

Or do you mean you're waiting for it to be wide-spread?

@zserge
Copy link
Collaborator

zserge commented Dec 30, 2018

Somehow I managed to make a minimal HWND + embedded Edge browser with pure C++17 using WinRT APIs. Unfortunately, I had to compile it with cl.exe, not sure if mingw supports winrt at the moment. Will see how it can be connected to Go then (maybe just an external DLL loaded from Go?).

Anyway, this means webview.h is about to be rewritten using a subset of modern C++ (we need C++17 anyway to support Edge and WinRT, so why not to simplify code for other platforms as well?). The high-level API will remain suitable for C and Go.

@quadrupleslap
Copy link

I have a fork working with a slightly different API and multiple windows, but I split everything into separate files, so the macOS part is in Objective C, and the Windows part is in C++/WinRT. I still can't get the Windows version working though, because Microsoft won't offer my PC the October Update. I can put it on GitHub if anyone wants it.

@PaintNinja
Copy link

PaintNinja commented Dec 30, 2018

I still can't get the Windows version working though, because Microsoft won't offer my PC the October Update.

Have you tried using the "Update now" button on this page? https://www.microsoft.com/en-au/software-download/windows10

@cretz
Copy link

cretz commented Feb 13, 2019

For those working on this, here's a same-licensed project/code that uses the Edge control: https://github.com/patr0nus/DeskGap/blob/5992a2eaf7c1695eba60a79553d3cf9ea6d1fecd/core/src/win/webview.cpp

@zserge
Copy link
Collaborator

zserge commented Feb 13, 2019

There is an experimental branch, webview-x, that has support for both MSHTML and EdgeHTML. Rewritten in plain C++ (not weird CX dialect), with C API and Go bindings. There are still a few things left to fix, but I expect it to be merged over the next month or so.

@cdujeu
Copy link

cdujeu commented Jun 6, 2019

Hi, sorry to bump this one,
@zserge any hint about the status of the webview-x branch? Can it be used as is? I tried to switch on it but on macOS it does not compile, would it be for windows-only compilation?
Thx in advance

@leaanthony
Copy link

Am also curious to the status of webview-x. No commits for 4 months. Is it still active?

@cretz
Copy link

cretz commented Nov 4, 2019

In addition to the Xaml control (which may use it underneath I dunno), there is https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2

@Ciantic
Copy link

Ciantic commented Jan 20, 2020

The WebView2 is way better, it's your regular good old Chrome renderer. Also they seem to be updating the sample rather regularily: https://github.com/MicrosoftEdge/WebView2Samples/tree/master/WebView2APISample

XAML component might not be updated to that for a while. Hard to imagine building on MSHTML (Old Edge) these days.

@zserge
Copy link
Collaborator

zserge commented Jan 20, 2020

@Ciantic Both are implemented in the webview-x branch, with a fallback from WebView2 (Edge/Chromium) to EdgeHTML, while MSHTML implementation is removed.

@anderejd
Copy link

Will the webview-x branch be merged to master or is it just an experiment?

@Ciantic
Copy link

Ciantic commented Feb 22, 2020

Yes, it would be nice to merge webview-x because downstream stuff is not even aware of webview-x branch. At least we could get the support to trickle faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests