Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: Recent WebView2 runtime update causes WebView2 session to freeze for 15 seconds #4514

Closed
kirwan-safesurfer opened this issue Apr 30, 2024 · 22 comments
Assignees
Labels
bug Something isn't working regression Something used to work but doesn't anymore tracked We are tracking this work internally.

Comments

@kirwan-safesurfer
Copy link

kirwan-safesurfer commented Apr 30, 2024

What happened?

A recent update to the WebView2 runtime is causing a WebView2 session in my app to become inoperable at a specific stage of being in use. This takes place when my WinUI 3 app opens a WebView2 session (for my web app). I first noticed this with runtime version 124.0.2478.67, but it could be possible that the regression was first introduced with runtime version 124.0.2478.51. This is not reproduceable in the Edge app, only the runtime. The following video demonstrates the regression, causing a freeze in my web app for 15 seconds:

safesurfer-webview2-regression.mov

The next time I open the app and try again, the same freeze has a duration of only two seconds. The following video demonstrates the same process with no freezing, as per runtime version 123.0.2420.65:

safesurfer-webview2-working.mov

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

124.0.2478.67

SDK Version

1.0.2210.55

Framework

WinUI3/WinAppSDK

Operating System

Windows 10, Windows 11

OS Version

22631.3447

Repro steps

(Please see videos.)

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Regression in newer Runtime

Last working version (if regression)

123.0.2420.65

AB#51402837

@kirwan-safesurfer kirwan-safesurfer added the bug Something isn't working label Apr 30, 2024
@github-actions github-actions bot added the regression Something used to work but doesn't anymore label Apr 30, 2024
@vbryh-msft
Copy link
Contributor

  • Was you able to find what wv2 API is called "at specific stage of being in use", when it hangs?
  • Do you see any new crashes in Crashpad folder after the repro?
  • Can you repro it with our Sample app?

@ichijikuibo
Copy link

I appear to have the same problem and have found that is related to how I am initialising the Webview.

StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
var path = Path.Combine(localFolder.Path, "WebView\\"+webViewIndex);

Directory.CreateDirectory(path);
var env = await CoreWebView2Environment.CreateWithOptionsAsync(null, path, null);
webView = new WebView2();   
await webView.EnsureCoreWebView2Async(env);
webView.Source = new Uri(options.Environment.Url);
webViewFrame.Content = webView;

When I do a standard initiation not using CreateWithOptionsAsync the problem doesn't happen.

webView = new WebView2();   
await webView.EnsureCoreWebView2Async(env);
webView.Source = new Uri(options.Environment.Url);
webViewFrame.Content = webView;

I haven't tried any other combination yet, such as passing valid values as parameters 1 and 3 instead of null etc but I will.

@vbryh-msft
Copy link
Contributor

vbryh-msft commented May 14, 2024

@ichijikuibo I have tried to create wv2 in our .net sample app with:

var env = await CoreWebView2Environment.CreateAsync(null, path, null);
await webView.EnsureCoreWebView2Async(env);

and it creates wv2 without delays.

With your repro do you see the same freeze as reported for 15 seconds and it started to happen with 124.0.2478.x?
Which line of your code causes delay for you?
Do you have any env vars or registry keys which affect the logic of which runtime wv2 runtime is used, do you have any prerelease channels installed?

@ichijikuibo
Copy link

The delay doesn't happen in the code it happens when using the webview, I've done some experimenting tonight and seems that it is because I am changing the user folder if I pass null I get no delays. It seems to happen on the 2nd navigation (1st navigation is load the log in page, 2nd is log in or fail to login) but doesn't happen every time, the page starts to load but there is a delay before it fully loads.

image
The delay happened after loading.gif in this network log
image

There is nothing in the crashpad, I enabled chronium logging but it doesn't seem to be useful, I have tried it on 3 different computers all showing similar results and I am not sure about other webview versions as I have only started this project, I have only used the newest version I can try an older one though. I haven't been working with webview2 for very long so I don't have any prerelease versions installed or any reg/keys or enviroment vars.

Log files
freeze at 215451.txt
no freeze.txt

I will try find a public site tomorrow that has the same behaviour and make a sample project if I can.

@ichijikuibo
Copy link

I haven't been able to get a consistant situation where it freezes for a long period but I have one where it will freeze everytime, sometimes for 1 second and sometimes for 15+ seconds on the github login screen. The freeze only happens once per application run, if you go back and try again there is no freeze(queueing) at all.

image
The freeze in this case is always between the collect and stats requests in that screen shot, similar to how its always between the same 2 requests on mine.
SampleApp.zip

@wanghan123
Copy link

我们也遇到了同样的问题,我们怀疑是运行时更新导致的。在webview2 Runtime 123.0.2420.97版本正常,更新到124.0.2478.67版本开始出现首次登录卡顿(我们使用了22秒)。最新版webview2 Runtime 版本号125.0.2535.51经过验还是存在同样的问题

We're having the same issue and we suspect it's due to a runtime update. In webview2 Runtime 123.0.2420.97 version is normal, after updating to 124.0.2478.67 version started to freeze on first login (we used 22 seconds). The latest webview2 Runtime version is 125.0.2535.51. The same problem occurs after verification.

@vbryh-msft
Copy link
Contributor

@ichijikuibo @wanghan123 Can you please collect and share the etw traces when you repro the issue

@lflores-ms
Copy link
Contributor

@ichijikuibo @wanghan123 Network logs might be helpful as well, please see instructions to capture.

@ichijikuibo
Copy link

@vbryh-msft @lflores-ms I have an etw trace and network logs do you have an email I can send them too?

@vbryh-msft vbryh-msft added tracked We are tracking this work internally. and removed regression Something used to work but doesn't anymore labels May 29, 2024
@github-actions github-actions bot added the regression Something used to work but doesn't anymore label May 29, 2024
@vbryh-msft
Copy link
Contributor

vbryh-msft commented May 30, 2024

We can not repro the issue - but we got the traces, thank you @ichijikuibo. It looks like there should be dump file also generated in <UDF>\EBWebView\Crashpad\reports\ (more about dumps). If somebody who is reproing it and have a dump - could you please let us know

@ichijikuibo
Copy link

I haven't got anything in that folder have you tried changing the userdata folder? Changing it defiantly makes the problem worse which is why in that screenshot I am on WebViewuserfolder3 in the origional issue I noticed I was loading multiple tabs with all with different userdata folders to isolate the cookies so userdata folder being different than what it was the last time webview was run could be a factor.
image

@vbryh-msft
Copy link
Contributor

we have a fix in Canary 128.0.2636.0+. Can folks with repro please verify that it works as expected and there is no freeze?

@ichijikuibo
Copy link

That looks to be working now but I will try a bit more tomorrow I spent too long trying to get it to switch to canary before finally changing the folder in application.

@kirwan-safesurfer
Copy link
Author

@vbryh-msft Thanks for the update. Apologies for our delay in reply, as we haven't had time to debug further. Could you please reply with steps on how to install (or apply) the Canary version of WebView2? I can't seem to find a Canary WebView2 runtime binary, only stable ones.

@kirwan-safesurfer
Copy link
Author

kirwan-safesurfer commented Jun 11, 2024

@vbryh-msft I've created a wildcard DWORD value under HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\WebView2\ChannelSearchKind and set it to 1, installed the Canary version of Edge, uninstalled my app, restarted my workstation, rebuilt my app, and checked the DevTools console with navigator.appVersion, but it prints out 125.0.0.0. Am I missing something? I presume that my app isn't seeing a Canary runtime and is using the stable version instead, as per the documentation.

@ichijikuibo
Copy link

ichijikuibo commented Jun 11, 2024

@kirwan-safesurfer That didn't work for me either i set the folder in the app like this

StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
var path = Path.Combine(localFolder.Path, "WebViewuserfolder4\\");
CoreWebView2EnvironmentOptions envOptions = new CoreWebView2EnvironmentOptions();
envOptions.AdditionalBrowserArguments = "--log-net-log=C:\\logs\\Log.json";
Directory.CreateDirectory(path);
var env = await CoreWebView2Environment.CreateWithOptionsAsync("C:\\Users\\horse\\AppData\\Local\\Microsoft\\Edge SxS\\Application\\128.0.2642.0", path, envOptions);

@victorhuangwq
Copy link
Collaborator

@kirwan-safesurfer
Copy link
Author

After further attempts, I couldn't get my WebView2 session to change channel. Regardless, I've tested again on the latest WebView2 runtime (126.0.2592.81) on a few devices, and the issue looks to be resolved now. Thanks again for your help!

@vbryh-msft
Copy link
Contributor

Yes, we backported the fix to all channels. Thanks everybody for the help with debugging!

@vbryh-msft
Copy link
Contributor

@kirwan-safesurfer - we added short doc how to easy test fixes/try new features in Canary - if it does not work for you and you want us help to debug - feel free to open new issue about that. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something used to work but doesn't anymore tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

6 participants