wxWebView with Chromium backend

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Anil8753
Experienced Solver
Experienced Solver
Posts: 80
Joined: Sat Jan 16, 2016 5:57 am

wxWebView with Chromium backend

Post by Anil8753 » Fri May 25, 2018 7:21 am

I need to do HTML/Angular development in my wxWidget desktop application (very similar to Electron https://electronjs.org/).

Looks like I should use wxWebViewChromium. I found a project https://github.com/sjlamerton/wxWebViewChromium/wiki that can serve my purpose but as per this project Wiki page, it has support for Windows only. My requirement is to have support for both Windows and MacOS. Could someone focus some light on this project or some other ways?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWebView with Chromium backend

Post by PB » Fri May 25, 2018 7:54 am

There is an open PR for merging wxWebViewChromium into wxWidgets codebase, see
https://github.com/wxWidgets/wxWidgets/pull/706

That is probably the closest how you can get for now...

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3409
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWebView with Chromium backend

Post by ONEEYEMAN » Fri May 25, 2018 2:16 pm

Hi,
You can actually try to compile it and if it works all around leave a comment for Vadim to merge it.

Thank you.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxWebView with Chromium backend

Post by Natulux » Wed Mar 27, 2019 2:51 pm

Hey guys,

this seems to be still an open topic. I tried this myself and for many hours now, but I only got confused so far.
PB wrote:
Fri May 25, 2018 7:54 am
There is an open PR for merging wxWebViewChromium into wxWidgets codebase, see
https://github.com/wxWidgets/wxWidgets/pull/706

That is probably the closest how you can get for now...
That pull request is still open and since I am not very experienced with git(hub) I struggled quite a bit with this.
To get the code, I eventually created a new local branch to my local wxWidgets project copy via git bash

Code: Select all

git fetch https://github.com/wxWidgets/wxWidgets pull/706/head:chromium
git checkout chromium
I compiled that "branch" on windows10 vs2015, which worked out of the box, and then tried to use the modified "webview" example. But this doesn't work:
missing external symbol ""char const * const wxWebViewBackendChromium" ([email protected]@3QBDB)"
I tried that with the newest master branch of the cef-project
https://github.com/chromiumembedded/cef-project
and I am providing all the libs asked for (which are already set up in the modified sample, I only needed to adjust the path):
C:\Widgets\lib\vc_lib\wxmsw31u_webviewchromium.lib
C:\Widgets\lib\vc_lib\wxmsw31u_webview.lib
C:\cef-project\third_party\cef\cef_binary_3.3538.1852.gcb937fc_windows32\Release\libcef.lib
C:\cef-project\libcef_dll_wrapper\Release\libcef_dll_wrapper.lib
Could anybody get this up and running? Any tips on how to tackle this?


Cheers
Natu

PS:
Instead of having again a custom wxWidgets version for the backend, I would rather have it included into my project, like this outdated approach:
https://github.com/sjlamerton/wxWebViewChromium
But I guess this is even more wishfull thinking?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3409
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWebView with Chromium backend

Post by ONEEYEMAN » Wed Mar 27, 2019 2:59 pm

Hi,
You should probably leave a comment on this PR about what you did and what the results are.
Hopefully Steve (Lamerton) is still around to look at it or maybe Tobias will be able to look at this PR (since he just tackled the HTTPS stuff).

Or try to send an e-mail to the wx-users ML and see if Steve is still there...

Thank you.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWebView with Chromium backend

Post by PB » Wed Mar 27, 2019 3:17 pm

Just a thought: Did you set wxUSE_WEBVIEW_CHROMIUM to 1 (the default seems to be 0)?

FWIW, I just tested it and could build and run the sample successfully. I used CMake (checked wxUSE_WEBVIEW_CHROMIUM and set wxBUILD_SAMPLES to "ALL") and MSVC 2017, shared release build.

I am not any good with GIT (I use TortoiseGIT), so I just cloned whole TcT2k's wxWidgets fork and switched to the chromium branch.

User avatar
doublemax
Moderator
Moderator
Posts: 13990
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWebView with Chromium backend

Post by doublemax » Wed Mar 27, 2019 3:42 pm

PB wrote:
Wed Mar 27, 2019 3:17 pm
I am not any good with GIT (I use TortoiseGIT), so I just cloned whole TcT2k's wxWidgets fork and switched to the chromium branch.
Offtopic: I'm not very good with GIT either, but i recently discovered https://git-fork.com which is very close to Tower (a commercial and probaly the best GIT client). And i think it's great.
Use the source, Luke!

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxWebView with Chromium backend

Post by Natulux » Thu Mar 28, 2019 8:00 am

Thanks for your input :-)
PB wrote:
Wed Mar 27, 2019 3:17 pm
Just a thought: Did you set wxUSE_WEBVIEW_CHROMIUM to 1 (the default seems to be 0)?
I tripped over that, but yes, I finally did set the flag. ;-)
PB wrote:
Wed Mar 27, 2019 3:17 pm
FWIW, I just tested it and could build and run the sample successfully. I used CMake (checked wxUSE_WEBVIEW_CHROMIUM and set wxBUILD_SAMPLES to "ALL") and MSVC 2017, shared release build.
Did you use the newest cef-version in your test? ( 3.3282.1735.g1e5b631 )

