Repository navigation
fix(wasm): Remove WebView2 iframe once it is collected (backport #24841) - #24842
Conversation
|
Cherry-pick of b17a85a has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24842/wasm-skia-net9/index.html |
|
Resolved the cherry-pick conflict in 7987a9d. The first commit conflicted in
Against Validated locally on this branch: the 6.8 The same three files are identical on |
|
|
|
The build 236668 did not find any UI Test snapshots differences. |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
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).