Repository navigation
Fix SwipeItemView Command Memory Leak - #38316
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38316Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38316" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
I've changed base to inflight/current because I remember that something has been done to fix it in that branch |
a63059a to
01a03c8
Compare
2af53a4 to
98b75d4
Compare
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
d67f566 to
c7281c3
Compare
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
| } | ||
|
|
||
| [Fact] | ||
| public void SwipeItemViewIsNotRetainedByCommand() |
There was a problem hiding this comment.
🔍 AI-Generated Review (multi-model)
[major] Regression Prevention and Test Coverage — SwipeItemViewIsNotRetainedByCommand does not demonstrate the claimed behavior change, because the same retention scenario was already exercised by CommandsSubscribedToCanExecuteCollect for SwipeItemView and ICommandElement cleanup tracking in CommandTests. Concrete failure mode: the new test can pass on the PR base as well, so it cannot fail when the fix is absent and does not prove this PR’s SwipeItemView code change.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@devanathan-vaithiyanathan — new AI review results are available based on commit
d5eeb8d.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ❌ FAILED
Platform: ANDROID · Base: inflight/current · Merge base: 1aa4552f
🩺 Test does not reproduce the bug — ran the same in both states (PASS without fix, PASS with fix). The repro test is not exercising the issue. Strengthen the test before reviewing the fix.
| Test | Without Fix (expect FAIL) | With Fix (expect PASS) |
|---|---|---|
🧪 SwipeViewTests SwipeViewTests |
❌ PASS — 158s | ✅ PASS — 86s |
🔴 Without fix — 🧪 SwipeViewTests: PASS ❌ · 158s
(no coded error found; showing last 1200 chars)
sed SwipeViewResubscribesToScrollParentAfterRemovalAndReaddition [2 ms]
Passed TestConstructor [1 ms]
Passed TestSwipeViewBindingContextChangedEvent [< 1 ms]
Passed TestProgrammaticallyClose [4 ms]
Passed TestSwipeItemsSwipeBehaviorOnInvoked [< 1 ms]
Passed SharedContentDoesNotKeepSwipeViewsAlive [108 ms]
Passed SwipeItemsRemainInLogicalTreeWhenContentIsSet [21 ms]
Passed ReplacingCachedSwipeItemsReleasesPreviousOwnerReference [117 ms]
Passed TestContentBindingContextChangedEvent [< 1 ms]
Passed ClearingCommandReEnablesSwipeItemView [6 ms]
Passed TestTemplatedContentBindingContextChangedEvent [2 ms]
Passed TestProgrammaticallyOpen [< 1 ms]
Passed ClearRemovesLogicalChildren [1 ms]
Passed TestLeftItems [< 1 ms]
Passed TestContentBindingContextPropagatesToNewSwipeItems [< 1 ms]
Passed TestSwipeItemsExecuteMode [< 1 ms]
Passed TestTopItems [< 1 ms]
[xUnit.net 00:00:02.08] Finished: Microsoft.Maui.Controls.Core.UnitTests
Passed SwipeViewRediscoversScrollParentWhenTemplateRootIsReparented [< 1 ms]
Passed SwipeViewFindsScrollParentAfterTemplateParentConnected [< 1 ms]
Test Run Successful.
Total tests: 29
Passed: 29
Total time: 2.6412 Seconds
🟢 With fix — 🧪 SwipeViewTests: PASS ✅ · 86s
(no coded error found; showing last 1200 chars)
d SwipeViewResubscribesToScrollParentAfterRemovalAndReaddition [1 ms]
Passed TestConstructor [1 ms]
Passed TestSwipeViewBindingContextChangedEvent [< 1 ms]
Passed TestProgrammaticallyClose [2 ms]
Passed TestSwipeItemsSwipeBehaviorOnInvoked [< 1 ms]
Passed SharedContentDoesNotKeepSwipeViewsAlive [102 ms]
Passed SwipeItemsRemainInLogicalTreeWhenContentIsSet [21 ms]
Passed ReplacingCachedSwipeItemsReleasesPreviousOwnerReference [100 ms]
Passed TestContentBindingContextChangedEvent [< 1 ms]
Passed ClearingCommandReEnablesSwipeItemView [6 ms]
Passed TestTemplatedContentBindingContextChangedEvent [2 ms]
Passed TestProgrammaticallyOpen [< 1 ms]
Passed ClearRemovesLogicalChildren [< 1 ms]
Passed TestLeftItems [< 1 ms]
Passed TestContentBindingContextPropagatesToNewSwipeItems [< 1 ms]
Passed TestSwipeItemsExecuteMode [< 1 ms]
Passed TestTopItems [< 1 ms]
[xUnit.net 00:00:01.98] Finished: Microsoft.Maui.Controls.Core.UnitTests
Passed SwipeViewRediscoversScrollParentWhenTemplateRootIsReparented [< 1 ms]
Passed SwipeViewFindsScrollParentAfterTemplateParentConnected [< 1 ms]
Test Run Successful.
Total tests: 29
Passed: 29
Total time: 2.5035 Seconds
⚠️ Failure Details
- ❌ SwipeViewTests PASSED without fix (should fail) — tests don't catch the bug
📁 Fix files reverted (1 files)
src/Controls/src/Core/SwipeView/SwipeItemView.cs
📋 Pre-Flight — Context & Validation
PR #38316 Pre-Flight
Context
- PR:
Fix SwipeItemView Command Memory Leak - Issue: #38177, a reported retention path from a long-lived
ICommand.CanExecuteChangedevent to a transientSwipeItemView. - Head:
d5eeb8d5cdd6c1af8faa10f5a053e7df6a630e38 - Base:
inflight/currentat merge base1aa4552fc784d4b443c5126c47ba4626712020fd - Platform: Android
Diff inspected
The PR changes:
src/Controls/src/Core/SwipeView/SwipeItemView.cs- Replaces the control-local command callbacks and
WeakCommandSubscriptionfield with the shared internalICommandElement/CommandElementimplementation. - Keeps
WeakCommandSubscriptionas the underlying subscription mechanism.
- Replaces the control-local command callbacks and
src/Controls/tests/Core.UnitTests/SwipeViewTests.cs- Adds
SwipeItemViewIsNotRetainedByCommand. - Adds
ClearingCommandReEnablesSwipeItemView.
- Adds
Important baseline finding
The current inflight/current base already uses WeakCommandSubscription. That implementation stores the target and handler in a DependentHandle, so the command's event subscription does not strongly root the SwipeItemView. The PR therefore refactors an already-weak subscription rather than replacing the direct strong event subscription described in #38177.
The completed gate confirms this mismatch:
SwipeViewTestspassed without the PR production fix.SwipeViewTestspassed with the PR production fix.SwipeItemViewIsNotRetainedByCommandandClearingCommandReEnablesSwipeItemViewpassed in both states.- Gate verdict: definitive failure because the added leak test does not reproduce against the current target branch.
- Do not rerun the gate or modify
gate/content.md.
Bounded try-fix scope
-
Production target/restore boundary:
src/Controls/src/Core/SwipeView/SwipeItemView.cs. -
Test file is context only unless the baseline script explicitly permits it; the existing PR tests remain in place.
-
Primary targeted validation:
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~SwipeViewTests"This is the detected
SwipeViewTeststest class and includes both PR regression tests without running the full suite. -
Each candidate gets one implementation/test pass and at most one focused correction/retest.
-
Candidate approaches must differ at the mechanism/root-cause level from both the PR's
ICommandElementrefactor and any earlier candidate. -
A truthful
BlockedorFailis required if no distinct production fix is justified by the current baseline or the targeted tests cannot validate it.
🔬 Code Review — Deep Analysis
Expert PR Evaluation
Verdict: NEEDS_CHANGES
Confidence: high
Independent assessment
The submitted production change replaces SwipeItemView's control-local command callbacks with the shared internal ICommandElement/CommandElement callback path. Both implementations use WeakCommandSubscription; on the PR base that helper already uses a DependentHandle whose primary target is the SwipeItemView. The refactor therefore does not replace the strong CanExecuteChanged subscription described by the issue and does not establish a new weak-retention mechanism.
The command replacement, command clearing, command-parameter, and CanExecuteChanged behavior remain consistent with the previous implementation. Clearing a command re-enables the view in both implementations.
Finding
❌ The regression test does not prove the submitted production change. SwipeItemViewIsNotRetainedByCommand passes on both the PR base and PR head. The trusted Gate confirmed 29/29 SwipeViewTests pass in both states, including both newly added tests. Consequently, the test cannot fail without this PR's production refactor and does not demonstrate a regression fixed by the PR.
The authoritative inline finding is recorded in ../inline-findings.json against src/Controls/tests/Core.UnitTests/SwipeViewTests.cs:422.
Blast radius and failure-mode probing
- The production change affects every
SwipeItemViewwith a command, but not startup or static/shared state. - Replacing or clearing
Commanddisposes the prior tracker throughCommandElement.OnCommandChanging; setting a new command installs one subscription. - A null command is handled by
CommandElement.GetCanExecuteand restoresIsEnabled. - No concrete runtime regression was identified in the submitted refactor; the blocking problem is that the current target branch already exhibits the claimed fixed behavior and the test cannot distinguish the PR.
Validation evidence
The trusted Gate failed because SwipeViewTests passed both without and with the submitted production change. Per the execution contract, Gate verification was not rerun.
🛠️ Try-Fix — Analysis & Comparison
PR #38316 Try-Fix Aggregate
Candidate 1 — Existing control-local weak subscription
Approach: Keep the inflight/current implementation unchanged: SwipeItemView owns a control-local WeakCommandSubscription, whose DependentHandle makes the view a weak primary target.
Difference from the PR: The PR introduces ICommandElement/CommandElement callback routing while retaining the same weak-subscription substrate. Candidate 1 uses no interface or shared helper routing; it establishes that the target branch's existing control-local weak mechanism already provides the reported retention behavior.
Candidate diff: Empty. Establishing the broken baseline produced the already-fixed target-branch implementation, so no additional production edit was justified.
Result: Pass
Test: dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~SwipeViewTests"
Test result: 29 passed, 0 failed, 0 skipped. This includes SwipeItemViewIsNotRetainedByCommand and ClearingCommandReEnablesSwipeItemView.
Failure analysis: None. The result instead confirms the gate finding: the PR regression tests pass on the current target branch without the PR production refactor, so they do not establish that an additional fix is needed.
Inline expert self-review: 0 findings.
Restoration: EstablishBrokenBaseline.ps1 -Restore completed with Restored True; target files were clean afterward.
Detailed record: ../try-fix-1/content.md
Aggregate status
Candidate 1 persisted.
Candidate 2 — Control-local weak listener proxy
Approach: Replace WeakCommandSubscription in SwipeItemView with a private subscription owner and event-listener proxy. The long-lived command retains the proxy, while the proxy reaches the transient view only through WeakReference<SwipeItemView>. Command replacement disposes the subscription, a callback self-detaches after observing a collected target, and the separately owned finalizable subscription detaches a dormant proxy even when the command never raises again.
Difference from the PR: This does not implement ICommandElement, use CommandElement, or retain shared WeakCommandSubscription/DependentHandle machinery. Its event delegate targets a standalone weak-reference proxy.
Difference from candidate 1: Candidate 1 made no production change and relied on the target branch's existing WeakCommandSubscription/DependentHandle. Candidate 2 changes both the reachability primitive and cleanup lifecycle to command -> proxy -> weak view, with a separately finalizable subscription owner.
Files changed in captured attempt: src/Controls/src/Core/SwipeView/SwipeItemView.cs; no public API change.
Result: Pass
Test: dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~SwipeViewTests"
Test result: 29 passed, 0 failed, 0 skipped. This includes SwipeItemViewIsNotRetainedByCommand and ClearingCommandReEnablesSwipeItemView.
Failure analysis: None. However, candidate 1 passed the same tests with an empty production diff, so candidate 2's result proves compatibility and tested collection behavior, not that replacing the current target-branch implementation is necessary.
Inline expert self-review: 0 findings; the reviewed diff did not change during testing.
Captured candidate diff:
diff --git a/src/Controls/src/Core/SwipeView/SwipeItemView.cs b/src/Controls/src/Core/SwipeView/SwipeItemView.cs
index b031048396..d3d4f157d8 100644
--- a/src/Controls/src/Core/SwipeView/SwipeItemView.cs
+++ b/src/Controls/src/Core/SwipeView/SwipeItemView.cs
@@ -52,7 +52,7 @@ namespace Microsoft.Maui.Controls
Invoked?.Invoke(this, EventArgs.Empty);
}
- WeakCommandSubscription _commandSubscription;
+ WeakCanExecuteChangedSubscription _commandSubscription;
void OnCommandChanged()
{
@@ -61,7 +61,7 @@ namespace Microsoft.Maui.Controls
if (Command == null)
return;
- _commandSubscription = new WeakCommandSubscription(this, Command, OnCommandCanExecuteChanged);
+ _commandSubscription = new WeakCanExecuteChangedSubscription(this, Command);
}
void OnCommandChanging()
@@ -82,5 +82,56 @@ namespace Microsoft.Maui.Controls
{
IsEnabled = Command.CanExecute(CommandParameter);
}
+
+ sealed class WeakCanExecuteChangedSubscription : IDisposable
+ {
+ readonly CanExecuteChangedProxy _proxy;
+
+ public WeakCanExecuteChangedSubscription(SwipeItemView target, ICommand command)
+ {
+ _proxy = new CanExecuteChangedProxy(target, command);
+ }
+
+ ~WeakCanExecuteChangedSubscription()
+ {
+ _proxy.Dispose();
+ }
+
+ public void Dispose()
+ {
+ _proxy.Dispose();
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ sealed class CanExecuteChangedProxy : IDisposable
+ {
+ readonly WeakReference<SwipeItemView> _target;
+ ICommand _command;
+
+ public CanExecuteChangedProxy(SwipeItemView target, ICommand command)
+ {
+ _target = new WeakReference<SwipeItemView>(target);
+ _command = command;
+ _command.CanExecuteChanged += OnCanExecuteChanged;
+ }
+
+ public void Dispose()
+ {
+ if (_command == null)
+ return;
+
+ _command.CanExecuteChanged -= OnCanExecuteChanged;
+ _command = null;
+ }
+
+ void OnCanExecuteChanged(object sender, EventArgs eventArgs)
+ {
+ if (_target.TryGetTarget(out var target))
+ target.OnCommandCanExecuteChanged(sender, eventArgs);
+ else
+ Dispose();
+ }
+ }
}
}
\ No newline at end of fileRestoration: EstablishBrokenBaseline.ps1 -Restore completed with Restored True; target files were clean afterward.
Detailed record: ../try-fix-2/content.md
Final aggregate status
Two candidates completed, persisted, and restored. Candidate 1 is the lower-risk result because it demonstrates that the target branch already satisfies the reported behavior without additional production code. Candidate 2 is a mechanically distinct passing alternative, but the current regression test cannot establish that its extra implementation complexity is necessary.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the current metadata inaccurately says the PR replaces a direct event subscription, while the submitted diff refactors an existing WeakCommandSubscription path through ICommandElement/CommandElement.
Recommended title
[Controls] SwipeItemView: Route command handling through ICommandElement
Recommended description
### Issue Details
#38177 reports that a long-lived command can retain a transient `SwipeItemView` through `CanExecuteChanged`.
### Description of Change
Refactors `SwipeItemView` command handling to use MAUI's existing internal `ICommandElement` and `CommandElement` infrastructure.
- Routes `CommandProperty` changes through `CommandElement.OnCommandChanging` and `CommandElement.OnCommandChanged`.
- Routes `CommandParameterProperty` changes through `CommandElement.OnCommandParameterChanged`.
- Implements `ICommandElement.CanExecuteChanged` and its `CleanupTracker`.
- Continues to use `WeakCommandSubscription` as the underlying command subscription.
- Adds coverage for collection while a command remains alive and for re-enabling the view when its command is cleared.
### Issues Fixed
Related to #38177
**Tested the behavior in the following platforms.**
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
| Before | After |
|---------|--------|
| **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> |
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Winner: pr-plus-reviewer
pr-plus-reviewer wins because it removes the submitted refactor and non-discriminating tests, leaving the tree identical to the current PR base. That base already uses WeakCommandSubscription with DependentHandle weak-primary semantics, and both the trusted Gate and try-fix-1 validated the identical base tree with 29 passing SwipeViewTests.
The submitted PR should not merge as-is. Its production change routes command handling through ICommandElement/CommandElement, but retains the same underlying weak-subscription mechanism already present on the target branch. Its leak test passes without that production change, so it cannot demonstrate the claimed fix.
Comparative ranking
| Rank | Candidate | Production approach | Focused validation | Assessment |
|---|---|---|---|---|
| 1 | pr-plus-reviewer |
Reverts the PR to the current target-branch implementation | Candidate-local run blocked before test execution by missing project.assets.json; resulting tree is identical to the Gate/try-fix-1 base tree that passed 29/29 tests |
Winner. No production delta, no unnecessary abstraction, and direct equivalent-tree validation exists. |
| 2 | try-fix-1 |
Keeps the existing control-local WeakCommandSubscription |
Pass: 29 passed, 0 failed, 0 skipped | Technically equivalent to the winner and confirms no additional fix is needed. It is an empty candidate rather than a reviewer patch applicable to the submitted PR. |
| 3 | try-fix-2 |
Adds a control-local proxy using WeakReference<SwipeItemView> |
Pass: 29 passed, 0 failed, 0 skipped | Correct under the focused tests, but replaces an already-working shared primitive with 51 lines of control-specific lifecycle code without evidence that the extra mechanism is needed. |
| 4 | pr |
Refactors local callbacks to shared ICommandElement/CommandElement callbacks |
Gate failed: the same 29 tests passed both without and with the production change | Lowest rank because the regression test does not distinguish the submitted fix and the claimed strong-retention path is absent from the current base. |
Expert review
The single expert review produced one major inline finding at src/Controls/tests/Core.UnitTests/SwipeViewTests.cs:422: SwipeItemViewIsNotRetainedByCommand can pass on the PR base and therefore does not prove this PR's production change. No concrete command replacement, command clearing, CanExecuteChanged, public API, or platform-specific regression was found in the refactor itself.
Validation interpretation
- The trusted Gate result is definitive for fix verification: base and PR both passed the same 29
SwipeViewTests. try-fix-1independently passed those 29 tests on the unchanged base implementation.try-fix-2passed but cannot establish necessity because the unchanged base passed first.- The one allowed
pr-plus-reviewerrun was blocked by missing restored NuGet assets. It was not rerun. This does not change the comparative result because its candidate diff against the PR base is empty and that identical tree has two successful focused results.
Required change
Do not merge the submitted refactor as a memory-leak fix against inflight/current. The winning change is the pr-plus-reviewer patch, which removes the PR delta and preserves the target branch's already-working weak command subscription.
📱 UI Tests — SwipeView
Detected UI test categories: SwipeView
✅ Deep UI tests — 79 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
SwipeView |
79/79 ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
🧭 Next Steps — reviewer changes required
The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.
Why: The target branch already implements weak command retention through WeakCommandSubscription and DependentHandle, and the submitted regression test passes without the PR refactor. pr-plus-reviewer removes the unnecessary delta, producing the same tree that the Gate and try-fix-1 validated with 29 passing SwipeViewTests.
Address the actionable findings in this review before merging.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-pr
🧪 maui-pr-devicetestsNo results available. 🧪 maui-pr-uitestsNo results available. 🧭 Follow-up — actions and refreshNext action: Comment
|
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak. ### Description of Change <!-- Enter description of the fix in this section --> Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement. ### 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 #38177 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <img src="https://github.com/user-attachments/assets/0ed1f34f-f4c2-45be-88e5-430f417fcdb9" width="300" height="600"> | **Android**<br> <img src="https://github.com/user-attachments/assets/e656958b-c414-4fbf-b4d0-a6498a8375de" width="300" height="600"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
SwipeItemView was retained by a long-lived command through its CanExecuteChanged event, causing a memory leak.
Description of Change
Replaced the direct event subscription with MAUI’s existing WeakCommandSubscription through ICommandElement.
Issues Fixed
Fixes #38177
Tested the behavior in the following platforms.