WebView2 working without WebView2 Runtime - webview

we trying to use WebView2 without WebView2 Runtime (because of it´s 100 MB size and distributing it to clients).
It was tested on 2 PC´s. Both of them have same version of Edge.
On PC1 WebView2 is not working whithout WV2 Runtime, on PC2 is working fine.
Do you have please any clue where can be a problem, why on PC1 is not WebView2 working? (PC1 is used for programming, PC2 no).
Thank you

You can use a fixed Version of WebView2 and by this make sure that your programm works on every PC even if they dont have the runtime installed.
Here you can download the fixed version you prefer:
https://developer.microsoft.com/de-de/microsoft-edge/webview2/
After you downloaded it you need to decompress the file into a folder of your choice.
You can do this with the command-line command:
expand {path to the package} -F:* {path to the destination folder}
Now you should have a folder with an executable runtime for WebView2. With the following code you can say where the path of this "executable folder" is.
var webViewEnvironment = await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync("Path of the executable folder"), ("Path where you want the Cache to be saved")));
await webView2.EnsureCoreWebView2Async(webViewEnvironment);
With this you don't need to install the WebView2 Runtime

The runtime is required for WebView2 (with the special exception that insider builds of Edge will provide it). So the answer is that you cannot use WebView2 without the WebView2 Runtime.

To run any WebView2 based applications pre-requisite is to have WebView2 Runtime available on the host machine.
There are two possibilities of running a WebView2 based application
So for your question
Do you have please any clue where can be a problem, why on PC1 is not
WebView2 working? (PC1 is used for programming, PC2 no).
There could be a possibility that Evergreen WebView2 Runtime would already be present on host system (Where app runs).
Also related to availability of Evergreen WebView2 runtime -
In June 2022, Microsoft announced that it would make the WebView2
runtime available to all Windows 10 devices running at least April
2018 updates.
So if you have Windows 10 with 2018 updates or Windows 11 you would be having evergreen WebView2 runtime present.
Advice:
To be sure that your application runs on systems not having Evergreen WebView2 runtime already installed
supply fixed runtime along with your applications as extra payload.
Use webview2 installer during the application start after checking WebView2 runtime availability ( would require elevated privileges )

Related

RAD Studio 10.4.2 Community Edition cannot make a new delphi project

