MBS WebView2 Experiences

Some random notes after experimenting with the (so far) wonderful WebView2 control, which allows you use the modern Edge browser engine in x64 Windows apps. I’m using MBS 22.2 and Xojo 2022R1.1.

  • overhead is very small: the DLL included in the build is under 400KB in size
  • some of the defaults are not as per documentation, for example isScriptEnabled is listed as defaulting to True, but in my tests it’s false, so it took me a while to figure out why my Javascript wasn’t running. See Monkeybread Xojo plugin - DesktopWebView2ControlMBS properties @Christian_Schmitz perhaps you can either change the default or the documents to be consistent?
  • there doesn’t seem to be any sort of document loading % progress event? (not that those are very useful)
  • WebView2 works after the application has been packed (see Xojo 2022 - Single File EXE - 64 bit Application Packers) although there are some limitations (file:/// URLs don’t work, but normal http or https URLs do…)

Well, the isScriptEnabled property is documented by Microsoft to be true by default.
I can check.

I think I see the problem?
On a new window, when I drag a WebView2MBS control to the window, all the defaults are true in the IDE:

But I was using an old project, and I may have taken an existing control and changed the Super from WKWebViewMBS to WebView2MBS. That naturally may have lost the default settings.

I’m seeing another issue.
You can set the DefaultBackgroundColor so that the control doesn’t have a white flash, but It seems to only work on the 2nd time - the first time you see a big white flash, regardless of the color.

@Christian_Schmitz here’s a demo project that shows it:

Edit to add:

I found a workaround, which is to move the control offscreen, then make it visible, then move it back onscreen on a 100msec timer. That seems to avoid any flash.

1 Like

That clearly looks to be a problem in Xojo.
They should all not be on or off. Some on, some off.

You can’t really change from Mac Control to Windows Control and expect properties to come over.