I think I should try cmake building myself. Good to know that you found a way to do it out of the box. It just has so many variables to play with:
cef-version, vs-version, building flags..
ONEEYEMAN wrote:
Wed Mar 27, 2019 2:59 pm
Hi,
You should probably leave a comment on this PR about what you did and what the results are.
Hopefully Steve (Lamerton) is still around to look at it or maybe Tobias will be able to look at this PR (since he just tackled the HTTPS stuff).

Or try to send an e-mail to the wx-users ML and see if Steve is still there...

Thank you.
I hope they are. It would be a shame if this project wouldn't make its way into wxWidgets after all this work. And the chromium backend might be the one backend, that survives them all.

Cheers
Natu

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWebView with Chromium backend

Post by PB » Thu Mar 28, 2019 8:38 am

Natulux wrote:
Thu Mar 28, 2019 8:00 am
Did you use the newest cef-version in your test? ( 3.3282.1735.g1e5b631 )
No, I did use the one CMake automatically downloads and installs. However, I do not think it has any effect on your linker error with wxWidgets' declared string....

I used CMake (CMake-GUI) because it is the simplest way to build wxWidgets library and samples, and it also has a very user friendly way of customizing all wxWidgets build options.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxWebView with Chromium backend

Post by Natulux » Tue Apr 02, 2019 7:22 am

PB wrote:
Thu Mar 28, 2019 8:38 am
Natulux wrote:
Thu Mar 28, 2019 8:00 am
Did you use the newest cef-version in your test? ( 3.3282.1735.g1e5b631 )
No, I did use the one CMake automatically downloads and installs. However, I do not think it has any effect on your linker error with wxWidgets' declared string....

I used CMake (CMake-GUI) because it is the simplest way to build wxWidgets library and samples, and it also has a very user friendly way of customizing all wxWidgets build options.
I tried to follow your steps, used the cmake GUI and a custom flag "wxUSE_WEBVIEW_CHROMIUM to 1".

First I checked Static build because this is what I actually want. It compiled 111 projects, and had errors on 7. The webview sample (chromiumized) was missing its cef libraries. So my cmake approach did not automatically download any cef data. I copied my cef data into "rdparty" according to the paths set for the linker, and there I was again:
"missing extern symbol: ""char const * const wxWebViewBackendChromium" C:\wxWidgets-chromium\samples\webview\webview.obj"

I then tried the Dynamic build (default). It compiled all wxwidgets projects, no errors. The cef libraries were still there, since I copied them before. But making the webview sample dynamic made it complain about static - dynamic missmatch (but why? even cef project is dynamic by default). Trying it static again leads to:
"missing extern symbol: ""char const * const wxWebViewBackendChromium" C:\wxWidgets-chromium\samples\webview\webview.obj"
I guess I need a fresh try with dynamic.


I still don't see my fault in this mess.
@PB: When you build the webview sample, do you only have one webview.cpp and it is ready to build or did you modify the sample in any way? I remember some chromium_cef1 and chromium_cef3 files from github (which I guess should be included into webview).

Thanks for your time.
Natu

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWebView with Chromium backend

Post by PB » Tue Apr 02, 2019 7:52 am

