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

Edge WebView2 support #521

Closed
r0x0r opened this issue May 19, 2020 · 34 comments
Closed

Edge WebView2 support #521

r0x0r opened this issue May 19, 2020 · 34 comments
Labels

Comments

@r0x0r
Copy link
Owner

r0x0r commented May 19, 2020

Windows Forms support for Chromium based WebView2 has finally arrived. Implementing this for pywebview should be doable at this point.

https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 26, 2020
@r0x0r r0x0r removed the stale label Aug 26, 2020
@kvnxiao
Copy link

kvnxiao commented Sep 10, 2020

Any chance of this being done any time soon?

@r0x0r
Copy link
Owner Author

r0x0r commented Sep 10, 2020

@kvnxiao I am not working on this actively at the moment, not sure when I have time and energy to devote to this issue.

However, if you want to see this implemented fast, consider sponsoring this issue.

@kvnxiao
Copy link

kvnxiao commented Sep 11, 2020

Suppose if I have time to contribute to this, what exactly is required to get WebView2 up and running together?

@r0x0r
Copy link
Owner Author

r0x0r commented Sep 11, 2020

  1. WebView2 implementation is to be done in the same manner as EdgeHTML, ie no changes would be needed to made to window logic. WebView2 component would be attached as a child to the form.

  2. WebView2 detection logic is needed (checking for .NET and Window 10 versions ), as it is done with Edge

    is_edge = _is_edge() and forced_gui_ != 'mshtml'

  3. winforms.py will require a refactor at some point, as it is already too large for a single file. In practice that would be mean splitting renderer code to separate files.

  4. renderer value for WebView2 can be chromium

  5. EdgeHTML is buggy af, not sure if WebView2 is any better. In any case, one should prepare for all kinds of quirks and funky solutions.

@kvnxiao
Copy link

kvnxiao commented Sep 11, 2020

WebView2 uses Chromium so it should not be buggy in any way; it would be as buggy as using chromium on other platforms.

@dmwyatt
Copy link

dmwyatt commented Sep 20, 2020

@kvnxiao Are you going to work on this?

@kvnxiao
Copy link

kvnxiao commented Sep 20, 2020

@dmwyatt I don't think I have the time to contribute on this one, but just simply wanted to ask for a clear roadmap in case someone else would like to work on it.

@tshemeng
Copy link
Contributor

@r0x0r r0x0r pinned this issue Oct 20, 2020
@Ksengine
Copy link
Contributor

@Ksengine
Copy link
Contributor

Ksengine commented Nov 5, 2020

webview2 latest
dlls

@Ksengine
Copy link
Contributor

Ksengine commented Nov 5, 2020

users should install webview2 runtime
we can programatically install it
get a link from https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section

@sbbosco
Copy link
Contributor

sbbosco commented Nov 6, 2020

I have created a working first draft with Edge Webview2 support.
The modified files and notes are here https://github.com/sbbosco/pywebviewx

I am new to Github, so let me know if I break any protocols.
Thanks

@tshemeng
Copy link
Contributor

tshemeng commented Nov 6, 2020

@sbbosco I tested on Windows10 20H2, it works well, maybe you can send PR to this repo.

@martinlombana
Copy link
Contributor

I have created a working first draft with Edge Webview2 support.
The modified files and notes are here https://github.com/sbbosco/pywebview

I am new to Github, so let me know if I break any protocols.
Thanks

Hi!, Just out of curiosity. With this approach, could we ship the DLLS with the app when freezing it with pyinstaller, so that we can use that webview, but if the final user does not have it, it can still work?

Thanks!

@tshemeng
Copy link
Contributor

tshemeng commented Nov 7, 2020

Edge 87 stable will release end of 2020 which includes webview2, soon user don't need to install webview2 runtime or Edge insider version.

@sbbosco
Copy link
Contributor

sbbosco commented Nov 7, 2020

@tshemeng I'm glad you were able to successfully test the webview2 changes. I am new to Github and I may need some guidance on how to submit a PR. I may also want to wait for a blessing from @r0x0r. My intention was always to directly contribute to this repo.

I hope you a right about Edge 87!

@sbbosco
Copy link
Contributor

sbbosco commented Nov 7, 2020

