Repository navigation
fix(wasm): Remove WebView2 iframe once it is collected (backport #24841) (backport #24842) - #25780
Merged
agneszitte merged 5 commits intoOct 28, 2026
Merged
Conversation
3 of 5 tasks
agneszitte
approved these changes
Oct 28, 2026
agneszitte
added a commit
that referenced
this pull request
Oct 28, 2026
They read the browser DOM through WasmSemanticDomHelper and BrowserHtmlElement, which the native heads don't build, so native Android failed with CS0234 since #25780. Same change as on servicing/6.8 (#25552). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 of 5 tasks
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: related to unoplatform/kahua-private#547
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia WebAssembly, every
WebView2leaves its<iframe>in the DOM for the rest of the session.BrowserWebViewProvidercreates the iframe withBrowserHtmlElement.CreateHtmlElement("iframe"), nothing ever disposes it, and native-element hosting only hides elements when they are detached. The hidden iframes keep their loaded documents alive. After a 700-page SamplesApp walk, 31 hidden iframes held about 510 MiB. Chrome keeps cross-site iframes in separate renderer processes; Safari keeps them in the tab's own process.This PR removes the iframe once its
WebView2is garbage collected, and keeps it across unload and reload while the control is still referenced. That matches WinUI (controls/dev/WebView2/WebView2.cpp):OnUnloadedonly hides and disconnects the browser, and onlyClose()or the destructor close it. It also follows the Skia macOS convention, where~MacOSNativeElementreleases the native peer.BrowserHtmlElementgets an internalRemoveFromDomWhenCollected(). A private sentinel, referenced only by the element, carries the finalizer; it removes the element on the UI thread at idle priority. An explicitDispose()cancels it.Dispose()contract.BrowserWebViewProvideropts in the iframe it creates.There are no public API changes.
Validation
Given_WebView2.When_Collected_Then_Native_Iframe_Is_RemovedandWhen_Unloaded_While_Referenced_Then_Native_Iframe_Is_Keptpass. With only the provider's opt-in line removed, the collection test fails at the DOM check while theWebView2itself is collected. The reload test passes either way; it guards against removing the iframe too early and checks that the navigated document survives.Uno.UI,Uno.UI.Runtime.Skia.WebAssembly.BrowserandUno.UI.RuntimeTests.Skiacompile fornet10.0with analyzers, code-style enforcement and warnings as errors.net11.0was not built locally.Not in this PR
WebView2.Close()is still a generated[NotImplemented]stub, so release depends on garbage collection. Implementing it would give apps a deterministic release.MediaPlayerElementreleases its<video>element from its own finalizer, directly instead of on the UI thread. It could move to the same mechanism.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #24841 done by [Mergify](https://mergify.com).
This is an automatic backport of pull request #24842 done by [Mergify](https://mergify.com).