wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Live filtering race condition fix

Open miloush opened this issue 1 year ago • 1 comments

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 avatar Sep 27 '24 09:09 miloush

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

h3xds1nz avatar Sep 27 '24 10:09 h3xds1nz

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

himgoyalmicro avatar Mar 05 '25 10:03 himgoyalmicro

It's a team effort!

miloush avatar Mar 05 '25 12:03 miloush