Submenu File -> New contains only "Other..." and "Customize" items.
How to correct this?
My OS is Windows 10.0.17763.107.
Old version is 10.2 with same problem.
Installed new version 10.4.2, in process of installation of Delphi Community, I have error at Roboto Font downloading:
[403] Forbidden
I pinged this address of Getit found in the registry: https://getit-104.embarcadero.com
It is not responding! Ok, changing to getit.embarcadero.com, the result is negative.
It seems that your Delphi installation hasn't finished properly. Either it was interrupted or Licence manager didn't manage to verify your Community licence properly.
You could try fixing your licence using Licence Manager that you can find inside Delphi folder. If my memory serves me correctly it is located withing BIN subfolder (don't have access to development machine at the moment to verify).
But if the installation proces itself is getting interrupted you might want to download ISO installation instead of Online installation. When installing latest version of Delphi I had to use ISO installation since Web installation kept loosing connection. I suspect my AV Software (ESET Internet Security) with integrated firewall might be the cause.

TEdgeBrowser Canary requirement

I tested TEdgeBrowser in RAD Studio 10.4.2 Sydney. Dropping the component onto a Form in C++Builder and then calling:
EdgeBrowser1->Navigate("https://www.stackoverflow.com/");
This results in an error on my development machine:
Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.
I have placed WebView2Loader.dll (from C:\Program Files (x86)\Embarcadero\Studio\21.0\Redist\win32\) into the project's executable folder, so that could not have been the cause of the error.
After that, I installed Edge Canary, and then it started working without errors.
However, if I compile the same project in Release configuration, and then run on another system which only has a stable installation of the Microsoft Edge browser and doesn't have Edge Canary installed, it all works.
But, if I run the same Release build on my build system, it fails to load (probably because of the same reason as the Debug build - it can't find the Canary installation).
I tested TMS's TAdvWebBrowser component, which doesn't have this requirement, and it works on both systems without installing Edge Canary. But I'd prefer to use TEdgeBrowser instead, to avoid an unnecessary dependency on a third party component.
What is the reason for this odd behavior for TEdgeBrowser, and does the same happen in RAD Studio 11 Alexandria? Can this be avoided so it works with a stable Edge installation on both systems?
EDIT: I later discovered that there is this property:
EdgeBrowser1->BrowserExecutableFolder = "C:\\Program Files (x86)\\Microsoft\\EdgeCore\\101.0.1210.53";
With that, all works. But, according to the documentation (Using TEdgeBrowser Component and Changes to the TWebBrowser Component), it should automatically locate the current version of the WebView2 control on the system. It does this on one system, but not on the development system.
TEdgeBrowser requires WebView2 Runtime in order to operate. More details on MS Edge Documentation website.
WebView2Loader.dll should be loadable by your application, in the same folder, known path or registered in path environment variable. Latest version is available on NuGet. Nupkg is a zip archive. Look in build\native\ folder.
TEdgeBrowser.BrowserExecutableFolder should point to WebView2 runtime folder in case of fixed version.
Fixed version distribution, placed inside your application folder seems the preferred way on your scenario.
MS claims that evergreen version will be distributed by default in next Windows versions.

What DLLs do I need for Delphi to run WebView2

I'm running WebView2 in my Delphi 11.1 application.
On my dev machine (Win 11), it works normally. It works on test PC1(Win 10), but when I try running it on the other PC (also Win 10) it doesn't load the page.
All PCs have Microsoft Edge WebView2 Runtime (ver. 99.0.1150.39)
Is there any list of DLLs needed, or can someone provide one.
Not every Windows installation comes pre-loaded with the WebView2Loader.dll required for WebView2 Runtime. You will need to distribute the file with your application. The WebView2 Runtime must be included in the main project directory distributed with the source code.
There are two different ways to distribute WebView2 Runtime with your application.
Fixed Version - Package a fixed version of WebView2Loader.dll to be distributed with your application. Download here.
Evergreen - Package the Evergreen Bootstraper to automatically update the required binaries, or package the Evergreen Standalone Installer to be invoked with the installer/updater for offline use-cases. Download here.
The quickest solution would be to add a fixed version of WebView2Loader.dll to the Delphi project directory.
A more detailed description by Microsoft is available for reference to better understand distributing applications with WebView2 Runtime.

Failed to initialise Edge browser control

Having a hard time attempting to run an example how to use TEdgeBrowser component on Windows 10.
Using the latest RAD Studio 10.4.1 (27.0.38860.1461)
The example is located under this path:
c:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\Object Pascal\VCL\WebBrowser\Edge\
Attempting to start results in "Failed to initialise Edge browser control".
What I tried:
Installed the latest stable Edge version (88.0.705.68 (Official build) (64-bit))
Downloaded and installed the runtime from
https://developer.microsoft.com/en-us/microsoft-edge/webview2/
Downloaded this:
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.705.50
Extracted WebView2Loader.dll and placed into the same folder where the compiled executable of the above demo resides
The documentation on:
http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component
Seems to be out of date and refers to old 0.9.430 version. I have actually previously used Edge Canary release with that version of WebView2Loader.dll before and that has worked, but the stable version of Edge Chromium was released in the meanwhile, assuming there were breaking API changes.
So, is it even possible to use TEdgeBrowser with Edge Chromium at this point because from all that I've tried it seems pretty hopeless? To me it looks like it is hard-coded against 0.9.430 and RAD Studio 10.4.1 wasn't updated. Is there a workaround of any sort?
for solving this copy "WebView2Loader.dll" to your output path
TEdgeBrowser requires WebView2 Runtime in order to operate. More details on MS Edge Documentation website.
WebView2Loader.dll should be loadable by your application, in the same folder, known path or registered in path environement variable. Latest version is available on NuGet. Nupkg is a zip archive. Look in build\native\ folder.
TEdgeBrowser.BrowserExecutableFolder should point to WebView2 runtime folder in case of fixed version.
MS claims that evergreen version will be distributed by default in next Windows versions.

Microsoft.WebView2 & Edge

I'm trying to use Microsoft.WebView2 from microsoft.web.webview2.0.9.579.nupkg (TEdgeBrowser example from Delphi 10.4 Version 27.0.38860.1461)
This version works with canary or beta versions of Edge only. With release of Edge I got an error message Could not find Edge installation. Do you have a version installed that's compatible with this WebView2 SDK version?
Documentation says about canary versions of Edge only.
Which version of Microsoft.WebView2 will work with Edge release ?
I am not available with the Delphi app but I try to make a test with the Windows Forms app. In which, I download the webView2 1.0.664.37 using Nuget package manager and I try to test it with the MS Edge Version 87.0.664.60 (stable version at present).
Based on my test result, it did not work with the MS Edge Version 87.0.664.60 (stable version at present).
So as per this test result, the webView2 1.0.664.37 may not work in your Delphi app with the current stable version of the Edge browser (Version 87.0.664.60). You can test it in your Delphi app to verify it.
I make further tests and found that if I install the webView2 Evergreen Standalone Installer then it is working on my side. You can notice that there is a minor difference in the version of the webView2 runtime and MS Edge stable browser.
So if you are available to use the webView2 runtime then you can make a test with it.
If you cannot use the webView2 runtime and webView2 1.0.664.37 also not working in your Delphi app then I suggest you keep using the MS Edge Canary or Dev version with the webView2.

Resources