Skip to content

Lite test flake: ScreenReaderNamesFollowUpTests hits a WPF dictionary from two threads #5559

Closed

Description

@erikdarlingdata

A Lite test failed in CI with a corrupted WPF dictionary. The test it hit, ScreenReaderNamesFollowUpTests.HiddenElementsInATemplatedCell_AreNotContent, does not touch the code the PR changed.

What failed:

InvalidOperationException : Operations that change non-concurrent collections must have exclusive access.
  at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
  at MS.Internal.ComponentModel.DependencyObjectPropertyDescriptor.AddValueChanged(Object component, EventHandler handler)
  at PerformanceMonitor.Ui.AccessibleNames.ActivateCell(DataGridCell cell)  (AccessibleNames.cs:168)

Seen once, on 2026-10-08, in a pull request's Lite shard 0 (1 of 673 failed). It has not been seen on dev yet.

The likely cause, not yet proven: the test builds its window on an STA thread of its own (OnStaThread, ScreenReaderNamesFollowUpTests.cs:33). Other Lite test classes do the same and run in parallel. AddValueChanged goes through a static WPF cache that is not safe for two threads at once. In the app there is one UI thread, so this is a test problem, not a product one.

To fix: run the Lite tests that build WPF elements one at a time, in one shared xUnit collection or on one shared STA thread. Keep every existing check. Show the failure on purpose first, at head and at the base, then show the fix holds.

Claude posting for Erik Darling.

Activity

  1. erikdarlingdata commented on Oct 8, 2026

    @erikdarlingdata
    OwnerAuthor

    Seen again on 2026-10-08, on the same pull request's rerun of Lite shard 0. This time the test was ScreenReaderRowNamesTests.AGridRow_SkipsHiddenColumnsAndReadsTemplatedColumns_AndFollowsTheDisplayOrder, with the same error from the same WPF dictionary. That is two failures in two attempts on that shard, while three other pull request runs on the same dev passed it. A second test class hitting the same error fits the cause above: two test classes building WPF elements at the same time.

    Claude posting for Erik Darling.

  2. added
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Oct 8, 2026
  3. erikdarlingdata commented on Oct 8, 2026

    @erikdarlingdata
    OwnerAuthor

    Fixed by #5567, merged into dev. The Lite and Viewer test classes that build WPF elements on their own UI thread now take one shared gate, so no two of them use WPF's shared property cache at once. A census in each test project fails when a new class starts a UI thread outside the gate. Claude posting for Erik Darling.

  4. removed
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions