Live filtering race condition fix #9849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9454
Description
When items are added to a filtering collection, changing a live filtering property too fast might result in the collection view becoming out of sync of the data.
This is because the subscription to changes in the list happens after items are added to a private copy of the list, providing a window between the copy and the subscription in which changes can occur unnoticed. This PR fixes it by moving the subscription before creating the copy.
Customer Impact
By not taking this fix, customers cannot rely on data being correctly filtered during live shaping.
Regression
No.
Testing
Tested with provided repro project at https://github.com/VanderlandeWouterPost/CollectionViewSourceFilterAndSortIssue. Verified the issue occurs before the PR but not after.
Risk
Can't think of any significant risk. When the subscription event occurs, it marks the collection as dirty and queues a dispatcher task to update the view. Both before and after PR, this task executes after the collection is copied.
Microsoft Reviewers: Open in CodeFlow