valinet / ExplorerPatcher

This project aims to enhance the working environment on Windows
GNU General Public License v2.0
22.22k stars 976 forks source link

WebView2 CPU Usage Issue from Weather Widget #1289

Open HenryTheVacuum opened 1 year ago

HenryTheVacuum commented 1 year ago

When using the Weather Widget on the taskbar, Microsoft's Edge WebView2 service will glitch/hang and use like 15% CPU consistently which leaves my laptop's processor running at 95 degrees.

There are several processes under COM Surrogate in the task manager that support the widget (Several WebView2 services).

Ending or restarting the widget fixes the issue, however I'm not sure what causes it as it takes several hours for the issue to come up again.

I have changed the update frequency to every minute to see if I can catch something sooner that might be triggering the constant CPU usage.

HenryTheVacuum commented 1 year ago

weather_hangs

So it appears sometimes after resuming from sleep, the program hangs when trying to reconnect? Although you can't see it in the screen shot, the contents of the box flickers like crazy which likely is causing the CPU to hang.

Could also be something to do with the DPI scaling as the box content is oversized and is trying to use the laptop screen scaling instead of transitioning to the external monitor.

tylerl commented 12 months ago

I've experienced something similar, tried to debug it, and eventually just gave up and disabled the weather widget. Basic details are as follows:

After resuming from sleep overnight, the laptop started to heat up. Task manager showed that the widget was running 30% CPU (on a 12-core system; so 100% on 3+ cores) and had around 4GB of private bytes in memory. Most likely whatever was going wrong was mired in javascript.

Reproducing the effect on demand is practically impossible; sleeping the device and resuming after a minute or two won't do it. My guess is that there's an interaction between the outdated state of the application host and some update on the remote website that happens during sleep.

One possible solution might be to completely drop and reload the weather host after resuming from sleep. The fact that it had managed to run up 4GB of memory usage suggests that periodically starting over is a warranted feature anyway.

