-
Notifications
You must be signed in to change notification settings - Fork 64
Description
What happened?
I ran WinForms and Tauri applications on a Windows 10 64 bit system computer and found that the startup speed was very slow, taking over 20 seconds to start. After investigation, it was found that it is related to whether it is running as an administrator.
Here is an example of WinForm:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Web.WebView2.Core;
namespace webview2test
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
InitializeAsync();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
private async void InitializeAsync()
{
this.Text = "init";
var webView = new Microsoft.Web.WebView2.WinForms.WebView2();
webView.Dock = DockStyle.Fill;
this.Controls.Add(webView);
this.Text = "EnsureCoreWebView2Async: ";
try
{
await webView.EnsureCoreWebView2Async(null);
this.Text = "IsZoomControlEnabled";
webView.CoreWebView2.Settings.IsZoomControlEnabled = false;
this.Text = "AreDevToolsEnabled";
webView.CoreWebView2.Settings.AreDevToolsEnabled = false;
string htmlContent = @"<html> <head> <title>time</title> <style> body {{ display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: linear-gradient(to right, #1a2a6c, #b21f1f, #fdbb2d); font-family: Arial, sans-serif; color: white; }} .time-container {{ text-align: center; background: rgba(0,0,0,0.5); padding: 2rem; border-radius: 15px; box-shadow: 0 0 20px rgba(0,0,0,0.5); }} .time {{ font-size: 3rem; font-weight: bold; letter-spacing: 3px; }} .date {{ font-size: 1.5rem; margin-top: 1rem; opacity: 0.8; }} </style> </head> <body> <div class='time-container'> <div class='time'>hello</div> </div> </body> </html>";
this.Text = "NavigateToString";
webView.NavigateToString(htmlContent);
this.Text = "NavigationCompleted";
webView.NavigationCompleted += (sender, e) =>
{
if (e.IsSuccess)
{
this.Text = "loaded: " + webView.Source;
}
};
}
catch (Exception ex)
{
MessageBox.Show("init fail: " + ex.Message, "error");
}
}
}
}
When running programs directly on a problematic PC, the program can start normally; When running the program with administrator privileges, the following code await webView.EnsureCoreWebView2Async(null); wait for 20 seconds before loading the HTML until you see the hello string.
I tried to turn off the proxy on my computer, but it didn't work. It is normal on other computers of the same model(3 seconds), but it can be reproduced on my own computer(over 20 seconds).
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
133.0.3065.92
SDK Version
No response
Framework
Winforms
Operating System
Windows 10
OS Version
19045.5965
Repro steps
It seems that the fault can only be reproduced on the computer in my possession, and when running the application as an administrator, it can be reproduced. And it can be replicated every time the application is launched, regardless of whether the computer is restarted or not.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response