Skip to content

Live filtering race condition fix #9849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

miloush
Copy link
Contributor

@miloush miloush commented Sep 27, 2024

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

@miloush miloush requested review from a team as code owners September 27, 2024 09:59
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Sep 27, 2024
@h3xds1nz
Copy link
Member

LGTM, I was looking into this earlier when you've posted the workaround.

@himgoyalmicro himgoyalmicro merged commit e6639c7 into dotnet:main Mar 5, 2025
8 checks passed
@himgoyalmicro
Copy link
Contributor

Many thanks to @miloush for your relentless contributions. Your support is invaluable to our project! 😄

@miloush
Copy link
Contributor Author

miloush commented Mar 5, 2025

It's a team effort!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CollectionViewSource live filtering can hide item(s) when adding items and quickly changing their filter status afterwards.
3 participants