Repository navigation
[iOS/MacCatalyst] Fix CollectionView crash during incremental loading - #40481
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
2848169 to
a61b68c
Compare
|
/review run-tests |
This comment has been minimized.
This comment has been minimized.
76ae42f to
0afe07d
Compare
Skill Validation Results
❌ Skill Validation Results —
|
0afe07d to
a9f021e
Compare
|
/review expert-review-with-gate |
|
Warning Your |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/review expert-review-with-gate |
66bc022 to
feb1232
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit feb1232.
There was a problem hiding this comment.
🔵 Needs a closer look
The fix relies on native UIKit callback ordering that remains unverified, so the regression test must be confirmed to fail without the guard and pass with it on both iOS and MacCatalyst.
No open issues 🎉
What changed in this PR
This PR addresses the iOS/MacCatalyst CollectionView incremental-loading crash reported in #40467, linked to scroll behavior introduced by #39493.
Changes:
- Prevents synchronous re-entry into remaining-items threshold notifications, resetting the guard in a
finallyblock. - Skips threshold evaluation if the item source changes during the
Scrolledevent. - Adds device tests for incremental page loading, command re-entry, and source changes during scrolling.
| File | Description |
|---|---|
| src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.iOS.cs | Adds paging, re-entry, and source-change regression tests. |
| src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewDelegator2.cs | Guards threshold notifications against synchronous re-entry and replaced sources. |
Review effort: Balanced
<!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change <!-- Enter description of the fix in this section --> Backport #40481 from `release/11.0.1xx-sr2` to `net11`. The change prevents re-entrant CollectionView remaining-items threshold notifications and skips threshold evaluation when the scrolled event replaces the items source. It includes the original iOS/MacCatalyst device tests. Source commit: `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`. **Validation** - `git diff --cached --check` - passed. - `git diff --cached | git patch-id --stable` - matched the patch ID of source commit `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`. - Building `Microsoft.Maui.BuildTasks.slnf` failed locally with `NETSDK1140`: the installed Apple workload accepts platform version 27.2 while the projects request 27.0. - iOS and MacCatalyst device tests were not run locally; CI validation is required. ### 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. --> Relates to #40467. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. -->
…0578) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change <!-- Enter description of the fix in this section --> Backport dotnet#40481 from `release/11.0.1xx-sr2` to `net11`. The change prevents re-entrant CollectionView remaining-items threshold notifications and skips threshold evaluation when the scrolled event replaces the items source. It includes the original iOS/MacCatalyst device tests. Source commit: `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`. **Validation** - `git diff --cached --check` - passed. - `git diff --cached | git patch-id --stable` - matched the patch ID of source commit `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`. - Building `Microsoft.Maui.BuildTasks.slnf` failed locally with `NETSDK1140`: the installed Apple workload accepts platform version 27.2 while the projects request 27.0. - iOS and MacCatalyst device tests were not run locally; CI validation is required. ### 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. --> Relates to dotnet#40467. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. -->
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.This pull request improves the reliability of the "remaining items threshold" feature in CollectionView on iOS by preventing re-entrant threshold notifications during rapid or synchronous collection updates. It also introduces a new test to ensure that additional pages are loaded correctly while scrolling, and that the threshold command is not invoked again before its previous execution completes.
Regression introduced by: #39493. Its scroll during collection-update finalization can trigger a nested threshold notification while the previous command is still adding items.
Description of Change
CollectionView RemainingItemsThreshold reliability improvements:
_notifyingThresholdflag toItemsViewDelegator2to prevent re-entrant calls to the threshold notification logic while it is already processing, ensuring that the threshold command cannot be triggered multiple times simultaneously. [1] [2] [3]Testing enhancements:
RemainingItemsThresholdLoadsPagesWhileScrollinginCollectionViewTests.iOS.csto verify that the CollectionView loads additional pages as the user scrolls, and to assert that the threshold command does not re-enter before finishing its previous invocation.Issues Fixed
Fixes #40467
Tested the behavior in the following platforms
BeforeFix40467.mov
AfterFix40467.mov