Obviously the "correct" solution would be fetching the weather data from an API and displaying it locally so you actually get to control your runtime (and don't incur a 400MB memory penalty under even the best of circumstances). But heaven knows I don't feel like writing it. So I totally get why showing someone else's webpage is where this goes.

pyrates999 commented 11 months ago

If this is happening to you and you have a laptop, check if it has modern stand by. It might be related to this. Is your battery low in power when this also happens?

harimgs commented 11 months ago

same thing happening for me, weather widget keep consuming 15~30% cpu usage forever, so I had to disable the weather widget.

Process name WebView2: weather - Google Search under COM Surrogate showing 15~30% CPU usage forever.

Killing the process works for few hours, but it starts again after few hours.

Bec-de-Xorbin commented 7 months ago

If this is happening to you and you have a laptop, check if it has modern stand by. It might be related to this. Is your battery low in power when this also happens?

It's indeed related. It only happens for me in a laptop which only has a S3 standby. With a Modern Standby laptop it works normally. It doesn't matter if you are on a battery or plugged in.

Amrsatrio commented 6 months ago

image Can confirm. 22621.2506

pyrates999 commented 6 months ago

Since you're running a preview update, please install the latest pre-release version of EP.

Amrsatrio commented 6 months ago

I have the latest everything even my unreleased changes......... 🤦

aemsx commented 6 months ago

same on W11 22621.2428 EP 22621.2428.59.1

twistios commented 5 months ago

same for me on W11 22631.2861 (ExplorerPatcher 22621.2506.60.1)

GammaScorpii commented 5 months ago

Also happens when coming out of S4 hibernation overnight

alex7654 commented 4 months ago

Similar effect here, using latest version of EP. Low CPU usage after weather widget loaded. But when clicking the mouse inside a certain widget area, CPU load rises dramatically. CPU load won't go down until restarting EP or disable and then again enable weather option in EP. Clicking anywhere outside the marked area does no harm. See attached screenshots.

before_clicking area after_clicking

egorbunovs commented 4 months ago

Same issue for me as well

pyrates999 commented 4 months ago

If this is happening to you, please include the following:

  1. windows version and build number. You can find this by running winver.
  2. EP version. Open up the EP properties application and go to about to find it.
alex7654 commented 4 months ago

Sorry, I should have included it in my comment. Here is the information requested: grafik grafik

pyrates999 commented 4 months ago

Thank you.

lucspe commented 4 months ago

I have the same issue with EP when resuming from sleep or hibernation on my laptop, except that COM Surrogate & child processes use about 30-35% of CPU.

Restarting File Explorer (using the link in bottom left of EP options menu) solves the CPU usage issue until the laptop goes to sleep / resumes, then the issue manifests itself again.

I am running W11 23H2, build 22631.3085 with EP 226212.2861.62.2.

Jaxel commented 4 months ago

I'm having the same issue on my DESKTOP. I do not use sleep mode and leave my PC on 24/7. The only thing that turns off is my monitor.

EP 22621.2428.59.1 W11 Pro 22H2 22621.3007

pyrates999 commented 4 months ago

I'm having the same issue on my DESKTOP. I do not use sleep mode and leave my PC on 24/7. The only thing that turns off is my monitor.

EP 22621.2428.59.1 W11 Pro 22H2 22621.3007

Please update EP: https://github.com/valinet/ExplorerPatcher/releases/tag/22621.2861.62.2_9b68cc0

Jaxel commented 4 months ago

I'm having the same issue on my DESKTOP. I do not use sleep mode and leave my PC on 24/7. The only thing that turns off is my monitor. EP 22621.2428.59.1 W11 Pro 22H2 22621.3007

Please update EP: https://github.com/valinet/ExplorerPatcher/releases/tag/22621.2861.62.2_9b68cc0

After updating the issue still persists.

pyrates999 commented 3 months ago

Ok, thanks. Please wait for a developer to respond.

ImportTaste commented 3 months ago

I don't see anyone here claiming this is happening on Windows 10, so I'd like to say that this is indeed happening to me on Windows 10:

image

Jaxel commented 3 months ago

Even after upgrading everything, the issue still persists. I notice it because occasionally I will hear my PC fans raging, even while I am not even at my computer. So I go check it out and see the weather widget is the problem.

I ended up completely disabling the weather widget.

ImportTaste commented 3 months ago

Even after upgrading everything, the issue still persists. I notice it because occasionally I will hear my PC fans raging, even while I am not even at my computer. So I go check it out and see the weather widget is the problem.

I ended up completely disabling the weather widget.

If I had to guess, this is probably happening due to a callback leak.

twistios commented 3 months ago

Just now I (again) got a very similar problem. Instead of soon after hibernation it happend "randomly" about ~20 minutes after returning from hibernation. I walked away from my machine and when I came back I could here the fans spinning fast so I immediatly knew what was happening. It was still COM Surrogate but this time it was not the weather but the "gpu process". Not only did it cause a high cpu utilisation but also "ate" my RAM away.

Command line arguments of two most hungry processes:

"C:\Program Files (x86)\Microsoft\EdgeWebView\Application\121.0.2277.112\msedgewebview2.exe" --type=gpu-process --noerrdialogs --user-data-dir="C:\Users\user\AppData\Roaming\ExplorerPatcher\ep_weather_host\EBWebView" --webview-exe-name=DllHost.exe --webview-exe-version=10.0.22621.1 --embedded-browser-webview=1 --embedded-browser-webview-dpi-awareness=2 --no-appcompat-clear --gpu-preferences=WAAAAAAAAADgAAAMAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAYAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --mojo-platform-channel-handle=2092 --field-trial-handle=2080,i,8537857491189957101,15380455410726052139,262144 --enable-features=MojoIpcz,msSingleSignOnOSForPrimaryAccountIsShared --variations-seed-version /prefetch:2 /pfhostedapp:1e9f6608ee9db5c89957a60288a87d7536191c35
"C:\Program Files (x86)\Microsoft\EdgeWebView\Application\121.0.2277.112\msedgewebview2.exe" --type=renderer --noerrdialogs --user-data-dir="C:\Users\user\AppData\Roaming\ExplorerPatcher\ep_weather_host\EBWebView" --webview-exe-name=DllHost.exe --webview-exe-version=10.0.22621.1 --embedded-browser-webview=1 --embedded-browser-webview-dpi-awareness=2 --allow-insecure-localhost --no-appcompat-clear --lang=en-US --device-scale-factor=1.25 --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=11 --js-flags="--harmony-weak-refs-with-cleanup-some --expose-gc --ms-user-locale=" --time-ticks-at-unix-epoch=-1707948004568474 --launch-time-ticks=134328812311 --mojo-platform-channel-handle=4968 --field-trial-handle=2080,i,8537857491189957101,15380455410726052139,262144 --enable-features=MojoIpcz,msSingleSignOnOSForPrimaryAccountIsShared --variations-seed-version /pfhostedapp:1e9f6608ee9db5c89957a60288a87d7536191c35 /prefetch:1

explorer_patcher_high_cpu_ram This is a picture that shows the COM surrogate utilisation of CPU and RAM.

I also created a dump of the two processes (each about >3GB). I could upload them but my network connection is very slow so it would take ages. Maybe I will try to analyse them myself.

Beaverhoosen commented 2 months ago

Similar effect here, using latest version of EP. Low CPU usage after weather widget loaded. But when clicking the mouse inside a certain widget area, CPU load rises dramatically. CPU load won't go down until restarting EP or disable and then again enable weather option in EP. Clicking anywhere outside the marked area does no harm. See attached screenshots.

before_clicking area after_clicking

EP Version 22621.3296.64.1 still does this. Clicking anywhere inside the weather display area will consume 10+% of the CPU until the weather COM process is End Task(ed).

USING: Windows 11 ver 22H2 (0S Build 22621.3296)

pyrates999 commented 2 months ago

I don't see anyone here claiming this is happening on Windows 10, so I'd like to say that this is indeed happening to me on Windows 10:

image

This also happens to me on windows 10. If I click on any graphic in the popup weather window, the cpu usage goes up. So I don't enable the weather feature in the taskbar.

Mayome commented 2 months ago

Hey, EP 22621.3296.64.1, Win 11 Pro (ver 23H2 build 22631.3296) here, memory use goes to space even when widget is unclicked on the taskbar (up to 1.2gb ram out of 8gb), regardless if the widget is loaded or not (sometimes news is not switched to weather, dunno if it happens after standby or at other times as well).

alex7654 commented 1 month ago

I updated to ExplorerPatcher version 22621.3296.64.1 and now CPU usage is absolutely normal, even when clicking into that certain areas. When the window is not opened, then there is no noticeable CPU usage at all.

This issue seems to be fixed, at least for my configuration and at this point in time.

This is my current Windows version: Windows 11 23H2 Build 22631.3296

alex7654 commented 1 month ago

Bad news: After waking the PC from sleep mode today, the CPU load was at roughly 75% soaked up by webview2. The weather widget flickered and displays something like "Connection lost afer sleep" (or similar).

After restarting Explorer Patcher, it works ok, but I guess it will throw the same issue tomorrow morning.

pyrates999 commented 1 month ago

can you disable the weather widget and put your pc to sleep and see if this still happens after it wakes from sleep mode?

alex7654 commented 1 month ago

I now put the PC into sleep for about 60 seconds twice, the first time with weather widget disabled, the second time with weather widget enabled.

In the first case the weather widget worked well after enabling it. In the second case it surprisingly also worked well right after waking the PC.

Can there be any difference in how log the PC was sleeping?

Today evening I will put the PC to sleep again with weather widget enabled. I will report back tomorrow, what happend after waking the PC after it slept all night long.

pyrates999 commented 1 month ago

This might be causing it: https://www.thewindowsclub.com/windows-laptop-battery-drains-in-sleep-mode

If it's a laptop, is the battery also low in power when you wake it up from sleep mode?

alex7654 commented 1 month ago

Thanks for the input. I tested it on desktop computers, not on laptops.

Strangely, today after waking the PC from sleep mode, everything worked well (weather widget enabled). The PC was in sleep several hours longer as it usually is over night.

It seems non-reproduceable to me. Maybe it was just a one-time-issue. I now also tested it on two other PCs (same models) successfully. It seems to work well for the moment.

Nevertheless I will keep testing sleep with weather widget enabled on these 3 PCs for the next few days.

ImportTaste commented 1 month ago

I get this problem on desktop and I've effectively forced my system to never even be able to sleep or hibernate.

It may be partially caused by the way it renders the page itself.

It could be affected by certain types of weather it's reporting, which would explain why it's difficult to reliably replicate.

pyrates999 commented 1 month ago

check what sleep mode your pc supports: https://www.windowscentral.com/how-determine-power-sleep-states-supported-windows-10

alex7654 commented 1 month ago

I tested that behavour an all our 10 PCs. All are the same models. Two of them showed that issue after wake. I will attach a screenshot of what the weather widget looks like. Screenshot 2024-04-14 095809

Here are my supportet sleep modes: Screenshot 2024-04-14 101532

pyrates999 commented 1 month ago

Ok, so it looks like this requires EP to check if the weather is unable to be loaded due to network interruption. Or at the very least, add a refresh button inside the window that shows the weather info.

twistios commented 1 month ago

weather_hangs

So it appears sometimes after resuming from sleep, the program hangs when trying to reconnect? Although you can't see it in the screen shot, the contents of the box flickers like crazy which likely is causing the CPU to hang.

Could also be something to do with the DPI scaling as the box content is oversized and is trying to use the laptop screen scaling instead of transitioning to the external monitor.

I can confirm that the same is happening to me too (the window is flickering). Something that I was able to see is that there is some error code at the bottom: ERR_IO_NETWORK_SUSPENDED.

explorer_patcher_high_cpu_StackGPUProcess This was the Stack for the GPU-Process (at some point, other data is from some minutes later). I was able to see that the GPU-Process was the main problem, so I have tried to collect data about it. The GPU-Process did not have any disk or network activity so it seems to only do communication to other processes.

explorer_patcher_high_cpu_GPUUsageGPU This is the GPU-Usage for the GPU-Process.

explorer_patcher_high_cpu_ThreadsGPUProcess This is the CPU-Usage. ProcessExplorer shows different numbers than TaskManager (about 20-40% instead of the 5% shown here)

explorer_patcher_high_cpu_Taskmgr Screenshot of TaskManager in the situation.

explorer_patcher_high_cpu_PerformanceGPU This is the Performance-Window for the GPU-Process.

I also created fresh dumps, but I do not know how to analyse them.

twistios commented 1 month ago

I tested that behavour an all our 10 PCs. All are the same models. Two of them showed that issue after wake. I will attach a screenshot of what the weather widget looks like. Screenshot 2024-04-14 095809

Here are my supportet sleep modes: Screenshot 2024-04-14 101532

My Device does only supports

I normally use Hibernation when the problem arrises.

pyrates999 commented 1 month ago

I suspect that this is happening because it's trying to access the url for the weather when there is no network connection available. So it keeps trying, causing high cpu usage.

alex7654 commented 1 month ago

When I woke the PCs this morning, one of them showed "Contacts" instead of "Weather" (see screenshot). After disabling and re-enabling weather in the ExplorerPatcher options, weather is shown correctly again. That weather widget is full of surprises :).

