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 leaks old msedgewebview2.exe processes with every page change #9088

Closed
sude22 opened this issue Nov 16, 2023 · 6 comments
Closed

WebView2 leaks old msedgewebview2.exe processes with every page change #9088

sude22 opened this issue Nov 16, 2023 · 6 comments
Labels
area-WebView bug Something isn't working needs-author-feedback Asked author to supply more information. needs-triage Issue needs to be triaged by the area owners team-Controls Issue for the Controls team

Comments

@sude22
Copy link

sude22 commented Nov 16, 2023

Describe the bug

A WinUI3 app with shell navigation. Several pages use the WebView2 control.
A new instance of "msedgewebview2.exe" is created every time the page is changed, even the GC never clears it.

Steps to reproduce the bug

Change between the pages

Expected behavior

The old instances should be cleared

Screenshots

grafik

NuGet package version

WinUI 3 - Windows App SDK 1.4.2: 1.4.231008000

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

@sude22 sude22 added the bug Something isn't working label Nov 16, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Nov 16, 2023
@bpulliam bpulliam added area-WebView team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Nov 16, 2023
@codendone codendone changed the title WebView2; a new instance is created with every page change WebView2 leaks old msedgewebview2.exe processes with every page change Nov 16, 2023
@codendone
Copy link
Contributor

Changed title to indicate the issue is leaking the old processes.

@sude22
Copy link
Author

sude22 commented Nov 18, 2023

OK,
Unfortunately, I don't know the internal processes in Shell Navigation. But certainly every time switching to a new page, it is recreated, but the old instances are not cleaned up. The workaround for us now (since we don't need a back and forth function) is not to call the Frame.Navigate() method, but to create the pages ourselves, cache them, and assign them to the Frame.Content if necessary.

@codendone
Copy link
Contributor

Calling Close() on WebView2 instances before navigating away from the page should also force process cleanup.

@ranjeshj
Copy link
Contributor

@sude22 I'm not sure who is caching the element. Are you able to repro this with WinUI 3 gallery? Can you share a repro?

@ranjeshj ranjeshj added the needs-author-feedback Asked author to supply more information. label Dec 13, 2023
@HO-COOH
Copy link

HO-COOH commented Dec 25, 2023

@sude22 I'm not sure who is caching the element. Are you able to repro this with WinUI 3 gallery? Can you share a repro?

@ranjeshj The issue seems to be reproducible with WinUI3 gallery. You just go to webview2 page, open a console, switch to other pages then switch back and open another console. Do this for multiple times, and you can see all the console windows' are not closed

@huwaireb
Copy link

huwaireb commented Jul 7, 2024

👋 This issue is still reproducible in latest versions of WinUI 3 Gallery,

Screen.Recording.2024-07-07.at.17.26.39.mov

The two cents of someone new to WinUI

WinUI's management of the lifecycle of the control shouldn't end when instantiating the <WebView2 ../> control, however it should also account for it's disposal. It shouldn't try to instantiate a new instance if one already exists.

Manually disposing should only be done if needed for ui logic.

There should be means of "persisting" the instance in order to retain state, but by default dispose of its self. Then it would be expected behavior as how it's treated in the documentation, examples and WinUI 3 gallery.

P.S: Please stop closing issues that are clear bugs just because the OP doesn't respond. In this case a third party provided instructions to reproduce yet it closed anyhow, but even the OP's explanation was clear enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-WebView bug Something isn't working needs-author-feedback Asked author to supply more information. needs-triage Issue needs to be triaged by the area owners team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

6 participants