Skip to content

Tests: UI tests that render with wgpu take turns, so the Windows test run no longer crashes - #1292

Merged
aiongg merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/gpu-tests-take-turns
Oct 25, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
dotCooCoo:fix/gpu-tests-take-turns

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

On Windows without cargo-nextest, cargo test -p deckcraft-ui-egui --lib often exits with 0xc0000005 (STATUS_ACCESS_VIOLATION), so cargo xtask ci stops at its test step. The tests that render pass with --test-threads=1. Several open pull requests name this crash as pre-existing (#806, #825, #940, #945).

Harness::render creates a wgpu device on its first call, and egui_kittest prefers a CPU adapter. When cargo test runs several of these tests on parallel threads, the test binary can exit with 0xc0000005. On main at 7be391a, on Windows 11 (x86-64):

  • the 13 tests that call render, run in parallel, crashed in 7 of 8 runs;
  • the same 13 tests with --test-threads=1 passed in 5 of 5 runs;
  • the other 245 tests, run in parallel, did not crash in 5 of 5 runs.

What changes:

  • New crate::gpu_lock::gpu_lock() (test-only), a mutex that the tests that render hold for their whole run, so only one of them runs at a time, copied from photocraft's crates/testkit/src/gpu.rs.
  • The 16 tests that call render (three of them ignored screenshot writers) take it on their first line.

Tests: gpu_lock::tests::holders_take_turns and a_panicked_holder_does_not_block_the_next_test check the lock itself.

With the change, the 13 tests that call render passed in 6 of 6 parallel runs, and the whole binary ran to the end in 4 of 4 parallel runs (255 passed). Each of those runs had one failure, replacefonts_tests::ribbon_button_opens_the_dialog_and_replaces, which also fails on main and which #1043 fixes.

A new test that calls render() takes the lock on its first line.

Checks: cargo fmt --all -- --check, cargo clippy -p deckcraft-ui-egui --all-targets -- -D warnings, cargo xtask assets and cargo xtask layers.

On Windows 11 (x86-64) with rustc 1.99.1, on top of main at 7be391a, with #1043 merged in:

  • cargo xtask ci passes its 8 steps: 1,793 tests passed, 0 failed, 6 ignored.

Without #1043, the gate stopped at its test step on control_server::tests::a_pipelined_peer_still_reads_why_its_line_was_rejected. That test and control_server::tests::blocked_ui_times_out_and_full_queue_is_busy fail intermittently on this machine on main at 7be391a as well (13 of 40 runs of the deckcraft test binary).

git merge-tree reports no conflicts with main at 7be391a.

Summary by CodeRabbit

  • Tests
    • GPU-rendered interface and screenshot tests now run sequentially, reducing interference between concurrent test runs and improving the consistency of test results. This covers tests for guides, rulers, spelling, thesaurus, and other interface areas.

… run no longer crashes

Harness::render creates a wgpu device on its first call, and egui_kittest
prefers a CPU adapter. When cargo test runs several of these tests on
parallel threads, the deckcraft-ui-egui test binary can exit with
0xc0000005 (STATUS_ACCESS_VIOLATION), so cargo xtask ci stops at its test
step on Windows without cargo-nextest.

The 16 tests that call render now hold one mutex for their whole run
(crate::gpu_lock::gpu_lock, as in photocraft's testkit), so only one of
them runs at a time.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7be391a and 44d5a0e.

Files selected for processing: 12
  • crates/ui-egui/src/animpane_tests.rs
  • crates/ui-egui/src/compare_tests.rs
  • crates/ui-egui/src/gpu_lock.rs
  • crates/ui-egui/src/guides_tests.rs
  • crates/ui-egui/src/inktoshape_tests.rs
  • crates/ui-egui/src/lib.rs
  • crates/ui-egui/src/replacefonts_tests.rs
  • crates/ui-egui/src/ruler_tests.rs
  • crates/ui-egui/src/smartart_tests.rs
  • crates/ui-egui/src/spelling_tests.rs
  • crates/ui-egui/src/texture_limit_tests.rs
  • crates/ui-egui/src/thesaurus_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

Selected UI rendering tests now acquire a shared GPU mutex before setting up their sessions or harnesses. The mutex recovers after poisoning. Tests verify poison recovery and that concurrent holders do not overlap.

Changes: GPU test serialization

Layer / File(s) Summary
Shared GPU lock
crates/ui-egui/src/gpu_lock.rs, crates/ui-egui/src/lib.rs
Adds a crate-visible mutex guard function with poison recovery. Tests check recovery after a panic and verify that concurrent holders do not overlap.
Lock acquisition in rendering tests
crates/ui-egui/src/*_tests.rs, crates/ui-egui/src/lib.rs
Selected UI and screenshot tests acquire the shared lock before creating sessions or harnesses and rendering.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

Suggested reviewers: nikitkara

Merge Risk: Minimal · up to 44d5a

The rendering tests are serialized as intended, and no issue requiring a fix before merge was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: serializing UI tests that render with wgpu to prevent Windows test-run crashes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants