webui icon indicating copy to clipboard operation
webui copied to clipboard

Windows Webview without bundling `WebView2Loader`

Open mochalins opened this issue 1 year ago • 3 comments

Rather than relying on users to provide and bundle WebView2Loader.dll or statically link WebView2Loader.lib, a custom WV2 loader implementation can be embedded in webui.

An existing embedded Windows WV2 loader is referenced below:

https://github.com/webview/webview/blob/master/core/include/webview/detail/platform/windows/webview2/loader.hh

mochalins avatar Oct 10 '24 10:10 mochalins

Yes, good idea, this will be helpful. We should try using loader.hh as it is, so we can get updates later.

Also, both projects are MIT licensed, so all good 👍

AlbertShown avatar Oct 10 '24 13:10 AlbertShown

Yes, good idea, this will be helpful. We should try using loader.hh as it is, so we can get updates later.

Also, both projects are MIT licensed, so all good 👍

We shouldn't use loader.hh or other files from webview directly, as it requires a minimum C++11 compiler rather than building with pure C. It shouldn't be infeasible to add a custom C implementation and maintain it separately; any major improvements/fixes can still be shared between libraries.

mochalins avatar Oct 10 '24 14:10 mochalins

I checked the file very quickly, and I did not even notice it's in C++ ! However, we can keep this in our to-do list, implementing it may take some time., but it's very good feature to have.

AlbertShown avatar Oct 10 '24 21:10 AlbertShown

I have a small question. Currently, the function show_wv needs to be linked to the dynamic link library WebView2Loader.dll during compilation to work properly, right?

jinzhongjia avatar Jan 12 '25 15:01 jinzhongjia

Yes, all xxx_wv() needs WebView2Loader.dll to be present in Windows, otherwise those functions will return false.

AlbertShown avatar Jan 13 '25 17:01 AlbertShown

Replacing WebView2Loader.dll requires a lot of work... Manually implement the WebView2 COM interfaces, load runtime directly (WebView2.FixedVersionRuntime.xxx.x.x) and resolve its functions... Handle COM initialization and lifetime... and finally needs maintaining and bugs fix.

Probably user can simply use a DLL injector into compiled binary app.

AlbertShown avatar Mar 05 '25 21:03 AlbertShown