MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
437 stars 51 forks source link

[WinForms] NewBrowserVersionAvailable is not firing #2098

Open kirsan31 opened 2 years ago

kirsan31 commented 2 years ago

Description NewBrowserVersionAvailable is not firing when new version of runtime installed.

Version SDK: 1.0.1072.54 Runtime: 97.0.1072.62 -> 97.0.1072.69 Framework: WinForms OS: Win10

Repro Steps

We have 2 Evergreen Standalone Installers. 97.0.1072.62 and 97.0.1072.69 versions.

Install 97.0.1072.62 and run some sample WinForms app with code like below:

_webView2.CoreWebView2InitializationCompleted += _webView2_CoreWebView2Ready;
_webView2.Source = new Uri("about:blank");

private async void _webView2_CoreWebView2Ready(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
    if (!e.IsSuccess)
    {
        _logger.Error(e.InitializationException, "WebView2 Initialization Exception");
        return;
    }

    _logger.Info($"WebView2 ready, RuntimeVersion {_webView2.CoreWebView2.Environment.BrowserVersionString}.");
    _webView2.CoreWebView2.Environment.NewBrowserVersionAvailable += Environment_NewBrowserVersionAvailable;
}

private void Environment_NewBrowserVersionAvailable(object sender, object e)
{
    _logger.Warn($"NewBrowserVersionAvailable: current {_webView2.CoreWebView2.Environment.BrowserVersionString}; new {CoreWebView2Environment.GetAvailableBrowserVersionString()}");
}

In log you will see: WebView2 ready, RuntimeVersion 97.0.1072.62. Install 97.0.1072.69 - Environment_NewBrowserVersionAvailable will never fire. If we close (deinit) window with WebView2, wait several seconds and open it again, we will see WebView2 ready, RuntimeVersion 97.0.1072.69. in log.

Also, can some one explain the meaning of this phrase (from docs), it eludes me:

The event is only raised for new version from the same WebView2 Runtime from which the code is running. When not running with installed WebView2 Runtime, no event is raised.

AB#37952354

champnic commented 2 years ago

Thanks for the bug report @kirsan31! I've opened it on our backlog.

The note at the end means that it will only fire the event if the runtime being used and updated are the same channel (Canary/Dev/Beta) and using the evergreen version (not Fixed Version).