Skip to content

Keep the Ctrl+A delete test at the four assemblies it opens - #4355

Open
christophwille wants to merge 1 commit into
masterfrom
christophwille/fix-ctrl-a-delete-test-hang
Open

christophwille wants to merge 1 commit into
masterfrom
christophwille/fix-ctrl-a-delete-test-hang

Conversation

@christophwille

@christophwille christophwille commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

SwitchListAndDeleteAllTests.Ctrl_A_Then_Delete_Drops_The_Selection_History_And_Tab never finished on my machine, so the last shard of runuitests.ps1 never ended.

Root cause

The test decompiles a sample from ILSpy.Tests.dll to build up history. That auto-loads the test assembly's whole reference closure, so the assembly list holds 214 top-level rows instead of 4 and Ctrl+A selects all of them.

  • The tab title becomes the comma-joined names of all 214 assemblies, about 12,200 characters.
  • While the resulting decompile runs, the tab-title spinner changes the title every 80 ms, and every change triggers a layout of that title. The headless test fonts are a stub with no fallback, so each layout is expensive.
  • The Ctrl+A is sent through Avalonia's KeyPress helper, which does not return until the dispatcher queue is empty. When a layout takes longer than the 80 ms spinner interval the queue never empties, and the test's own timeouts, which are only checked between pumps, never fire.

This comes from process dumps of the hung test host and from a probe test, not only from reading the code.

Change

Test only, in ILSpy.Tests/AssemblyList/SwitchListAndDeleteAllTests.cs:

  • The test turns off AutoLoadAssemblyReferences before decompiling, so the list stays at the four assemblies it means to select.
  • A new assertion before the Ctrl+A checks that the tree shows exactly 4 rows. Without the fix it fails in 4 s with "found 214" instead of hanging.

Verification

  • The fixture passes in 11 s (2 of 2).
  • ./runuitests.ps1 on Windows: all four shards exit 0 in 108 s, 1,350 tests, 0 failed, 1 skipped.

Why CI does not show it

CI goes through the same state and escapes it narrowly. A temporary probe test, run once on the Windows runner from a throwaway branch (since deleted), reported the same 214 assemblies and the same 12,220-character title as locally. The difference is the number of logical processors: 4 on the runner, 24 on my machine.

CI runner (4 processors) My machine (24)
Layout of the 12,220-char title 60-90 ms 315-385 ms
KeyPress returns after 646 ms (6 spinner ticks) never while the decompile runs
  • Running the same probe locally with DOTNET_PROCESSOR_COUNT=4 made KeyPress return in 1.7 s, in two runs. Turning server GC off alone, as the CI workflow does, changed nothing.
  • The test never waits for the decompile. Once KeyPress returns it sends Delete, which removes everything, so on CI it passes in about 3 s.
  • CI passes on a thin margin: the title layout there sits right at the 80 ms spinner interval.

Not established: the full mechanism behind the processor count. One contributor is identified. On every failed font-fallback lookup Avalonia's FontCollectionBase.TryGetCoveringMatch calls ConcurrentDictionary.Keys.ToArray(), which takes one lock per logical processor; that was the hot spot in four of four stack samples. But limiting the processor count made the layout only 1.3-1.6x faster locally, not the roughly 5x seen on CI.

Left alone

Three things the test tripped over that this PR does not touch:

  • The tab title is an unbounded join of every selected node's name.
  • XmlDocLoader.LoadDocumentation caches per module, so the whole 32 MB ref pack is re-indexed for each framework assembly that is decompiled (134 s of CPU in the hung run).
  • runuitests.ps1 has no per-shard timeout, so any future stuck test blocks it forever again.

🤖 Generated with Claude Code

Decompiling the sample from ILSpy.Tests.dll auto-loaded that assembly's
whole reference closure, so the list held 214 rows and Ctrl+A selected
all of them. The tab title became their joined names (about 12,000
characters), and the headless stub fonts took minutes to lay that out
inside Avalonia's KeyPress helper, which does not return until the
dispatcher queue is empty. The test's own timeouts never ran, and the
shard of runuitests.ps1 that contains it never ended.

Assisted-by: Claude:claude-fable-5-2:Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant