Skip to content

[Tests] Round 3: job-wake waiters, font factory, remote hold bound, late first-frame poll - #73

Merged
xnetcat merged 4 commits into
mainfrom
fix/flaky-tests-round3
Dec 3, 2026
Merged

xnetcat merged 4 commits into
mainfrom
fix/flaky-tests-round3

Conversation

@xnetcat

@xnetcat xnetcat commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Before submitting

Please read our contribution guidelines before opening a pull request:

➡️ CONTRIBUTING.md

By opening this pull request, you confirm that you have read and agree to follow the contribution guidelines.

What this changes

Four intermittent Libs test failures, one commit each. All four are test-side changes. The only product file touched is MediaFramePlayback.cs, which gets an internal diagnostic method (DescribeState) and no behaviour change.

  • JobWakeRuntimeTests ("the waiter never went to sleep", then "Expected 0, Actual 2" in the next test): the waiters were thread-pool items that block for up to 10 s. A saturated pool started them more than 5 s late, and a late waiter left asleep was then woken by the next test. Fix: waiters get their own threads, and each test wakes its workers when it ends. With every pool worker blocked, all three tests fail before the fix and pass after.
  • FontTextLayoutTests under a filter: the class relied on another class to install the process-wide font factory. It now installs it itself. Run alone: 2 of 13 fail before, 13 of 13 pass after.
  • MediaFramePlaybackTests.FirstFrameWaitsUntilPresentationStarts: when the test thread is held up for more than 0.5 s, the next poll finds frame 2's time and the movie's end both passed, and playback finishes. That is the documented behaviour (a passed frame is never shown). The test now accepts either a later frame or a finished playback whose clock is past the movie's duration. A new 1.1 s late-poll case fails on the old assertion with the same state the full run printed.
  • HostCompileStallTests.ALongSleepIsHeldWhileTheRemoteWaits...: the upper bound is now an explicit 30 s max hold instead of grace + 1 s. The held sleep checks every 4 ms and returns at the first check past the end plus the grace, so a longer measured hold means a thread was not running. The failure message now prints the publish delay and the GC pause time.

Not changed, already fixed on main: the ParallelProgramPrefetch interrupt NRE (137530a) and the ResourcePreparationAllocationTests 5784 B case (it predates e9c4109).

Unverified: the media and HostCompileStall failures line up with test-process freezes of seconds to tens of seconds in full Libs runs on a heavily loaded machine. In one run, three unrelated tests failed within 0.4 s of each other. What causes the freeze is not known. Other wall-clock tests can still fail under such a freeze.

Testing

N/A (tests only, plus an internal diagnostic). REUSE lint passes. The Release build has 0 errors. Full dotnet test SharpEmu.slnx -c Release: every project passes except Libs, which has 12630 passed and 1 failed. The failure is SeatbeltSandboxProbeTests (AudioOutputUnitStart OSStatus 2003329396), a known local CoreAudio failure that this change does not touch. Class loops: 15 runs of the changed classes beside all Audio classes, 0 failures in the changed classes. The MacCoreAudioDeviceTests "device never consumed" failure appears in 10 of 15 loops both before and after this change. It is a separate, open issue.

No game was run.

Checklist

By submitting this pull request, you confirm that:

  • I have read and followed CONTRIBUTING.md.
  • I tested my changes or marked the testing section as N/A.
  • I wrote this pull request description myself and did not paste AI-generated explanations.
  • I listed the game(s) I tested (or marked the testing section as N/A).

…test ends

The waiters were thread-pool items that block for up to 10 s. In a full parallel Libs run
the pool is saturated by other blocking tests and injects threads slowly, so a waiter could
start more than 5 s late ("the waiter never went to sleep"). Its late start then left it
asleep in the process-wide sleeper mask, where the next test's wake over the other workers'
bits woke it ("Expected 0, Actual 2").

Reproduced with every pool worker blocked: all three waiter tests fail with the same message
before, pass after.
The exports read the process-wide factory, which only FontExportsTests and FontWritingTests
installed; a filtered run without them failed two tests with "No guest font factory was
selected". Before: 2 of 13 fail alone; after: 13 of 13.
…margin

ALongSleepIsHeldWhileTheRemoteWaitsAndReturnsWhenItEnds asserted the sleep returned within
grace + 1 s of the end; a full Libs run measured 2.43 s. The product's held sleep reads the
remote every 4 ms and returns at the first read past LastEnd + grace, so anything past that
is a thread (the sleeper, or the test before it published) not running. The case the bound
guarded against, a sleep that missed the end, now returns only at an explicit 30 s max hold
and is still told apart. The failure message reports the publish delay and the GC pause
time across the interval, to say which next time.
… its end

FirstFrameWaitsUntilPresentationStarts waited 10 s for frame 2 of a two-frame, 2 fps movie.
When the test thread is held up for more than 0.5 s after it starts the clock (a full Libs
run froze the test process for seconds to tens of seconds: the same moment failed
HostCompileStall and GameLibraryWatcher tests), the next poll swaps in frame 2 and, its
time already over, finishes the playback in the same call and returns false. That is the
documented product behaviour (a frame the clock has passed is never shown), so the test
now accepts either a later frame or a playback finished with its clock past the movie's
duration.

The theory case pollDelayMs=1100 fails with the old assertion exactly as the full run did
(current=1 decoded=2 finished=True) and passes now. MediaFramePlayback.DescribeState, an
internal diagnostic, is printed by the frame waits' timeouts (queued and decoded frames,
decoder thread, which clock and where it stands).
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

📦 Build artifacts — e1485eb

Platform Download
macOS (osx-x64) sharpemu-osx-x64-0c8d7d5
macOS app bundle (osx-x64) sharpemu-osx-x64-app-0c8d7d5

From build run #556. Downloads require a GitHub login and expire after 90 days.

@xnetcat
xnetcat merged commit 1a12f60 into main Dec 3, 2026
11 of 12 checks passed
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.

1 participant