Skip to content

[iOS & Mac] Fix and Re-enable "Cells Do Not Leak" and "Handler Does Not Leak" Device Tests - #36698

Merged
kubaflo merged 8 commits into
dotnet:inflight/currentfrom
BagavathiPerumal:fix-35985
Aug 8, 2026
Merged

kubaflo merged 8 commits into
dotnet:inflight/currentfrom
BagavathiPerumal:fix-35985

Conversation

@BagavathiPerumal

@BagavathiPerumal BagavathiPerumal commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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

The device memory leak validation tests began failing in the Candidate branch after the test-related changes introduced in PR #35487, which exposed actual memory leaks that were previously undetected. The regressions affected the Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and the Handler Does Not Leak test on macOS 26.0, indicating platform-specific memory leak issues that require fixes.

Root cause

The issue occurs because of a templated cell registering its bound view as a logical child of the parent items view when bound, but only removing that registration when the cell was rebound to a different template — never when a cell was simply bound once and then discarded without being recycled. This permanently rooted the templated view, and its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could independently keep the platform view (and bound view) reachable even if the logical-child link were cleared. The leak test itself also had a bug: it never released its local cell, handler, and control references before checking for garbage collection, which kept them rooted for the whole test and masked the production issue.

Solution description

The fix involves detaching the bound view from the parent's logical children and clearing the cell's native subviews during disposal, on the deterministic (non-finalizer) teardown path, so cleanup happens regardless of whether the cell was recycled, replaced, or simply discarded. It also involves correcting the test to explicitly tear down the cell and its owning control, then null out all local references, before verifying collection — since without this, the fix could never be exercised or proven in the test.

Note: The issue, "Handler Does Not Leak," was not reproduced in the Switch control. Therefore, the "Handler Doesn't Leak" test case has been re-enabled for the Switch control.

Validated the behavior in the following platforms

  • iOS
  • Mac
  • Android
  • Windows

Regression PR

PR #35487

Issues Fixed

Fixes #35985

Output Screenshot

Platform Before After
iOS
BeforeFix-CollectionView-MemoryLeak.iOS.1.1.mov
AfterFix-Cells.Do.not.leak.iOS.1.1.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36698

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36698"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@sheiksyedm

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@BagavathiPerumal BagavathiPerumal changed the title Fix and Re-enable "Cells Do Not Leak" and "Handler Does Not Leak" Device Tests [iOS & Mac] Fix and Re-enable "Cells Do Not Leak" and "Handler Does Not Leak" Device Tests Jul 23, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/macos macOS / Mac Catalyst platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jul 23, 2026
@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Jul 27, 2026
kubaflo pushed a commit that referenced this pull request Jul 27, 2026
…ED red-X

A gate that exceeds the 150-min safety cap is killed by AzDO and marked failed,
which red-Xed the Review stage as if the PR's test verification genuinely FAILED
(observed: build 14772346 / #36698 catalyst — 2 device tests x A/B exceeded 150m,
'The task has timed out'). A timeout is an infra/duration outcome, not a real test
failure.

Add continueOnError:true to the gate task. This is SAFE for genuine verdicts: the
RunGate wrapper exits 0 and signals a real FAILED via the GateFailed output
variable, which 'Check Review Result' turns into the red-X — so PASSED / FAILED /
INCONCLUSIVE are all unchanged. continueOnError only affects the killed-on-timeout
case, turning it into a non-blocking succeededWithIssues so the deep tests + expert
review still deliver a summary (gate reported INCONCLUSIVE).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 15d2af20-e4ab-4e88-9011-cfbd83513bc0
@MauiBot

This comment has been minimized.

@MauiBot MauiBot added the s/agent-gate-failed AI could not verify tests catch the bug label Jul 27, 2026
@kubaflo

kubaflo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

CI Merge-Readiness: ❌ Not ready

Analyzed builds on head 6a16b28.

Check Verdict
maui-pr 1523328 ✅ pass
maui-pr-uitests 1524530 🔴 PR-caused
maui-pr-devicetests 1524531 🔴 PR-caused
Build Analysis 🔴 0 known-issue matches

UI tests — 27 failures, none on baseline

Compared test-by-test against 5 recent main builds of maui-pr-uitests (1526484, 1518286, 1503618, 1503332, 1503036). Every failure is new; not one matched a baseline failure in the same suite.

Suite PR main baselines
CarouselView_CARV1_ios 14 0, 0, 0, 0, 0
CarouselView_ios 5 0, 0, 0, 0, 0
CollectionView_CV1_ios 5 0, 0, 0, 0, 0
CarouselView_mac 3 0, 0, 0, 0, 0
CollectionView_ios (Items2) 0 0, 0, 0, 0, 0
CollectionView_mac (Items2) 0 0, 0, 1, 0, 1

Notable failures:

  • Issue29411.VerifyLoopChangeAtRuntimeShouldNotCrash — System.NullReferenceException
  • Issue17283.CarouselViewShouldScrollToRightPosition, Issue10234.ScrollCarouselViewAfterDispose, Issue28557.CarouselViewShouldNotCrashOnSourceUpdateWithPageNavigation, CarouselViewUpdateCurrentItem.Issue9827Test, CarouselViewUITests.NavigateForwardWhenLooped, NavigateBackWhenLooped, Issue17969.CollectionViewAddGroupWhenViewIsEmpty, Issue12374.Issue12374Test — app crashes
  • Issue32243.CollectionViewDisconnectsHandlersAfterNavigationBack — ⚠️ 2 labels still have connected handlers (expected ✓ No labels have connected handlers)
  • Issue29491.VerifyDataTemplateParentIsNotNull — screenshot diff 11.97%
  • Issue32139.ValidateNoScrollOnInvalidItemWithLoop — screenshot diff 5.21%
  • 12 further System.TimeoutException : Timed out waiting for element

The attribution is hard to argue with: this PR only touches Items/iOS/TemplatedCell.cs, i.e. the legacy iOS CollectionView/CarouselView handler — and the Items2 suites (CollectionView_ios, CollectionView_mac) are the only iOS/Mac suites at zero failures. The regressions land precisely on the code path that changed.

The crashes, the NRE, and the CollectionViewDisconnectsHandlersAfterNavigationBack assertion all point the same way: the new Dispose(bool) → Unbind() → DetachFromItemsView() + ClearSubviews() path is tearing the cell down while UIKit still expects it to be live. Unbind() is called from PrepareForReuse and from cell recycling, so now every recycle also rips the platform view out of the ContentView and drops the logical child — not just the deallocation case.

Device tests — Android CoreCLR regression

Run DeviceTests Android (CoreCLR) failed:

[FAIL] Items Do Not Leak
  Expected all references to be collected, but some are still alive.
  at Microsoft.Maui.DeviceTests.AssertionExtensions.WaitForGC(WeakReference[] references)

That leg is green on 6/6 recent main builds (1526485, 1518287, 1503431, 1503150, 1503037, 1499502), so it qualifies as regressed-vs-base. Likely vector: MemoryTests.cs removes the #if TESTS_FAILS_ON_MACCATALYST guard around [InlineData(typeof(Switch))]. That symbol is never defined, so the guard was suppressing the case on every platform — removing it enables the Switch leak test on Android and Windows too, not just Catalyst.

Test gate

The AI gate reported ❌ FAILED — the re-enabled tests passed both with and without the fix, so they do not currently reproduce #35985.

Suggested next steps

  1. Investigate the legacy-handler crashes/NRE — Unbind() runs on recycle, not only on teardown, so ClearSubviews() + RemoveLogicalChild there is likely too aggressive.
  2. Re-scope the Switch InlineData to MacCatalyst only (e.g. #if MACCATALYST) instead of removing the guard, so Android/Windows are untouched.
  3. Strengthen the re-enabled CellsDoNotLeak / HandlerDoesNotLeak tests so they actually fail without the fix.

🤖 Automated CI analysis — no approval or change request implied; a human review is still required.

@BagavathiPerumal

Copy link
Copy Markdown
Contributor Author

AI Review Summary

@BagavathiPerumal — new AI review results are available based on this last commit: 6a16b28.

Gate Partial Confidence Low Platform MacCatalyst

🗂️ Review Sessions — click to expand

🚦 Gate — Test Before & After Fix

Gate Result: ❌ FAILED

Platform: CATALYST · Base: main · Merge base: 997d875b

🩺 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)
📱 CollectionViewTests CollectionViewTests ❌ PASS — 3667s ✅ PASS — 967s
📱 MemoryTests MemoryTests ❌ PASS — 4865s ✅ PASS — 474s
🔴 Without fix — 📱 CollectionViewTests: PASS ❌ · 3667s
(no coded error found; showing last 1200 chars)

m�[37mdbug�[39m�[22m�[49m: 2026-07-26 15:43:50.063 Df Microsoft.Maui.Controls.DeviceTests[20281:14710] <private>
�[40m�[37mdbug�[39m�[22m�[49m: Killing process 20278 as it was cancelled
�[40m�[37mdbug�[39m�[22m�[49m: ==================== End of SystemLog ====================
�[40m�[37mdbug�[39m�[22m�[49m: 
�[40m�[32minfo�[39m�[22m�[49m: <<XHARNESS_RESULT_START>>
      {
        "version": 1,
        "machineName": "CW3R43TWM6-1",
        "exitCode": 0,
        "exitCodeName": "SUCCESS",
        "platform": "apple",
        "device": "CW3R43TWM6-1",
        "deviceOsVersion": "macOS 26.5.2",
        "files": [
          {
            "name": "test-maccatalyst.log",
            "type": "executionlog"
          },
          {
            "name": "test-maccatalyst-20260726_150936.log",
            "type": "testlog"
          },
          {
            "name": "Microsoft.Maui.Controls.DeviceTests.log",
            "type": "systemlog"
          },
          {
            "name": "xunit-test-maccatalyst-20260726_150936.xml",
            "type": "xmllog"
          }
        ]
      }
      <<XHARNESS_RESULT_END>>
XHarness exit code: 0
  Passed: 0
  Failed: 0
  Tests completed successfully

🟢 With fix — 📱 CollectionViewTests: PASS ✅ · 967s
(no coded error found; showing last 1200 chars)

<private>
�[40m�[37mdbug�[39m�[22m�[49m: Killing process 70235 as it was cancelled
�[40m�[37mdbug�[39m�[22m�[49m: ==================== End of SystemLog ====================
�[40m�[37mdbug�[39m�[22m�[49m: 
�[40m�[32minfo�[39m�[22m�[49m: <<XHARNESS_RESULT_START>>
      {
        "version": 1,
        "machineName": "CW3R43TWM6-1",
        "exitCode": 0,
        "exitCodeName": "SUCCESS",
        "platform": "apple",
        "device": "CW3R43TWM6-1",
        "deviceOsVersion": "macOS 26.5.2",
        "files": [
          {
            "name": "test-maccatalyst.log",
            "type": "executionlog"
          },
          {
            "name": "test-maccatalyst-20260726_173121.log",
            "type": "testlog"
          },
          {
            "name": "MacCatalyst.system.log",
            "type": "systemlog"
          },
          {
            "name": "Microsoft.Maui.Controls.DeviceTests.log",
            "type": "systemlog"
          },
          {
            "name": "xunit-test-maccatalyst-20260726_173121.xml",
            "type": "xmllog"
          }
        ]
      }
      <<XHARNESS_RESULT_END>>
XHarness exit code: 0
  Passed: 0
  Failed: 0
  Tests completed successfully

🔴 Without fix — 📱 MemoryTests: PASS ❌ · 4865s
(no coded error found; showing last 1200 chars)

<private>
�[40m�[37mdbug�[39m�[22m�[49m: Killing process 41688 as it was cancelled
�[40m�[37mdbug�[39m�[22m�[49m: ==================== End of SystemLog ====================
�[40m�[37mdbug�[39m�[22m�[49m: 
�[40m�[32minfo�[39m�[22m�[49m: <<XHARNESS_RESULT_START>>
      {
        "version": 1,
        "machineName": "CW3R43TWM6-1",
        "exitCode": 0,
        "exitCodeName": "SUCCESS",
        "platform": "apple",
        "device": "CW3R43TWM6-1",
        "deviceOsVersion": "macOS 26.5.2",
        "files": [
          {
            "name": "test-maccatalyst.log",
            "type": "executionlog"
          },
          {
            "name": "test-maccatalyst-20260726_160955.log",
            "type": "testlog"
          },
          {
            "name": "MacCatalyst.system.log",
            "type": "systemlog"
          },
          {
            "name": "Microsoft.Maui.Controls.DeviceTests.log",
            "type": "systemlog"
          },
          {
            "name": "xunit-test-maccatalyst-20260726_160955.xml",
            "type": "xmllog"
          }
        ]
      }
      <<XHARNESS_RESULT_END>>
XHarness exit code: 0
  Passed: 0
  Failed: 0
  Tests completed successfully

🟢 With fix — 📱 MemoryTests: PASS ✅ · 474s
(no coded error found; showing last 1200 chars)

<private>
�[40m�[37mdbug�[39m�[22m�[49m: Killing process 76845 as it was cancelled
�[40m�[37mdbug�[39m�[22m�[49m: ==================== End of SystemLog ====================
�[40m�[37mdbug�[39m�[22m�[49m: 
�[40m�[32minfo�[39m�[22m�[49m: <<XHARNESS_RESULT_START>>
      {
        "version": 1,
        "machineName": "CW3R43TWM6-1",
        "exitCode": 0,
        "exitCodeName": "SUCCESS",
        "platform": "apple",
        "device": "CW3R43TWM6-1",
        "deviceOsVersion": "macOS 26.5.2",
        "files": [
          {
            "name": "test-maccatalyst.log",
            "type": "executionlog"
          },
          {
            "name": "test-maccatalyst-20260726_174737.log",
            "type": "testlog"
          },
          {
            "name": "MacCatalyst.system.log",
            "type": "systemlog"
          },
          {
            "name": "Microsoft.Maui.Controls.DeviceTests.log",
            "type": "systemlog"
          },
          {
            "name": "xunit-test-maccatalyst-20260726_174737.xml",
            "type": "xmllog"
          }
        ]
      }
      <<XHARNESS_RESULT_END>>
XHarness exit code: 0
  Passed: 0
  Failed: 0
  Tests completed successfully

⚠️ Failure Details

  • ❌ CollectionViewTests PASSED without fix (should fail) — tests don't catch the bug
  • ❌ MemoryTests PASSED without fix (should fail) — tests don't catch the bug

📁 Fix files reverted (3 files)

  • src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs
  • src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

📱 UI Tests — CollectionView

Detected UI test categories: CollectionView

❌ Deep UI tests — 308 passed, 81 failed across 1 category on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
CollectionView 308/390 (81 ❌) 162 diff PNGs
🔍 AI analysis of failures — PR-related vs unrelated

🔍 AI-generated triage (GitHub Copilot CLI) — a heuristic judgement of whether each deep UI test failure is connected to this PR's changes. Verify before relying on it.

Likely PR-related: one or more failures appear connected to this PR's changes.

  • ✗ PR-related — CollectionView Catalyst visual snapshots (~81 tests): every reported failure is a CollectionView screenshot mismatch, and the PR changes TemplatedCell.cs under the iOS CollectionView handler path, which also compiles for MacCatalyst and plausibly affects cell reuse, logical-child attachment, native subviews, and rendered item/header/footer/selection layout across the run.

Strongest signal: this is not a platform-mismatch case; the changed iOS handler code is in scope for the Catalyst run, and the failures are concentrated entirely in the modified CollectionView rendering area rather than spread across unrelated controls or infrastructure errors.

❌ CollectionView — 81 failed tests

VerifyCustomSizedEmptyViewDisplaysCorrectly_WithRightToLeftFlowDirection

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyCustomSizedEmptyViewDisplaysCorrectly_WithRightToLeftFlowDirection.png (16.39% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScr
...

CollectionViewSelectionModeOnDarkTheme

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewSelectionModeOnDarkTheme.png (15.36% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 re
...

ShouldIgnoreBottomContentInsetForCollectionViewItems

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: ShouldIgnoreBottomContentInsetForCollectionViewItems.png (22.38% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name,
...

CollectionViewHorizontalItemSpacing

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewHorizontalItemSpacing.png (20.98% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retry
...

CollectionViewGroupFooterTemplateShouldNotCrash

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewGroupFooterTemplateShouldNotCrash.png (20.11% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Null
...

VerticalGridCollectionViewRTLColumnMirroringShouldWork

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerticalGridCollectionViewRTLColumnMirroringShouldWork.png (17.30% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String nam
...

CollectionViewSingleItemAlignmentWithFooter

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewSingleItemAlignmentWithFooter.png (15.58% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable
...

HeaderShouldNotCollapseWithItems

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: HeaderShouldNotCollapseWithItems.png (16.18% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDel
...

VerifySelectionModeSingleWhenProgrammaticSelectionWorksWithVerticalList

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifySelectionModeSingleWhenProgrammaticSelectionWorksWithVerticalList.png (17.41% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance, Boolean includeTitleBar) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 296
   at Microsoft.Maui.TestCases.Tests.CollectionView_SelectionFeatureTests.VerifySelectionModeSingleWhenProgrammaticSelectionWorksWithVerticalList() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_SelectionFeatureTests.cs:line 515
   at System.RuntimeMethodHandle.InvokeMethod
...

ItemShouldbeScrolledbasedOnGroupHeader

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: ItemShouldbeScrolledbasedOnGroupHeader.png (15.69% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 re
...

VerifyFlowDirectionRTLAndMeasureAllItemsWithObservableCollection

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyFlowDirectionRTLAndMeasureAllItemsWithObservableCollection.png (19.80% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(
...

VerifyFlowDirectionRTLAndMeasureAllItemsWithGroupedList

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyFlowDirectionRTLAndMeasureAllItemsWithGroupedList.png (19.29% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String na
...

VerifyFlowDirectionLTRAndMeasureAllItemsWithObservableCollection

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyFlowDirectionLTRAndMeasureAllItemsWithObservableCollection.png (19.77% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(
...

CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation.png (17.87% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreen
...

PointerOverWithSelectedStateShouldWork

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: PointerOverWithSelectedStateShouldWork.png (19.09% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 re
...

CVHorizontalLinearItemsLayoutItemSpacing

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CVHorizontalLinearItemsLayoutItemSpacing.png (20.10% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 
...

ReorderBetweenGroupsShouldNotOccurWhenCanMixGroupsIsFalse

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: ReorderBetweenGroupsShouldNotOccurWhenCanMixGroupsIsFalse.png (22.26% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String 
...

VerifyDefaultScrollToRequested

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyDefaultScrollToRequested.png (16.94% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay
...

HeaderAndFooterShouldBeVisible

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: HeaderAndFooterShouldBeVisible.png (16.55% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay
...

FooterShouldBeRemovedWhenSetToNull

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: FooterShouldBeRemovedWhenSetToNull.png (14.62% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryD
...

VerifyCVBackgroundAndBackgroundColorWithVSM

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyCVBackgroundAndBackgroundColorWithVSM.png (19.10% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable
...

SingleItemAlignmentInCollectionViewHorizontalGridLayout

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: SingleItemAlignmentInCollectionViewHorizontalGridLayout.png (15.52% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String na
...

CollectionViewSelectedItemBackgroundLost

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewSelectedItemBackgroundLost.png (16.46% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 
...

FooterShouldDisplayAtBottomOfEmptyView

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: FooterShouldDisplayAtBottomOfEmptyView.png (14.54% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 re
...

VerifyScrollToByItemWithCenterPositionAndVerticalList_Carrot

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyScrollToByItemWithCenterPositionAndVerticalList_Carrot.png (16.98% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(Stri
...

VerticalItemsRemainFullyVisibleAfterChangingSpacing

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerticalItemsRemainFullyVisibleAfterChangingSpacing.png (17.33% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, 
...

CollectionViewShouldChangeItemsLayout

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewShouldChangeItemsLayout.png (25.56% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 ret
...

VerifyDataTemplateParentIsNotNull

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyDataTemplateParentIsNotNull.png (17.09% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDe
...

VerifyFlowDirectionLTRAndMeasureAllItemsWithGroupedList

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: VerifyFlowDirectionLTRAndMeasureAllItemsWithGroupedList.png (19.77% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 477
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String na
...

CollectionViewSelectionShouldClear

VisualTestUtils.VisualTestFailedException : 
Snapshot different than baseline: CollectionViewSelectionShouldClear.png (22.65% difference)
If the correct baseline has changed (this isn't a a bug), then update the baseline image.
See test attachment or download the build artifacts to get the new snapshot file.

More info: https://aka.ms/visual-test-workflow
at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance, Boolean includeTitleBar) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 296
   at Microsoft.Maui.TestCases.Tests.Issues.Issue30363.CollectionViewSelectionShouldClear() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30363.cs:line 21
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at S
...

(+51 more — see TRX in artifact)

📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

📋 Pre-Flight — Context & Validation

Issue: #35985 - [Testing] Re-enable Cells and Handler Memory Leak Device Tests for June 08 Candidate Branch PR: #36698 - [iOS & Mac] Fix and Re-enable "Cells Do Not Leak" and "Handler Does Not Leak" Device Tests Platforms Affected: iOS, MacCatalyst, Windows (issue); PR changes legacy iOS/MacCatalyst CollectionView cell cleanup and device tests Files Changed: 3 implementation/API, 2 test

Key Findings

  • PR addresses a memory leak where legacy iOS/MacCatalyst templated CollectionView cells keep bound views rooted through logical children and native subviews.
  • PR also updates the Cells Do Not Leak device test to tear down local references and re-enables Switch in the handler leak matrix.
  • Gate was skipped before this run because no tests were detected by the gate script; PR itself does contain device-test edits and should have targeted device validation.
  • Independent code review found a high-confidence reuse risk: Unbind() removes native subviews but same-template Bind() only restores the logical child, so an off-screen unbound cell reused with the same template can render blank.

Code Review Summary

Verdict: NEEDS_CHANGES Confidence: low Errors: 1 | Warnings: 0 | Suggestions: 0

Key code review findings:

  • ✗ src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs:99 — ClearSubviews() in Unbind() detaches the native platform view while leaving PlatformHandler/CurrentTemplate intact; same-template reuse re-adds only the logical child and can leave the cell blank.

Fix Candidates

Source Approach Test Result Files Changed Notes

PR PR #36698 Detach logical child and native subviews from TemplatedCell.Unbind(), call Unbind() from deterministic Dispose(bool), and re-add same-template logical children in Bind() ⚠️ SKIPPED (Gate) TemplatedCell.cs, PublicAPI, device tests Original PR; code review found missing native reattachment on same-template reuse
🔬 Code Review — Deep Analysis

Code Review — PR #36698

Independent Assessment

What this changes: Fixes legacy iOS/MacCatalyst CollectionView cell leaks by detaching cell content from logical/native trees during unbind/dispose and re-enables memory tests. Inferred motivation: Address leaked templated cells/views exposed by memory tests.

Reconciliation with PR Narrative

Author claims: Logical/native references kept templated views rooted; tests were corrected/re-enabled. Agreement/disagreement: Root cause aligns, but the native detach path misses a reuse case.

Prior Review Reconciliation

No prior ❌ Error findings found. GitHub reviews/inline comments were empty; issue comments only contained CI trigger/dogfood comments.

Blast Radius Assessment

  • Runs for all instances: Legacy iOS/MacCatalyst Items/ templated CollectionView cells using this handler.
  • Startup impact: No.
  • Static/shared state: No.

CI Status

  • Required-check result: gh pr checks --required unavailable due missing auth.
  • Public API check-runs: failing (maui-pr-uitests, maui-pr-devicetests, Build Analysis).
  • Classification: undetermined.
  • Action taken: invoked azdo-build-investigator; confidence capped low.

Findings

❌ Error — Reused cells can render blank after Unbind

src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs:99

Unbind() now calls ClearSubviews(), removing the native platform view from ContentView, but leaves PlatformHandler and CurrentTemplate intact. On same-template reuse, Bind() only re-adds the logical child at lines 266-268; it does not call SetRenderer()/SetupPlatformView(), so the native view remains detached and the reused cell can appear empty.

The updated test drops the cell after Unbind() and does not rebind it, so it does not catch this failure.

Failure-Mode Probing

  • Cell unbound off-screen then reused with same template: logical child is restored, native subview is not; likely blank cell.
  • Dispose path: disposing == true avoids finalizer-thread managed access; idempotent enough.
  • Null parent: guarded, but re-add only fixes logical tree, not native tree.

Verdict: NEEDS_CHANGES

Confidence: low overall due unauthenticated required-check status and red public check-runs; high confidence in the code-path finding. Summary: Leak cleanup direction is reasonable, but native subview removal needs a matching same-template reattachment/reset path before merge.

🛠️ Fix — Analysis & Comparison

Fix Candidates

Source Approach Test Result Files Changed Notes

1 try-fix-1 Destructive content release: after Unbind() detaches logical/native content, clear PlatformHandler and CurrentTemplate so next same-template Bind() creates fresh content ✅ PASS 1 file Corrects blank reuse risk but increases allocations/content recreation; not selected
2 try-fix-2 Targeted native reattachment: keep PR cleanup, and on same-template reuse re-add detached native platform view to ContentView when Superview is null ✅ PASS 1 file Fixes the PR's missing native reattachment with less churn; selected
PR PR #36698 Detach logical child and native subviews in Unbind(), call Unbind() from deterministic Dispose(bool), and re-add only logical child on same-template reuse ⚠️ SKIPPED (Gate) 5 files Original PR; expert review found reused cells can render blank after native subview removal

Test Results

Candidate Command Result
try-fix-1 pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter "Category=CollectionView" -IncludeClasses "Microsoft.Maui.DeviceTests.CollectionViewTests" -Timeout "00:20:00" ✅ PASS — xharness exit 0; Tests run: 46 Passed: 42 Failed: 0 Ignored: 4
try-fix-2 pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter "Category=CollectionView" -IncludeClasses "Microsoft.Maui.DeviceTests.CollectionViewTests" -Timeout "00:20:00" ✅ PASS — xharness exit 0; Tests run: 46 Passed: 42 Failed: 0 Ignored: 4
try-fix-2 pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter "Category=Memory" -IncludeClasses "Microsoft.Maui.DeviceTests.Memory.MemoryTests" -Timeout "00:20:00" ✅ PASS — xharness exit 0; Tests run: 56 Passed: 55 Failed: 0 Ignored: 1

Cross-Pollination

Model/Reviewer Round New Ideas? Details
maui-expert-reviewer 1 Yes Suggested (1) native reattachment on same-template reuse, (2) destructive content release, and (3) disconnect/reconnect via weak reusable view.
main loop 2 No Stopped after candidate 2 passed CollectionView and Memory slices and addressed the expert review error more directly than candidate 1 or the PR. The disconnect/reconnect approach was not run because it is higher lifecycle risk and not meaningfully better than targeted reattachment.
Baseline note: EstablishBrokenBaseline.ps1 could not establish a without-fix baseline because the working directory already had unrelated uncommitted .github changes outside this PR. Per autonomous execution instructions, the loop continued with candidate diffs relative to the checked-out PR state and restored the touched PR file afterward.

Exhausted: No — stopped because candidate 2 passed the targeted MacCatalyst regression slices and is demonstrably better than the PR's current fix. Selected Fix: Candidate #2 — targeted native reattachment. It directly fixes the PR's missing native-tree restoration on same-template reuse without the allocation/performance cost of candidate #1.

📝 Recommended PR Title & Description

Assessment: ✏️ Recommend updating — the current metadata is mostly detailed, but the winning fix now includes same-template native reattachment and focused reuse coverage that the title/description do not mention.

Recommended title

[iOS & MacCatalyst] CollectionView: Fix templated cell leak and reuse cleanup

Recommended description

### Issue Details

The device memory leak validation tests began failing in the Candidate branch after the test-related changes introduced in PR https://github.com/dotnet/maui/pull/35487, which exposed actual memory leaks that were previously undetected. The regressions affected the Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and the Handler Does Not Leak test on macOS 26.0, indicating platform-specific memory leak issues that require fixes.

### Root cause

The iOS/MacCatalyst legacy `CollectionView` templated cell leak occurs because a templated cell registers its bound view as a logical child of the parent items view when bound, but previously only removed that registration when the cell was rebound to a different template — never when a cell was simply bound once and then discarded without being recycled. This permanently rooted the templated view and its subviews in the parent's children list, preventing collection.

A related native-side reference on the cell's `ContentView` could independently keep the platform view, and therefore the bound view, reachable even if the logical-child link were cleared. The leak test itself also had a bug: it never released its local cell, handler, and control references before checking for garbage collection, which kept them rooted for the whole test and masked the production issue.

### Solution description

The fix detaches the bound view from the parent's logical children and clears the cell's native subviews during deterministic teardown, so cleanup happens when the cell is recycled, replaced, or discarded. Because that teardown can remove the native platform view before the cell is reused, the same-template `Bind()` path also restores the native platform view to the cell `ContentView` when it has no superview, in addition to restoring the logical child.

The `Cells Do Not Leak` device test now explicitly tears down the cell and owning control, then nulls local references before verifying collection. A focused iOS/MacCatalyst regression test also covers `Unbind()` followed by same-template `Bind()` to ensure reused cells regain native content instead of rendering blank.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the `Switch` control. Therefore, the "Handler Doesn't Leak" test case has been re-enabled for the `Switch` control.

Validated the behavior in the following platforms:

- [x] iOS
- [x] MacCatalyst
- [ ] Android
- [ ] Windows

### Regression PR

PR https://github.com/dotnet/maui/pull/35487

### Issues Fixed

Fixes https://github.com/dotnet/maui/issues/35985

### Output Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0"> |<video src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

🏁 Report — Final Recommendation

Comparative Candidate Report — PR #36698

Candidates compared

Rank Candidate Result Assessment
1 pr-plus-reviewer ✅ PASS on MacCatalyst CollectionView and Memory slices Best candidate. Keeps the PR's logical/native leak cleanup, adds native reattachment on same-template reuse, and adds a focused regression test for the reviewer-identified blank-cell path.
2 try-fix-2 ✅ PASS on MacCatalyst CollectionView and Memory slices Strong implementation candidate. It uses the same targeted native reattachment strategy and avoids extra content recreation, but it lacks the added regression test from the expert reviewer feedback.
3 try-fix-1 ✅ PASS on MacCatalyst CollectionView slice Correctly avoids the blank-cell reuse bug by destructively forgetting PlatformHandler/CurrentTemplate, but it forces content recreation on reuse and has higher allocation/performance risk in CollectionView hot paths.
4 pr ⚠️ Gate skipped; expert review found a critical regression The raw PR fixes the leak direction, but Unbind() removes native subviews while same-template Bind() restores only the logical child. A recycled cell can render blank after off-screen unbind/rebind.

Key comparison

The raw PR is not acceptable as-is because it fixes a memory root but breaks the same-template reuse lifecycle: ClearSubviews() removes the native platform view, and the same-template branch only calls AddLogicalChild(). try-fix-1 and try-fix-2 both address that regression and passed targeted Catalyst validation, so they must rank above the raw PR.

Between the two STEP 5a candidates, try-fix-2 is better than try-fix-1: it restores the native view only when it has been detached, which directly repairs the regression without forcing fresh content creation on every reuse. The pr-plus-reviewer candidate incorporates that targeted approach and adds reviewer-requested regression coverage for Unbind() followed by same-template Bind(), making it stronger than try-fix-2.

Winning candidate

Winner: pr-plus-reviewer

pr-plus-reviewer is the best single candidate because it preserves the PR's intended memory leak fix, fixes the expert-reviewed blank-cell regression, and verifies both the CollectionView and Memory slices on MacCatalyst. No candidate with failed regression tests ranked above a passing candidate; there were no observed regression-test failures among the non-PR try-fix candidates.

🧭 Next Steps — review latest findings

I have checked the review comments and validated the concerns raised through real device testing. The analysis correctly identified the core reuse regression.

ClearSubviews() was kept in Unbind() as suggested, since removing it broke other tests that depend on proper native-view cleanup. Targeted reattachment was added in Bind() 's same-template branch (only when Superview is null ), matching the recommended "try-fix-2" approach.

Two additional issues surfaced during device testing beyond the original review scope:

  1. A NullReferenceException when measuring a mid-unbind cell — fixed with a bound-state guard.
  2. A handler leak in ItemsViewController 's measurement-cell cache — fixed with a dedicated UnbindAndDisconnect() teardown path.

@BagavathiPerumal

Copy link
Copy Markdown
Contributor Author

CI Merge-Readiness: ❌ Not ready

Analyzed builds on head 6a16b28.

Check Verdict
maui-pr 1523328 ✅ pass
maui-pr-uitests 1524530 🔴 PR-caused
maui-pr-devicetests 1524531 🔴 PR-caused
Build Analysis 🔴 0 known-issue matches

UI tests — 27 failures, none on baseline

Compared test-by-test against 5 recent main builds of maui-pr-uitests (1526484, 1518286, 1503618, 1503332, 1503036). Every failure is new; not one matched a baseline failure in the same suite.

Suite PR main baselines
CarouselView_CARV1_ios 14 0, 0, 0, 0, 0
CarouselView_ios 5 0, 0, 0, 0, 0
CollectionView_CV1_ios 5 0, 0, 0, 0, 0
CarouselView_mac 3 0, 0, 0, 0, 0
CollectionView_ios (Items2) 0 0, 0, 0, 0, 0
CollectionView_mac (Items2) 0 0, 0, 1, 0, 1
Notable failures:

  • Issue29411.VerifyLoopChangeAtRuntimeShouldNotCrash — System.NullReferenceException
  • Issue17283.CarouselViewShouldScrollToRightPosition, Issue10234.ScrollCarouselViewAfterDispose, Issue28557.CarouselViewShouldNotCrashOnSourceUpdateWithPageNavigation, CarouselViewUpdateCurrentItem.Issue9827Test, CarouselViewUITests.NavigateForwardWhenLooped, NavigateBackWhenLooped, Issue17969.CollectionViewAddGroupWhenViewIsEmpty, Issue12374.Issue12374Test — app crashes
  • Issue32243.CollectionViewDisconnectsHandlersAfterNavigationBack — ⚠️ 2 labels still have connected handlers (expected ✓ No labels have connected handlers)
  • Issue29491.VerifyDataTemplateParentIsNotNull — screenshot diff 11.97%
  • Issue32139.ValidateNoScrollOnInvalidItemWithLoop — screenshot diff 5.21%
  • 12 further System.TimeoutException : Timed out waiting for element

The attribution is hard to argue with: this PR only touches Items/iOS/TemplatedCell.cs, i.e. the legacy iOS CollectionView/CarouselView handler — and the Items2 suites (CollectionView_ios, CollectionView_mac) are the only iOS/Mac suites at zero failures. The regressions land precisely on the code path that changed.

The crashes, the NRE, and the CollectionViewDisconnectsHandlersAfterNavigationBack assertion all point the same way: the new Dispose(bool) → Unbind() → DetachFromItemsView() + ClearSubviews() path is tearing the cell down while UIKit still expects it to be live. Unbind() is called from PrepareForReuse and from cell recycling, so now every recycle also rips the platform view out of the ContentView and drops the logical child — not just the deallocation case.

Device tests — Android CoreCLR regression

Run DeviceTests Android (CoreCLR) failed:

[FAIL] Items Do Not Leak
  Expected all references to be collected, but some are still alive.
  at Microsoft.Maui.DeviceTests.AssertionExtensions.WaitForGC(WeakReference[] references)

That leg is green on 6/6 recent main builds (1526485, 1518287, 1503431, 1503150, 1503037, 1499502), so it qualifies as regressed-vs-base. Likely vector: MemoryTests.cs removes the #if TESTS_FAILS_ON_MACCATALYST guard around [InlineData(typeof(Switch))]. That symbol is never defined, so the guard was suppressing the case on every platform — removing it enables the Switch leak test on Android and Windows too, not just Catalyst.

Test gate

The AI gate reported ❌ FAILED — the re-enabled tests passed both with and without the fix, so they do not currently reproduce #35985.

Suggested next steps

  1. Investigate the legacy-handler crashes/NRE — Unbind() runs on recycle, not only on teardown, so ClearSubviews() + RemoveLogicalChild there is likely too aggressive.
  2. Re-scope the Switch InlineData to MacCatalyst only (e.g. #if MACCATALYST) instead of removing the guard, so Android/Windows are untouched.
  3. Strengthen the re-enabled CellsDoNotLeak / HandlerDoesNotLeak tests so they actually fail without the fix.

🤖 Automated CI analysis — no approval or change request implied; a human review is still required.

I have checked all 27 flagged failures ( CarouselView_CARV1_ios , CarouselView_ios , CollectionView_CV1_ios , CarouselView_mac ) including VerifyLoopChangeAtRuntimeShouldNotCrash , CarouselViewShouldScrollToRightPosition , ScrollCarouselViewAfterDispose , and CarouselViewShouldNotCrashOnSourceUpdateWithPageNavigation , root-caused them, applied fixes in TemplatedCell / ItemsViewController , and verified all pass on a real iOS 18.4 simulator.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Jul 27, 2026
@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 28, 2026
BagavathiPerumal and others added 8 commits August 8, 2026 14:54
…ctionView, stepper and HybridWebView.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
…ssion, NullReferenceException in cell measurement, and handler leak in the measurement-cell cache within TemplatedCell/ItemsViewController.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
…achment in Bind() 's same-template branch, since Unbind() no longer detaches the native subview, preventing duplicate Auto Layout constraints from SetupPlatformView() accumulating across reuse cycles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
…uring conflict resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
…or-cleanup logic in ItemsViewController.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
…add a  _disposed  re-entrancy guard, and release prior content in  UseContent()  before adopting the donor's.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
@kubaflo
kubaflo merged commit 670873b into dotnet:inflight/current Aug 8, 2026
2 of 11 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR10 milestone Aug 8, 2026
kubaflo added a commit that referenced this pull request Aug 12, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
BagavathiPerumal added a commit to BagavathiPerumal/maui that referenced this pull request Aug 20, 2026
kubaflo pushed a commit that referenced this pull request Aug 20, 2026
…er Does Not Leak" Device Tests (#37672)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue details:

PR #36698 aimed to fix and re-enable the "Cells Do Not Leak" and
"Handler Does Not Leak" device memory-leak tests on iOS and Mac. To
achieve this, it changed `TemplatedCell` and `ItemsViewController` on
iOS so that a cell's bound view is detached from the parent's logical
children — and the cell's native subviews are cleared — during disposal,
ensuring templated views are released deterministically instead of being
permanently rooted.

After this change merged, the `NavigateForwardWhenLooped` and
`NavigateBackWhenLooped` CarouselView UI tests started failing on iOS.

### Description of changes:

This reverts the changes introduced in PR #36698, which modified
`TemplatedCell.cs` and `ItemsViewController.cs` on iOS/MacCatalyst to
detach a cell's bound view from the parent's logical children and clear
its native subviews during disposal.

Reverting restores the prior cell disposal behavior, fixing the
CarouselView looped-navigation regression (#37571). As a side effect, it
also re-introduces the original memory-leak test failures that PR #36698
addressed.

### 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 #37571

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@sheiksyedm sheiksyedm modified the milestones: .NET 10 SR10, .NET 10 SR11 Aug 26, 2026
kubaflo added a commit that referenced this pull request Aug 27, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo added a commit that referenced this pull request Sep 2, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms

- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

PR #35487

Fixes #35985

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo added a commit that referenced this pull request Sep 3, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
…er Does Not Leak" Device Tests (#37672)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue details:

PR #36698 aimed to fix and re-enable the "Cells Do Not Leak" and
"Handler Does Not Leak" device memory-leak tests on iOS and Mac. To
achieve this, it changed `TemplatedCell` and `ItemsViewController` on
iOS so that a cell's bound view is detached from the parent's logical
children — and the cell's native subviews are cleared — during disposal,
ensuring templated views are released deterministically instead of being
permanently rooted.

After this change merged, the `NavigateForwardWhenLooped` and
`NavigateBackWhenLooped` CarouselView UI tests started failing on iOS.

### Description of changes:

This reverts the changes introduced in PR #36698, which modified
`TemplatedCell.cs` and `ItemsViewController.cs` on iOS/MacCatalyst to
detach a cell's bound view from the parent's logical children and clear
its native subviews during disposal.

Reverting restores the prior cell disposal behavior, fixing the
CarouselView looped-navigation regression (#37571). As a side effect, it
also re-introduces the original memory-leak test failures that PR #36698
addressed.

### 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 #37571

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo added a commit that referenced this pull request Sep 3, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo added a commit that referenced this pull request Sep 4, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo pushed a commit that referenced this pull request Sep 4, 2026
…er Does Not Leak" Device Tests (#37672)

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue details:

PR #36698 aimed to fix and re-enable the "Cells Do Not Leak" and
"Handler Does Not Leak" device memory-leak tests on iOS and Mac. To
achieve this, it changed `TemplatedCell` and `ItemsViewController` on
iOS so that a cell's bound view is detached from the parent's logical
children — and the cell's native subviews are cleared — during disposal,
ensuring templated views are released deterministically instead of being
permanently rooted.

After this change merged, the `NavigateForwardWhenLooped` and
`NavigateBackWhenLooped` CarouselView UI tests started failing on iOS.

### Description of changes:

This reverts the changes introduced in PR #36698, which modified
`TemplatedCell.cs` and `ItemsViewController.cs` on iOS/MacCatalyst to
detach a cell's bound view from the parent's logical children and clear
its native subviews during disposal.

Reverting restores the prior cell disposal behavior, fixing the
CarouselView looped-navigation regression (#37571). As a side effect, it
also re-introduces the original memory-leak test failures that PR #36698
addressed.

### 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 #37571

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo added a commit that referenced this pull request Sep 6, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
kubaflo added a commit that referenced this pull request Sep 7, 2026
…ot Leak" Device Tests (#36698)

<!-- 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!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Issue Details

The device memory leak validation tests began failing in the Candidate
branch after the test-related changes introduced in PR
#35487, which exposed actual memory
leaks that were previously undetected. The regressions affected the
Cells Do Not Leak and Handler Does Not Leak tests on Windows, the Cells
Do Not Leak test on iOS, the Handler Does Not Leak test on iOS 26.0, and
the Handler Does Not Leak test on macOS 26.0, indicating
platform-specific memory leak issues that require fixes.

### Root cause

The issue occurs because of a templated cell registering its bound view
as a logical child of the parent items view when bound, but only
removing that registration when the cell was rebound to a different
template — never when a cell was simply bound once and then discarded
without being recycled. This permanently rooted the templated view, and
its subviews, in the parent's children list, preventing collection.

A related native-side reference on the cell's content view could
independently keep the platform view (and bound view) reachable even if
the logical-child link were cleared. The leak test itself also had a
bug: it never released its local cell, handler, and control references
before checking for garbage collection, which kept them rooted for the
whole test and masked the production issue.

### Solution description

The fix involves detaching the bound view from the parent's logical
children and clearing the cell's native subviews during disposal, on the
deterministic (non-finalizer) teardown path, so cleanup happens
regardless of whether the cell was recycled, replaced, or simply
discarded. It also involves correcting the test to explicitly tear down
the cell and its owning control, then null out all local references,
before verifying collection — since without this, the fix could never be
exercised or proven in the test.

**Note**: The issue, "Handler Does Not Leak," was not reproduced in the
Switch control. Therefore, the "Handler Doesn't Leak" test case has been
re-enabled for the Switch control.

Validated the behavior in the following platforms
 
- [x] iOS
- [x] Mac
- [ ] Android
- [ ] Windows

### Regression PR

PR #35487
 
### Issues Fixed
  
Fixes #35985

### Output  Screenshot

|Platform|Before|After|
|--|--|--|
|iOS|<video
src="https://github.com/user-attachments/assets/9a59cc41-bf7b-4781-bffb-1d4eb6cd6da0">
|<video
src="https://github.com/user-attachments/assets/dd527177-0022-4465-b7a1-303882f19f2e">|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 71612044-ad1f-454b-952b-004fa14c1744
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst s/agent-fix-win AI found a better alternative fix than the PR s/agent-review-incomplete AI review did not complete all expected phases s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing] Re-enable Cells and Handler Memory Leak Device Tests for June 08 Candidate Branch

7 participants