grafik

pyrates999 commented 1 month ago

Next time, open up task manager and kill explorer.exe and then run task manager again and run explorer.exe. See if that fixes it.

alex7654 commented 1 month ago

Just a brief update: Today both test PCs showed the original issue (high CPU load after wake). Yes, killing explorer.exe and than running explorer.exe via task manager makes it work again.

pyrates999 commented 1 month ago

Ok, thanks. It's been confirmed by a developer earlier.

ImportTaste commented 1 month ago

I suspect that this is happening because it's trying to access the url for the weather when there is no network connection available. So it keeps trying, causing high cpu usage.

Might be more than just a network outage that causes retries, like the destination not responding in a timely manner. I have pretty consistent uptime on my ISP but I notice leaving the weather widget running for 24 hours has it using up quite a bit of CPU.

pyrates999 commented 1 month ago

Not a network outage. I meant while your computer is waking up from sleep mode, the network connection has not re-established itself yet, and EP is trying to get the weather at this time.

Hence, I suggest a refresh button for when this occurs and EP doesn't retry when this happens.

ImportTaste commented 1 month ago

Not a network outage. I meant while your computer is waking up from sleep mode, the network connection has not re-established itself yet, and EP is trying to get the weather at this time.

Hence, I suggest a refresh button for when this occurs and EP doesn't retry when this happens.

I keep every form of sleep and hibernation disabled in the BIOS and in Windows. I just turn the monitor off and on. It still happens to me regardless.

pyrates999 commented 1 month ago

Thank you for the input.

ndg8743 commented 3 weeks ago

had a similar issue where chrome, discord, etc all crashed a couple times for the day I get the following error: Windows successfully diagnosed a low virtual memory condition. The following programs consumed the most virtual memory: msedgewebview2.exe (6036) consumed 5217705984 bytes, msedgewebview2.exe (11768) consumed

Did update to the prerelease and seems good for now, will update if I get more crashing