First, try a fresh start with a source tree and build outside the source directory.
Natulux wrote:
Tue Apr 02, 2019 7:22 am
I tried to follow your steps, used the cmake GUI and a custom flag "wxUSE_WEBVIEW_CHROMIUM to 1".
I did not do such a step, I just checked the wxUSE_WEBVIEW_CHROMIUM option under wxUSE tree (having checked "Grouped" and "Advanced" checkboxes next to "Search" control in CMake-Gui's GUI). Not sure if there is an actual difference though.
Natulux wrote:
Tue Apr 02, 2019 7:22 am
When you build the webview sample, do you only have one webview.cpp and it is ready to build or did you modify the sample in any way?
I did no modification to any files at all. I do not remember (I will check when I get to a computer with that build) if the sample source was separate, the executable certainly was.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxWebView with Chromium backend

Post by Natulux » Tue Apr 02, 2019 11:43 am

PB wrote:
Tue Apr 02, 2019 7:52 am
First, try a fresh start with a source tree and build outside the source directory.
Thanks for describing further.
I am almost certain, that I already fail on downloading the right repository. When I get the repo (from github) from TcT2k directly, the solution is not complete and cmake complains about it:
CMake Error at build/cmake/functions.cmake:448 (add_library):
Cannot find source file:
C:/wxWidgets_Chrome/src/png/png.c
[... and several more]
CMake Error: CMake can not determine linker language for target: wxpng
[... and several more]
So I add the missing projects from my original wxWidgets github repo, but that can't be the way it's supposed to be... or is it?

As for the static vs. dynamic building, I found the source where I read that I am supposed to use a dynamic build:
http://hokein.github.io/wxWidgets/class ... omium.html
But who knows, if this information is (still) valid. At least I could build wxWidgets (chromiumized) with the dynamic build without errors.

I will now try again from a fresh directory, dynamic build, newest cef build and I keep an eye out for the advanced flags in cmake GUI as you mentioned.

One last thing: You wrote, that RunScript() with the Chromium backend does not return values. Is that according to your knowledge still the case?

Thanks again!
Natu

[EDIT]:
I think last time I copied to much. This time I just got the source from the picture libs, that were missing, and after that cmake could run through without error. It was only after that, that cmake was downloading cef and set a new path variable:
CEF_ROOT C:/wxWidgets_Chrome/build/libs/webview_chromium/cef-source
I guess this was the missing piece. Gotta go on compiling ;-)

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWebView with Chromium backend

Post by PB » Tue Apr 02, 2019 12:24 pm

Natulux wrote:
Tue Apr 02, 2019 11:43 am
One last thing: You wrote, that RunScript() with the Chromium backend does not return values. Is that according to your knowledge still the case?
I did not "wrote it", it is a documented limitation of the back end and to my best knowledge it is still the case. I tried looking into it but it appeared to be difficult to implement, due to Chromium architecture (async, multiple threads/processes). OTOH, it seems to work with MiniBlink, too bad that MiniBlink is not a global audience friendly.

BTW, with Chromium PR, no manual copying whatsoever should be necessary. You just need to switch the branch cleanly and remember that 3rd party libs (such as libpng or libzip) are GIT submodules which need to be initialized.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Thu Aug 03, 2017 12:20 pm

Re: wxWebView with Chromium backend

Post by Natulux » Tue Apr 02, 2019 1:25 pm

PB wrote:
Tue Apr 02, 2019 12:24 pm
Natulux wrote:
Tue Apr 02, 2019 11:43 am
One last thing: You wrote, that RunScript() with the Chromium backend does not return values. Is that according to your knowledge still the case?
I did not "wrote it", it is a documented limitation of the back end and to my best knowledge it is still the case. I tried looking into it but it appeared to be difficult to implement, due to Chromium architecture (async, multiple threads/processes). OTOH, it seems to work with MiniBlink, too bad that MiniBlink is not a global audience friendly.
You wrote it, assuming you are PBfordev, who commented on that on GitHub. ;-)
Sry to confuse.
And yes, its a shame. MiniBlink is quite easy to set up, using imRekers API for wxWidgets. But you just can't go with it untouched, as it even has hardcoded chinese signs in popup context menus. I also found, that several modern HTML elements do not show properly in MiniBlink, especially with quite modern approaches like Quasar CLI. The sef sample browsers on the other hand do quite fine. I'd assume that MiniBlink just became a little outdated.
PB wrote:
Tue Apr 02, 2019 12:24 pm
BTW, with Chromium PR, no manual copying whatsoever should be necessary. You just need to switch the branch cleanly and remember that 3rd party libs (such as libpng or libzip) are GIT submodules which need to be initialized.
I am not sure if I can follow you. What do you mean by "Chromium PR"?
It would seem that I did not initialize those submodules then, though my manual copying of the source files did the same thing for me.
[EDIT]: I also couldn't use the git command on my files, because my current test dir is no git dir. I just downloaded the files as zip.

Unfortunately there is still some things going awry. I chose a different path as a build directory and as a result all the standard paths didn't find their compiled sources. I ended up copying my new build directory into the source dir.
Going on from that, the webview_chromium project cant find "wxmsw31u_webviewchromium.lib" and in fact I dont have such a file in my wxWidgets repo (I only have it in the master branch checkout). What I have is a "wxmsw31u_webview_chromium.lib". Is that supposed to be the one?

I still wonder how you could just build the whole thing from the get go.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3409
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWebView with Chromium backend

Post by ONEEYEMAN » Tue Apr 02, 2019 3:30 pm

Hi,
Because PB just cloned TcT2K repository and switched the branch appropriately. ;-)

BTW, I believe the actual WebView code is able to do RunScript() with return value. It just a Chromium that doesn't support it (yet?).

Thank you.

Post Reply