@martinlombana There are 2 separate requirements.

  • The 3 SDK DLLs that I image would be included in a future release of pywebview.
  • The Webview2 Runtime or supported Edge browser.

If you distributed a frozen program, you would probably need to check if the runtime is installed and programmatically install a runtime if it is not present.

Hopefully the comment from @tshemeng about Edge 87 will save us from this extra requirement in most cases.

Here's a link about app distribution https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution

@tshemeng
Copy link
Contributor

tshemeng commented Nov 7, 2020

@sbbosco Sorry I check webview2 docs again, it does not say Edge 87 contains webview2.
I decide emmbed a webview2 runtime web installer in my exe.

@r0x0r
Copy link
Owner Author

r0x0r commented Nov 8, 2020

@sbbosco Good work. Please create a PR.

I was hoping to refactor the whole winforms.py for better handling of different renderers. With four different renderers it is becoming unruly. Alas I don't have a Windows development machine at the moment.
If anyone has got ideas for a better architecture, please share your thoughts here.

@sbbosco
Copy link
Contributor

sbbosco commented Nov 10, 2020

@r0x0r Please take a look here and let me know if this is what you had in mind for refactoring. Any suggestions are welcome.

https://github.com/sbbosco/pywebview/tree/edge-webview2/webview/platforms

@r0x0r
Copy link
Owner Author

r0x0r commented Nov 12, 2020

@sbbosco yes, this would do for now. chromium.py can have a more descriptive name to indicate that it is not cross-platform, maybe edgechromium.py

@sbbosco
Copy link
Contributor

sbbosco commented Nov 16, 2020

@r0x0r Thanks. I will create a PR after the noblock changes are stable.

@r0x0r
Copy link
Owner Author

r0x0r commented Nov 16, 2020

@sbbosco The noblock might take a while, as there is no solution in sight. So no need to wait for it.

@r0x0r
Copy link
Owner Author

r0x0r commented Nov 24, 2020

Chromium support merged into master. Many thanks to @sbbosco for the outstanding work.

I have updated documentation here https://github.com/r0x0r/pywebview/blob/master/docs/guide/renderer.md

Feel free to test this and report your findings. I will release a new pywebview version next week or so.

@Ksengine
Copy link
Contributor

I need a help for noblock
Can anyone find a method to do multiprocessing using spawn method on frozen apps

@sbbosco
Copy link
Contributor

sbbosco commented Nov 25, 2020

@r0x0r You may want to consider updating the edgehtml evaluate_js function similar to the chromium method.

I have an app that works well with cef and chromium, but has lots of errors when using edgehtml. After updating the code, edgehtml also runs without errors.

winforms.py
edgehtml.py
edgehtml.py oops

@r0x0r
Copy link
Owner Author

r0x0r commented Nov 25, 2020

@sbbosco Could you create a PR?

@r0x0r r0x0r mentioned this issue Dec 3, 2020
Closed
@r0x0r r0x0r unpinned this issue Dec 3, 2020
@r0x0r r0x0r closed this as completed Mar 26, 2021
@martinlombana
Copy link
Contributor

Hi,

Any idea on how to package the DLLs with pywebview, and froze it with pyinstaller in an standalone/controlled manner? Has anyone done that?
@sbbosco, @r0x0r

Thanks!

@r0x0r
Copy link
Owner Author

r0x0r commented Sep 23, 2022

You can specify a data dir that would be embedded with the exe in pyinstaller

@martinlombana
Copy link
Contributor

@r0x0r , thanks. But how do I instruct pywebview to load the runtime from that exact folder?
That is my doubt :)

@r0x0r
Copy link
Owner Author

r0x0r commented Sep 24, 2022

You can use pyinstaller's sys._MEIPASS to obtain the current directory of the executable. You may look at pywebview's code for example usages of this variable.

@martinlombana
Copy link
Contributor

Thanks,

I can't seem to be able to locate the example that you are referring to, in order to set the executable to be used by Pywebview. Could you point me to it? Thanks in advance.

@r0x0r
Copy link
Owner Author

r0x0r commented Sep 29, 2022

@martinlombana Check this

def get_app_root():

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

No branches or pull requests

7 participants