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

webview2 loading time #1818

Closed
andreeasor opened this issue Oct 12, 2021 · 18 comments
Closed

webview2 loading time #1818

andreeasor opened this issue Oct 12, 2021 · 18 comments
Assignees

Comments

@andreeasor
Copy link

andreeasor commented Oct 12, 2021

Webview2 it's a bit slow to render the page. When I try to navigate to a simple webpage, it takes 15 s. This happens only the first time I call EnsureCoreWebView2Async method. Create a new WebView2 control with the same environment. This avoid the 15 seconds, the second time I call EnsureCoreWebView2Async.
Start initialization in the background is the only option. Not having the problem at all would be great.
I used version 1.0.992.28.

@champnic
Copy link
Member

@LiangTheDev @lingamy

@LiangTheDev
Copy link
Member

Is there any antivirus product installed on the machine? And if there is one, just for testing, does it make any difference if we exclude files under all sub folders of "C:\Program Files (x86)\Microsoft\EdgeWebView\Application" for that antivirus program?

@andreeasor
Copy link
Author

andreeasor commented Oct 19, 2021

I temporarily turned off the antivirus protection. It doesn't make any difference. Antivirus software is not interfering with the binaries loading and running.
No, this is not the cause.

@LiangTheDev
Copy link
Member

What's the configuration of the machine, is it a powerful machine or low end device? Like SSD or normal spinning hard disk, CPU speed, how many memory do we have, and OS version?
What is the WebView2 Runtime version and Edge browser version? Does it becomes a little faster if Edge browser of the same version is already running?
I assume that the slowness is coming from EnsureCoreWebView2Async itself, not loading the page later on, right?

You are right, start initialization in the background is the workaround. EnsureCoreWebView2Async is slow. 15s is a little too slow. Normally for this type of investigation, we take a perf trace using Windows Performance Recorder and analyze it. The trace file will be a large file. Let us know whether you are willing to take the trace and share the large trace file.

@andreeasor
Copy link
Author

SSD M.2
16GB DDR4
Core i5 8th generation
Windows 10 pro 20h2

WebView2 Runtime version : 94.0.992.50
Edge browser version : the same version, 94.0.992.50

I tried also with a fixed version ... the same loading time.
Microsoft.WebView2.FixedVersionRuntime.94.0.992.50.x64

Does it becomes a little faster if Edge browser of the same version is already running?
No

I assume that the slowness is coming from EnsureCoreWebView2Async itself,
not loading the page later on, right?
YES

I tried to set the Source property but I know that setting the Source will trigger initialization of the CoreWebView2, if not already initialized, ...the result is the same.

@LiangTheDev
Copy link
Member

The only "weakness" in the hardware is the CPU. 15s seems too slow with this configuration.

Is it possible to take a perf trace for this? The instruction on how to take a trace is at microsoft/microsoft-ui-xaml#5816 (comment). The trace file will be a large file that has to be shared via some cloud drive.

@andreeasor
Copy link
Author

The trace file is here https://1drv.ms/u/s!ArFZdFKviysTgX5CvMiOYCpAC-Ro?e=Cfxhgm

@LiangTheDev
Copy link
Member

From the trace, WebView creation was actually pretty fast, less than 1s. But the redirection from https://www.microsoft.com/ to https://www.microsoft.com/ro-ro/ took a long time. Not sure what's going on there.
I would suggest that we try to navigate to https://example.com instead of microsoft.com and see whether that loads faster.

I also see another navigation to about:blank right after navigation to https://www.microsoft.com/ is requested. Not sure whether this confused the underlying code, or where that comes from. Do we have "about:blank" anywhere in the code or markup?
Anyway, try to play around with how we navigate to the page. Like setting the Source to the url directly in the markup, which should automatically load the url as part of EnsureCoreWebView2Async. Sharing your related code might also help us repro the issue and figure out what's going on.

@andreeasor
Copy link
Author

I navigated to https://example.com instead of https://microsoft.com and the load is pretty fast, less than 2s. I tried with google.com, smartsheet.com and the result is the same ...15-20 seconds loading time.
I navigate to the page setting the Source to the url directly in the markup.

The app and 2 trace files for both scenarios, using https://example.com and using https://www.smartsheet.com are here:

https://1drv.ms/u/s!ArFZdFKviysTgX8VMdPnvcfR1Wjy?e=PC1YG1

@LiangTheDev
Copy link
Member

It seems to be network proxy related. Could you try to play around with OS proxy settings to see whether that makes a difference?

@LiangTheDev
Copy link
Member

Could you also share details of the OS proxy setting? If you could capture network log, that would be very helpful.

https://textslashplain.com/2020/01/17/capture-network-logs-from-edge-and-chrome/ has instruction on how to do that.
For WebView, you should be able to set OS environment variable WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS as "--log-net-log=%USERPROFILE%\Desktop\ReproNetlog.json --net-log-capture-mode=Everything", repro, and share the ReproNetlog.json file from Windows desktop.

@andreeasor
Copy link
Author

I'm using a VPN connection. I disconnected from the VPN conn and the load is pretty fast.
Is there a way to use webview2 and connect the way I want using VPN? Having this information is it still helpful to capture network log and send you the ReproNetlog.json file?
Thank you :)

@LiangTheDev
Copy link
Member

It would still be helpful if you could collect network log. That would confirm whether it is something we could improve in WebVeiw2 code or it is just that some request has to go through VPN and is slow.

@andreeasor
Copy link
Author

I share you 2 network log files: https://1drv.ms/u/s!ArFZdFKviysTggN6RYyvIHKfVePl?e=BnTAaQ

  1. from my PC with VPN connected
  2. from the PC I connect to remotely through VPN (on this pc we have the same loading time, 15-20 seconds)

@champnic
Copy link
Member

@andreeasor I took a quick peek, and looks like these logs are from the Edge browser. Are you seeing the same slowdown in the browser when navigating to microsoft.com? Are you able to get a network log from the WebView2?

@andreeasor
Copy link
Author

In the browser the loading is very very fast.
the network log from the WebView2 is here: https://1drv.ms/u/s!ArFZdFKviysTggacDmyURYBmO5NG?e=OIrs7W

@naarcini
Copy link

@andreeasor Hi, I'm a developer on the Edge networking team!

It looks like you have WPAD enabled in your proxy settings. WPAD defines a protocol for automatically finding a PAC file, which would in turn figure out a proxy URL.

In Chromium, the way this works is that we'll do a DNS lookup for "wpad". If this succeeds, we'll then try to retrieve a PAC file at http://wpad/wpad.dat. In your case, the DNS lookup for "wpad" is succeeding, but subsequent network call to retrieve the PAC file times out. This indicates that your network admin has misconfigured WPAD for Chromium. For startup to be fast on your VPN, the DNS lookup must fail OR the URL http://wpad/wpad.dat must be configured to return a PAC file.

The reason this is fast when you're not on VPN is probably that the DNS lookup for "wpad" fails, so we don't try to retrieve a PAC file. One way for you to make your WebView2 startup fast on your machine is to disable WPAD in your proxy settings.

There's much more detail about this stuff in my colleague's blog post:
https://textslashplain.com/2020/07/14/web-proxy-auto-discovery/

@andreeasor
Copy link
Author

andreeasor commented Nov 1, 2021

Disable proxy settings in Windows - this is the solution!
Unintended or incorrect proxy settings can cause this type of issue, unable to load any webpage or very slow when loading webpages.
Thank you for your efforts. Thanks for all the support. I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants