Repository navigation
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39591Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39591" |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hey there @@FullDevStudio! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @FullDevStudio! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
kubaflo
left a comment
There was a problem hiding this comment.
Could you check the ai's suggestions?
There was a problem hiding this comment.
🟡 Changes recommended
Clearing _shell leaves subsequent flyout measurement callbacks vulnerable to a null-reference exception.
1 open issue
What changed in this PR
This PR addresses Windows Shell retention by releasing flyout-item references when the Shell handler disconnects.
Changes:
- Reuses content cleanup for both data-context changes and disconnects.
- Disconnects descendant flyout-item views during Shell teardown.
- Adds a Windows device test that checks Shell collection after a page swap.
| File | Description |
|---|---|
| src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs | Adds a garbage-collection regression test. |
| src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs | Invokes flyout-item cleanup during disconnect. |
| src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs | Extracts shared cleanup and clears retained references. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
kubaflo
left a comment
There was a problem hiding this comment.
Looks like there are still a few ai suggestions - could you please check?
|
Hi @kubaflo, I think those are the threads from the first round. Both points are already fixed in bbb4ac4: the ShellView getter is null-safe now (_shell?.Handler?.PlatformView as ShellView), with a test that measures a flyout item after the shell disconnects, and the leak test keeps the window open and runs the GC check during the shell swap. The review on bbb4ac4 came back with 0 findings. If there's another suggestion I'm missing, point me to it and I'll fix it right away. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit bbb4ac4.
kubaflo
left a comment
There was a problem hiding this comment.
Could you check the ai's suggestions?
Selected PR Tests
🎯 Detected coverage
❌ Results
Failed tests (5)
Comment Manual trial snapshot; the UI run remains in progress, so these counts are not final. 🧪 Selection notes — click to expandSelected runs are not full-suite certification; queued does not mean passed. Coverage notes:
Manual preview; selection/reporting code under test is in #40253. |
This comment has been minimized.
This comment has been minimized.
PR Test Gate
|
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit bbb4ac4.
a83e97a
into
dotnet:candidate/11.0.1xx-sr2
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…9591) Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects. ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change. I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve. <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes # <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>

Our app swaps between two shells, and on Windows every old shell stayed in memory with all its pages, about 90 MB per switch. A gcdump showed the path: WinUI keeps the ShellFlyoutItemView of each flyout entry alive through its CCW, and the view still holds _shell and _content (whose parent is the shell item). It only lets go of them when its DataContext changes, and that does not happen when the shell's handler disconnects.
ShellView.Disconnect now also tells every ShellFlyoutItemView under it to release its content and the shell. The cleanup that used to sit in OnDataContextChanged is moved into ReleaseContent, which both paths use, so nothing changes for a DataContext change.
I added a Windows device test that shows a shell with two flyout items, swaps the window's page, disconnects the shell handler and waits for the shell to be collected. Our workaround sets DataContext = null on each ShellFlyoutItemView after the swap; with it, twelve switches left one old shell instead of twelve.
Description of Change
Issues Fixed
Fixes #