Conversation
There was a problem hiding this comment.
Pull request overview
Updates flyout-related dependency properties and FlyoutBase behavior to prevent DataContext-based retention (leaks) when flyouts are shared across multiple controls, with Skia-focused runtime test coverage.
Changes:
- Prevent flyout DP values (ContextFlyout/SelectionFlyout/ProofingMenuFlyout) from inheriting DataContext.
- Ensure flyout presenters receive the placement target DataContext while open, and clear it on close to avoid leaks.
- Add Skia runtime tests validating no ViewModel leak and correct DataContext forwarding.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Uno.UI/UI/Xaml/UIElement.Properties.cs |
Changes ContextFlyout DP metadata to avoid DataContext inheritance. |
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs |
Updates SelectionFlyout/ProofingMenuFlyout DP metadata to avoid DataContext inheritance. |
src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.skia.cs |
Updates SelectionFlyout DP metadata to avoid DataContext inheritance. |
src/Uno.UI/UI/Xaml/Controls/Flyout/FlyoutBase.cs |
Forwards DataContext to presenter on show and clears it on close to prevent retention. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs |
Adds runtime tests for shared ContextFlyout leak regression and presenter DataContext forwarding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
|
The build 198930 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
|
The build 199022 found UI Test snapshots differences: Details
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
|
The build 199026 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.ContextFlyoutLeak.cs
Outdated
Show resolved
Hide resolved
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The build 199164 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
|
The build 199232 found UI Test snapshots differences: Details
|
|
|
|
The build 199232 found UI Test snapshots differences: Details
|
|
The build 199232 found UI Test snapshots differences: Details
|
|
The build 199232 found UI Test snapshots differences: Details
|
`XamlRoot` propagation is not needed - it is done implicitly in ShowAt
8a3d94a to
4503efe
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22750/wasm-skia-net9/index.html |
|
The build 199407 found UI Test snapshots differences: Details
|
|
|
|
The build 199407 found UI Test snapshots differences: Details
|
GitHub Issue: closes https://github.com/unoplatform/add-private/issues/44
PR Type:
🐞 Bugfix
What is the current behavior? 🤔
When a single
MenuFlyout(orTextCommandBarFlyout) instance is shared as theContextFlyoutorSelectionFlyoutacross multiple controls, the flyout's presenter captures a strong reference to theDataContextof whichever control last opened it. After that control is removed from the visual tree itsDataContext(e.g. a ViewModel) cannot be garbage-collected, causing a memory leak.What is the new behavior? 🚀
The flyout presenter now holds only a weak reference to the target element when propagating
DataContext, so removing a control from the tree allows itsDataContextto be collected even when the flyout is still assigned to another control.Runtime tests covering both
ContextFlyoutandSelectionFlyoutleak scenarios are included.PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️
Reproducer pattern: assign a
MenuFlyouttoTextBox.ContextFlyout, open/close it, remove theTextBoxfrom the tree, reassign the flyout to a second control — then verify the firstTextBox'sDataContextis collectable.