Repository navigation
feat(ci): Capture diagnostics when runtime tests stall - #24007
MartinZikmund wants to merge 6 commits into
Conversation
|
Claude finished @MartinZikmund's task in 5m 32s —— View job PR Review —
|
| # | Severity | Line | Summary |
|---|---|---|---|
| 1 | Minor | L158–168 | ManualResetEventSlim in ProbeThreadPool() is never disposed — leaks a kernel wait handle per tick and leaves a latent ObjectDisposedException risk in the thread-pool callback on the timeout path. Can be disposed on the success and queue-failed paths; timeout path must stay unmanaged. |
| 2 | Minor | L203–207 | _disposed guard in Dispose() is not volatile / not atomic — two concurrent callers can both pass the check, leading to double-Cancel + double-Dispose() on the CancellationTokenSource. Use Interlocked.CompareExchange on an int flag. |
| 3 | Minor | L212 | _thread.Join(2 s) is shorter than ProbeTimeout (5 s), so _cts.Dispose() can be called while the background thread is mid-probe. The practical race is near-zero (cancelled token short-circuits before the next WaitHandle access), but the join should cover the maximum blocking time. |
Nit — shell scripts
| # | Severity | Location | Summary |
|---|---|---|---|
| 4 | Nit | stall-watchdog.sh L138 |
Hard-timeout capture bypasses MAX_CAPTURES, so total captures can reach MAX_CAPTURES + 1. Intentional, but a one-line comment prevents future confusion. |
| 5 | Nit | macos-skia-runtime-tests.sh L41 |
APP_EXIT is captured and echoed but not acted on — add a comment confirming it's informational only, to avoid a "forgotten check" read-later. |
Cross-cutting notes
#nullable enableis correctly present at the top of the newTestRunStallMonitor.cs. TheUnitTestsControl.csfield_stallMonitoris declared without?(nullable-oblivious context, no#nullable enablein that file) — consistent with the pre-existing style of that file.- The
Interlocked.Exchange(ref _stallMonitor, null)?.Dispose()pattern inUnitTestsControl.csis correct and ensures only one caller reachesDispose()from the outside; the fix in finding Paths are either not shown or shown not as in the UWP Designer #2 adds the same safety inside the class. - No
event Action/event Action<T>— not applicable here. - No allocations in hot paths beyond what the diagnostic intent requires.
- Conventional Commits format (
feat(ci):) is correct. - The two Linux stages sharing a single template with
testResultLabel-suffixed artifact names is noted correctly in the PR description.
There was a problem hiding this comment.
Pull request overview
This PR improves diagnosability of Desktop Skia runtime-test stalls on macOS and Linux by adding (1) an in-process heartbeat during test execution and (2) an out-of-process watchdog that captures stacks and publishes them as CI artifacts, even on failure/timeouts.
Changes:
- Add
TestRunStallMonitorheartbeat logging during runtime test execution (CI-enabled by default). - Add
stall-watchdog.shand wire it into macOS/Linux runtime-test drivers to capture diagnostics when console output stalls, plus a hard-timeout termination path. - Publish new “stall diagnostics” artifacts from macOS/Linux CI jobs using
condition: always().
Review summary (verdict + counts):
- Verdict: requires changes
- Issues found: 2 bugs, 1 performance
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs | Starts/stops the stall monitor and updates current test name during execution. |
| src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/TestRunStallMonitor.cs | New heartbeat monitor that probes dispatcher + thread pool and logs periodic status. |
| build/test-scripts/stall-watchdog.sh | New out-of-process watchdog that detects log silence and captures managed/native diagnostics. |
| build/test-scripts/macos-skia-runtime-tests.sh | Runs watchdog alongside tests, tees console log, and preserves post-run failed-test list generation. |
| build/test-scripts/linux-skia-runtime-tests.sh | Runs watchdog alongside tests, tees console log (both Xvfb and non-Xvfb paths). |
| build/ci/tests/.azure-devops-tests-macos-skia.yml | Publishes macOS stall diagnostics artifact unconditionally. |
| build/ci/tests/.azure-devops-tests-linux-skia.yml | Publishes Linux stall diagnostics artifact unconditionally (with result-label suffix). |
Suppressed comments (1)
build/test-scripts/stall-watchdog.sh:85
- The Darwin capture path also relies on
timeout, which may be unavailable on the macOS hosted image. Iftimeoutis missing, bothsampleandvmmapcaptures can be skipped entirely, which defeats the purpose of macOS diagnostics.
Darwin)
# Native stacks for every thread, including AppKit/CoreAnimation frames that
# managed stacks cannot show. This is the artefact for a host-level livelock.
timeout 120 sample "$pid" 10 -f "$dir/sample.txt" >/dev/null 2>&1 \
|| log "sample failed"
timeout 60 vmmap --summary "$pid" > "$dir/vmmap.txt" 2>&1 || true
;;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
|
|
When_Reorder_DragDrop_ScrollsAwayFromDraggedItem_KeepsExtentAndPositions fails intermittently on the iOS Skia CI leg, always on the mid-drag extent assertion and always with the same values: ExtentHeight 1560 instead of 1440, exactly 3 phantom 40px rows. Observed on master build 225991 (attempt 1, passed on retry), PR #24007 build 226424, and PR #24012 build 226524 where 5/5 stage attempts failed on this single test across different hosted agents. The identical values every failure point at a timing-dependent residue of the extent estimation fixed by #23946 surfacing on the iOS simulator profile — tracked in #24013. Desktop and Android Skia legs keep running the test, so the regression coverage #23946 added stays in place. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NsWEWZN3E2AtwQm7UU1cFm
When_Reorder_DragDrop_ScrollsAwayFromDraggedItem_KeepsExtentAndPositions fails intermittently on the iOS Skia CI leg, always on the mid-drag extent assertion and always with the same values: ExtentHeight 1560 instead of 1440, exactly 3 phantom 40px rows. Observed on master build 225991 (attempt 1, passed on retry), PR #24007 build 226424, and PR #24012 build 226524 where 5/5 stage attempts failed on this single test across different hosted agents. The identical values every failure point at a timing-dependent residue of the extent estimation fixed by #23946 surfacing on the iOS simulator profile — tracked in #24013. Desktop and Android Skia legs keep running the test, so the regression coverage #23946 added stays in place. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NsWEWZN3E2AtwQm7UU1cFm (cherry picked from commit c0ce315) # Conflicts: # src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs
There was a problem hiding this comment.
i think a more effective method would be enforce a per-test hard timeout, like 1min, on the engine level
for heavy tests, we can adjust case-by-case with [TimeoutAttribute]
(which you have mentioned in an issue for uno7)
f2fd5c6 to
77ecb59
Compare
|
Claude finished @MartinZikmund's task in 3m 32s —— View job PR Review —
|
| Severity | File | Line | Summary |
|---|---|---|---|
| Minor | stall-watchdog.sh |
L74 | timeout is not reliably available on macOS (it's GNU coreutils, not a macOS built-in). Without it, dotnet-stack report and sample run unguarded — when the target is stuck in a kernel or GC state these tools can hang, freezing the watchdog instead of completing the capture. |
Confirmed from prior inline review (still open):
| Severity | File | Lines | Summary |
|---|---|---|---|
| Minor | TestRunStallMonitor.cs |
L158–168 | ManualResetEventSlim in ProbeThreadPool() is never disposed — the timeout path must stay unmanaged, but the success and queue-failed paths can and should call Dispose(). |
| Minor | TestRunStallMonitor.cs |
L203–207 | _disposed is a plain bool with no synchronization; two concurrent callers can both pass the guard and double-cancel/double-dispose the CancellationTokenSource. Use Interlocked.CompareExchange on an int field. |
| Minor | TestRunStallMonitor.cs |
L212 | _thread.Join(2 s) is shorter than ProbeTimeout (5 s); _cts.Dispose() can be called while the background thread is mid-probe. Raise to ≥ 10 s. |
Cross-cutting notes
#nullable enableis correctly present; noevent Action/event Action<T>violations.- The
Interlocked.Exchange(ref _stallMonitor, null)?.Dispose()pattern inUnitTestsControl.csensures only one external caller reachesDispose()— the fix in finding Paths are either not shown or shown not as in the UWP Designer #2 adds the same safety inside the class, which completes the picture. - The two Linux stages sharing one template with
testResultLabel-suffixed artifact names is correctly called out in the PR description; not a bug introduced here. - Conventional Commits format (
feat(ci):) is correct.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
build/test-scripts/stall-watchdog.sh:76
stall-watchdog.shrelies ontimeout(1)for all captures, but macOS agents typically don’t shiptimeout(see the existing comment inios-uitest-run.sh). Whentimeoutis missing, the watchdog will skipdotnet-stack/sample/vmmapcaptures, which defeats the purpose of the diagnostics on macOS. Add a wrapper that usestimeout/gtimeoutwhen available and otherwise enforces a timeout via a background watchdog +kill.
# Managed stacks — the primary artefact for a managed deadlock or a hung await.
if command -v dotnet-stack >/dev/null 2>&1; then
timeout 120 dotnet-stack report --process-id "$pid" > "$dir/dotnet-stack.txt" 2>&1 \
|| log "dotnet-stack failed (see $dir/dotnet-stack.txt)"
fi
src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/TestRunStallMonitor.cs:160
ProbeThreadPoolallocates a newManualResetEventSlimeach tick but never disposes it. SinceWait(...)can allocate an underlyingWaitHandle, this can unnecessarily retain OS handles until GC/finalization during long test runs. Dispose the event and guard the queued callback against Set-after-dispose races.
private static string ProbeThreadPool()
{
var sw = Stopwatch.StartNew();
var signal = new ManualResetEventSlim(false);
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
77ecb59 to
8c4c2c2
Compare
|
Claude finished @MartinZikmund's task in 4m 37s —— View job PR Review —
|
| # | Severity | Location | Summary |
|---|---|---|---|
| 1 | Minor | TestRunStallMonitor.cs L168 |
ManualResetEventSlim leaked on every tick — dispose on success and queue-failed paths; the timeout path must stay unmanaged (work item may still call Set()) |
| 2 | Minor | TestRunStallMonitor.cs L210 |
_disposed is a plain bool — two concurrent callers can both pass the guard and double-cancel/double-dispose the CancellationTokenSource; use Interlocked.CompareExchange on an int field |
| 3 | Minor | stall-watchdog.sh L74 |
timeout is GNU coreutils, not a macOS built-in — when absent, dotnet-stack, sample, and vmmap run unguarded and can freeze the watchdog itself; add a gtimeout/timeout/bare fallback wrapper |
| 4 | Nit | TestRunStallMonitor.cs L212 |
_thread.Join(2 s) is shorter than ProbeTimeout (5 s) — raise to ≥ 10 s so _cts.Dispose() cannot be called while the background thread is mid-probe |
| 5 | Nit | macos-skia-runtime-tests.sh L61 / linux-skia-runtime-tests.sh L56 |
kill $WATCHDOG_PID without a subsequent wait leaves the watchdog as a zombie during artifact publishing |
Cross-cutting notes
#nullable enableis correctly present inTestRunStallMonitor.cs. The_stallMonitorfield inUnitTestsControl.csomits?— consistent with that file's nullable-oblivious style (no#nullable enableat the top).- The
Interlocked.Exchange(ref _stallMonitor, null)?.Dispose()pattern inUnitTestsControl.cscorrectly ensures only one external caller reachesDispose(). Issue Paths are either not shown or shown not as in the UWP Designer #2 adds the same safety inside the class itself. - No
event Action/event Action<T>violations. - Conventional Commits format (
feat(ci):) is correct. - The Linux artifact name being suffixed with
testResultLabel(preventing collision between the two Linux stages) is correctly noted in the PR description; the pre-existinglinux-failurescollision is not introduced here.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
|
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
The monitor introduces a thread requirement on a test host that also runs on ordinary browser-WASM. That needs a platform-safe path before approval. The captured WASM CI log also ends without a result file, although it does not expose a managed stack trace, so I am not attributing every CI failure solely from its red status.
| Name = "UnoTestStallMonitor", | ||
| Priority = ThreadPriority.AboveNormal, | ||
| }; | ||
| _thread.Start(); |
There was a problem hiding this comment.
[P1] Do not start this Thread on the single-threaded WASM host. TryStart is enabled by IS_CI by default and has no browser/thread-capability guard; UnitTestsControl.RunTests calls it at lines 756-758 before its try/finally and before test enumeration. .NET's thread-disabled runtime rejects Thread.Start (see https://github.com/dotnet/runtime/blob/v10.0.0/src/mono/mono/metadata/threads.c#L4818-L4829). A diagnostic feature must not prevent the test run or result publication. Keep this implementation for supported hosts and provide an explicit browser-safe/disabled path.
There was a problem hiding this comment.
Fixed in f4be2c4. TryStart now returns null up front on OperatingSystem.IsBrowser(), logging [stall-monitor] disabled: no dedicated threads on this runtime. Separately, any exception while starting the monitor is caught and logged as disabled, so a diagnostic can never keep the run from starting or publishing results on any other host either.
Same commit picks up the bot threads: capture tools are bounded through a with_timeout helper (timeout, then gtimeout, then a manual kill) since macOS agents may have neither; the watchdog is waited after kill; Dispose joins for 3x the probe timeout and only disposes the token source once the loop has actually exited; the thread-pool probe uses a TaskCompletionSource instead of an undisposed ManualResetEventSlim.
Runtime check on Skia desktop Release with a 2 s interval over Given_ContentPresenter: 11 heartbeat lines (dispatcher, dispatcherIdle, threadPool all reporting), clean stop, 270/270 passed.
0feff49 to
f4be2c4
Compare
|
Claude finished @MartinZikmund's task in 3m 30s —— View job PR Review —
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
f4be2c4 to
1e6c129
Compare
|
Claude finished @MartinZikmund's task in 1m 42s —— View job PR Review —
|
🤖 Addressed PR comments up to this pointRebased onto current
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
macOS and Linux desktop Skia runtime tests freeze mid-test and are killed by the 60-minute job timeout, leaving no evidence of what blocked. Adds two complementary instruments: - TestRunStallMonitor: an in-process heartbeat on a dedicated thread that separately probes the UI dispatcher and the thread pool each tick. A dedicated thread is used so pool starvation cannot silence it, which is what separates "UI thread blocked" from "pool starved" from "process frozen" (no heartbeat line at all). Enabled on CI, opt-in locally via UNO_TEST_STALL_MONITOR_INTERVAL_SECONDS. - stall-watchdog.sh: watches the console log and, once it goes quiet, captures managed stacks (dotnet-stack), native stacks (sample on macOS, eu-stack and /proc on Linux) and process state, re-arming for each subsequent stall. Optionally terminates the app before the job wall so results and the failed-test list are still written. The macOS driver no longer aborts on a non-zero app exit, so the failed-test list is written and a retry can run only the failures instead of the whole suite. closes #24006 refs #24005, #23967 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01RgHbZ4EHYrK6uTkPTtKbq8
The watchdog treated the console log's mtime as the liveness signal, but the in-process stall monitor writes a heartbeat to that same log every 30s. The file is therefore never quiet for the 180s threshold and no capture could ever fire. Build 229532 shows the consequence: the heartbeat correctly reported `STALL ... inTest=00:05:16`, and the diagnostics artifact contains no stacks -- the one run that reproduced the freeze under instrumentation still produced no evidence of it. Progress is now the count of test-start lines, which the heartbeat does not affect. Verified against a process that stalls while a heartbeat keeps writing: unchanged watchdog captures nothing, this one captures the stall. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BGKr3vEBkqQJA6Su8NQMXq
The monitor probed the dispatcher at normal priority only. Nearly every wait in the runtime tests funnels through `WindowHelper.WaitForIdle`, which enqueues at idle priority -- the lowest of the dispatcher's four queues, served only when every higher queue is empty. A steady stream of normal-priority work leaves the normal probe reporting single-digit milliseconds while every test wait blocks, so the existing signal cannot see that case at all. This is not hypothetical. Build 229532 stalled 5m16s inside a test whose only waits are `WaitForIdle`/`WaitForRender`, and reported `dispatcher=31ms`, `threadPool=0ms`, `gcPauseDelta=0ms` throughout -- every instrument healthy while nothing progressed. The idle queue was the one thing not measured. One probe stays outstanding at a time and its age is reported, so a blocked queue neither piles up work nor hides how long it has been blocked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BGKr3vEBkqQJA6Su8NQMXq
The monitor starts a dedicated thread, which the browser runtime refuses. It now stays disabled there, and any failure to start is logged instead of breaking the run it observes. Also bound capture tools where macOS has no timeout(1), reap the watchdog after killing it, and stop disposing the token source under a live probe loop. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm
The normal-priority dispatcher probe now shares the idle probe's one-outstanding-probe logic, so a blocked queue reports how long it has been stuck instead of piling up probes. Dispose guards with Interlocked. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1e6c129 to
29c23d6
Compare
|
Claude finished @MartinZikmund's task in 1m 2s —— View job PR Review —
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (6)
pgrep -f ... | head -n 1can select an unrelateddotnetprocess if multiple matches exist… · Newgreptreats$PROGRESS_PATTERNas a regular expression, so patterns containing regex… · New Same as macOS: quote variables and paths to avoid word-splitting/globbing issues. This is… · New Same as macOS: quote variables and paths to avoid word-splitting/globbing issues. This is… · New These paths/variables should be quoted to avoid word-splitting/globbing issues in shell scripts.… · New These paths/variables should be quoted to avoid word-splitting/globbing issues in shell scripts.… · New
Resolved since last review (4)
After terminating the background watchdog,waitfor it to avoid leaving a defunct (zombie)… After terminating the background watchdog, the script shouldwaitfor it to avoid leaving a… stall-watchdog.sh uses thetimeoutcommand, buttimeoutis not available by default on macOS… ProbeThreadPool allocates a ManualResetEventSlim on every heartbeat tick but never disposes it. In…
| find_pid() { | ||
| pgrep -f "$PROC_PATTERN" 2>/dev/null | head -n 1 |
| progress_count() { | ||
| local f=$1 | ||
| [ -f "$f" ] || { echo 0; return; } | ||
| grep -c "$PROGRESS_PATTERN" "$f" 2>/dev/null || echo 0 |
| chmod +x $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh | ||
| $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh \ |
| $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh \ | ||
| "$APP_LOG" "$UITEST_DIAGNOSTICS_DIR" "dotnet.*SamplesApp\.dll" & | ||
| WATCHDOG_PID=$! | ||
| trap 'kill $WATCHDOG_PID 2>/dev/null || true' EXIT |
| export UITEST_DIAGNOSTICS_DIR=$BUILD_SOURCESDIRECTORY/build/uitests-diagnostics | ||
| export UNO_WATCHDOG_HARD_TIMEOUT_SECONDS=${UNO_WATCHDOG_HARD_TIMEOUT_SECONDS:-3300} | ||
| mkdir -p $UITEST_DIAGNOSTICS_DIR | ||
| APP_LOG=$UITEST_DIAGNOSTICS_DIR/runtime-tests-console.log | ||
|
|
||
| chmod +x $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh |
| $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh \ | ||
| "$APP_LOG" "$UITEST_DIAGNOSTICS_DIR" "dotnet.*SamplesApp\.dll" & | ||
| WATCHDOG_PID=$! | ||
| trap 'kill $WATCHDOG_PID 2>/dev/null || true' EXIT |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24007/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (11)
pgrep -f ... | head -n 1can select an unrelateddotnetprocess if multiple matches exist… Several variable expansions here are unquoted (e.g.,mkdir -p $UITEST_DIAGNOSTICS_DIR, `chmod +x… · Newgrep -cprints0even when it exits with status 1 (no matches). With the current|| echo 0,… · New When a dispatcher/idle probe fails, the logged value only includes the exception type, which can be… · New If_thread.Join(...)times out, the monitor thread may still be running, but the code still logs… · New This field is intentionally set to null (viaInterlocked.Exchange(ref _stallMonitor, null)and… · Newgreptreats$PROGRESS_PATTERNas a regular expression, so patterns containing regex… These paths/variables should be quoted to avoid word-splitting/globbing issues in shell scripts.… These paths/variables should be quoted to avoid word-splitting/globbing issues in shell scripts.… Same as macOS: quote variables and paths to avoid word-splitting/globbing issues. This is… Same as macOS: quote variables and paths to avoid word-splitting/globbing issues. This is…
| export UITEST_DIAGNOSTICS_DIR=$BUILD_SOURCESDIRECTORY/build/uitests-diagnostics | ||
| export UNO_WATCHDOG_HARD_TIMEOUT_SECONDS=${UNO_WATCHDOG_HARD_TIMEOUT_SECONDS:-3300} | ||
| mkdir -p $UITEST_DIAGNOSTICS_DIR | ||
| APP_LOG=$UITEST_DIAGNOSTICS_DIR/runtime-tests-console.log | ||
|
|
||
| chmod +x $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh | ||
| $BUILD_SOURCESDIRECTORY/build/test-scripts/stall-watchdog.sh \ | ||
| "$APP_LOG" "$UITEST_DIAGNOSTICS_DIR" "dotnet.*SamplesApp\.dll" & |
| progress_count() { | ||
| local f=$1 | ||
| [ -f "$f" ] || { echo 0; return; } | ||
| grep -c "$PROGRESS_PATTERN" "$f" 2>/dev/null || echo 0 |
| catch (Exception e) | ||
| { | ||
| pending = null; | ||
| return $"error({e.GetType().Name})"; | ||
| } |
| // A tick can be blocked in each of its three probes in turn; disposing the source under a live | ||
| // loop would fault its next wait. | ||
| if (_thread.Join(ProbeTimeout * 3 + TimeSpan.FromSeconds(2))) | ||
| { | ||
| _cts.Dispose(); | ||
| } | ||
|
|
||
| Console.WriteLine($"{LogPrefix} stopped after {Format(_runElapsed.Elapsed)}"); |
| private List<TestCaseResult> _testCases = new(); | ||
| private TestRun _currentRun; | ||
| private long _scrollableHeightCallbackToken; | ||
| private TestRunStallMonitor _stallMonitor; |



GitHub Issue: closes #24006
Related: #24005 (macOS host freeze), #23967 (
When_MsAppDataLinux hang) — this PR does not fix either, it makes them diagnosable.PR Type:
🏗️ Build or CI related changes
What changed? 🚀
macOS and Linux desktop Skia runtime tests freeze mid-test and get killed by the 60-minute job timeout, leaving no evidence of what blocked. The log just stops. There is no stack, no dump, and no way to tell whether the UI thread, the thread pool, or the whole process stopped.
This adds two complementary instruments. They answer different halves of the question, which is why both are here.
1.
TestRunStallMonitor— in-process heartbeatsrc/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/TestRunStallMonitor.csEmits one line per interval (30 s on CI) while tests run:
The design point is that the three signals are independent, so the shape of the output identifies the culprit:
dispatcher=BLOCKED,threadPoolfinethreadPool=STARVEDinTestclimbingawaitnever completes — a test buggcPauseDeltaThe heartbeat runs on a dedicated thread, not a timer or the thread pool — a pool-starvation hang must still produce output, otherwise it is indistinguishable from a fully frozen process. That distinction is the entire point of the instrument.
Enabled automatically under
IS_CI; locally it is off unless you setUNO_TEST_STALL_MONITOR_INTERVAL_SECONDS.2.
stall-watchdog.sh— out-of-process stack capturebuild/test-scripts/stall-watchdog.sh, wired into the macOS and Linux drivers.Watches the console log. When it goes quiet past a threshold (default 180 s) it captures, while the process is still stuck:
dotnet-stack report— managed stackssample <pid> 10— native stacks for every thread, including AppKit/CoreAnimation frames that managed stacks cannot showeu-stack,/proc/<pid>/status,/wchan, and per-threadstat/wchanpssnapshot, and the log tail so the capture records which test was runningIt re-arms, so a run that stalls three times yields three captures (capped, default 6). Published as a new
runtime-tests-desktop-skia-{macos,linux[-framebuffer]}-diagnosticsartifact viacondition: always()+continueOnError: true.UNO_WATCHDOG_HARD_TIMEOUT_SECONDS(default 3300 s = 55 min, against the 60-minute job wall) captures a final snapshot and thenSIGTERMs the app so the results XML and failed-test list are still written. 55 min was chosen deliberately: the longest observed successful macOS run is ~52 min, so this rescues diagnostics from runs that would have been killed at 60 while leaving every currently-passing run untouched.3. macOS driver no longer aborts on a non-zero app exit
macos-skia-runtime-tests.shran underset -e, so a crash or non-zero exit skippedlist-failedentirely and the retry re-ran the whole ~8.5k-test suite. It now captures the exit code and continues, matching what the Linux driver already does. (fail-emptystill fails the build when no results could be read, so a crash with no results is still red.)Validation ✅
Runtime —
stall-watchdog.shexecuted end-to-end against a simulated stalling process on Ubuntu 24.04 (WSL), driving two distinct stalls plus a hard-timeout case:Compile —
SamplesApp.Skia.csprojbuilds clean (net10.0, 0 errors). Verified the new type is actually in the output rather than silently excluded:TestRunStallMonitor,[stall-monitor],UnoTestStallMonitorandSTARVED(>are all present inSamplesApp.Skia.dll.Not validated at runtime: the in-process heartbeat has not run on a real macOS/Linux CI agent — that only happens once this is merged. It is logging-only and disabled off-CI, so the blast radius is a few extra stdout lines per run.
Notes for reviewers
testResultLabelto avoid a collision. (The pre-existing…-linux-failuresartifact is not suffixed and so does collide between those two stages — flagging it, not fixing it here.)pgrepand astatper 15 s.PR Checklist ✅
Screenshots Compare Test Runresults.Update: two defects found by running this instrumentation against real CI data
Both instruments have now been exercised against the macOS runs this PR's own CI produced. Two
things prevented them from answering the question they were built for; both are fixed here.
1. The watchdog could never fire (
abb52d5)The watchdog used the console log's mtime as the liveness signal — but the in-process heartbeat
writes to that same log every 30 s. The file is therefore never quiet for the 180 s threshold, so
no capture could ever happen. The two instruments cancelled each other out.
This is not a theoretical interaction. Build 229532, attempt 1 — a full instrumented suite — hit
a real freeze and reported it correctly:
The
runtime-tests-desktop-skia-macos-diagnosticsartifact for that build contains no stacks.The one run that reproduced the freeze under instrumentation still produced no evidence of it.
Progress is now the count of test-start lines, which the heartbeat does not affect. Verified against
a process that stalls while a heartbeat keeps writing — unchanged watchdog captures nothing, this
one captures the stall.
2. The dispatcher was probed at the wrong priority (
954ff36)The probe was
dispatcher.RunAsync(...)— normal priority. Nearly every wait in the runtimetests funnels through
WindowHelper.WaitForIdle, which enqueues at idle priority: the lowest ofNativeDispatcher's four queues, and one that is served only when every higher queue is empty(
NativeDispatcher.DispatchItems,for (var p = 0; p <= 3; p++)). A steady stream ofnormal-priority work leaves the normal probe reporting single-digit milliseconds while every test
wait blocks indefinitely.
The same build shows exactly that shape. Throughout a 5m16s freeze in
Given_TextBlock.When_Focus_Changes_Selection_Is_Not_Shown— a test whose only waits areWaitForIdleandWaitForRender— every instrument reported healthy:dispatcher(normal priority)threadPoolgcPauseDeltaSo the freeze is not a blocked UI thread, not GC, not pool starvation, and not a stopped
process — the four things this monitor could already distinguish. The idle queue was the one thing
it did not measure, and it is the queue every one of those waits depends on.
dispatcherIdle=now reports it. One probe stays outstanding at a time and its age is reported, soa blocked queue neither piles up work nor hides how long it has been blocked.
Why this matters for #24005
#24005 is blocked on "no stack dump exists for a stalled process". With these two fixes, one
instrumented macOS run should settle it:
dispatcherhealthy +dispatcherIdle=BLOCKED(...)→ the idle queue is starved;WaitForIdlecan never return, and the follow-up question is what floods the higher-priority queues on macOS.
sample/dotnet-stackcaptures (which can now actually fire) say where.
Added validation
keeps writing to the log: unchanged script captures 0, fixed script captures the stall
(
capturing diagnostics (no test started for 5s)).SamplesApp.Skia.Genericon Windows,Given_ContentPresenter, monitorat a 2 s interval:
dispatcher=0..67ms dispatcherIdle=0..52msacross 12 heartbeats, run exits 0.SamplesApp.Skia.csproj,net10.0, 0 warnings / 0 errors.Still not validated on a macOS agent — that is what merging this is for.