-
Notifications
You must be signed in to change notification settings - Fork 675
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 control throws OutOfMemoryException on call to EnsureCoreWebView2Async() after being loaded too many times #9689
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you! Closed similar issues:
|
I've had a look at this, and it looks to me like it may be an issue with C# garbage collection. In your test app (thanks so much for that, by the way!), I added this after
I no longer see the memory usage grow unboundedly larger with that added. Could you confirm? It's possible I'm missing something, so feel free to reopen if so. |
Thanks for looking at this! After you posted, I ran through some tests before trying your solution and found that I could no longer reproduce the initial issue. I loaded the WebView2-containing page more than 600 times without a crash before giving up. So, I think the problem has already been addressed in some way. |
Describe the bug
Our WinUI 3 app allows users to navigate to various pages to define a model, compute, and review outputs. Some of these pages have WebView2 controls on them to show their content. Once we've loaded a WebView2 control 252 times, the 253rd attempt throws an OutOfMemory exception when we call EnsureCoreWebView2Async() when initializing the WebView2 control.
This was tested with the following configurations with the same behavior:
Steps to reproduce the bug
WebViewTest.zip
Debug|x86
unpackaged configurationNavigationViewItem
to load a page containing a singleWebView2
controlNavigationViewItem
to load subsequent pagesOutOfMemoryException
when the page calls theWebView2
'sEnsureCoreWebView2Async()
method.Expected behavior
We should be able to load and unload a WebView2 control as many times as necessary, as is possible with other controls like TextBoxes, RadioButtons, etc.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.5.3: 1.5.240428000
Windows version
Windows 11 (22H2): Build 22621, Windows 10 (21H2): Build 19044
Additional context
If I don't call
WebView.Close()
from the Page'sUnloaded
event, I have been able to load the WebView2 control as many as 268 times before crashing.I've made a similar bug report in the Microsoft Edge WebView2Feeback repository. Please let me know if that or somewhere else is a more appropriate place to report this issue. Thank you!
The text was updated successfully, but these errors were encountered: