Skip to content

fix: keep Companion from crashing after the setup mascot closes - #2425

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess/flake-testhost-failfast
Dec 1, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess/flake-testhost-failfast

Conversation

@bkudiess

@bkudiess bkudiess commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 835d42bb674f22b432f42cc0cd7bdbebc4104438

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ One-line ownership change; the only AnimationController in the repo.
↑ New test crashed unfixed code 6/6 and passed the fix 10/10; native repeat 20/20 with screenshots 0 and 1; soak passed with CPU burners at screenshots 0 and 1.
↑ Shared (6187) and Tray (7148) suites pass; dual-model review found no defect in the product change.
↑ Hosted x64 CI run 46583633443 is green on this head, including the new test (passed, 31 s) and the new-test soak.
↓ Absence of recurrence on main is not yet observed.
Diagnosis confidence 9.5/10 ↑ Dumps show dcompi!purecall in CRebuildableObjectList::Rebuild; the dead list item has the AnimationController::Api vtable.
↑ Bisection: closing the controller crashes; stopping its binding without closing passes 8/8.
Evidence fit 9.5/10 ↑ All 8 crashes in 14 days were in tests that host the mascot; the first two were on #2380's own PR, none before it.
↑ The same exit code (0xC0000409) and the same window-teardown timing reproduce natively.
↓ No crash dump from a hosted x64 runner; the native stack comes from an ARM64 host.

What Problem This Solves

Since #2380 (refactor: simplify desktop lobster and setup animation playback), the setup and Store migration mascot can crash the whole process soon after its window closes. Windows ends the process with 0xC0000409 (a fast-fail), with no managed exception and no log line. In CI this shows up as "Test host process crashed" in the Tray UI lane on unrelated PRs (8 times in 14 days, for example #2379 and #2417). The same code runs in Companion's setup and migration windows.

User Impact

User impact: closing the setup or Store migration window no longer risks crashing Companion, and the hosted Tray UI lane stops failing on unrelated PRs with "Test host process crashed".

Why This Change Was Made

The mascot's mouth morphs use a Composition AnimationController that belongs to the geometry's path animation. The mascot also closed that controller when it unloaded. Composition still had the controller queued for rebuild, so when .NET finalized it before the next frame, Composition called the destroyed object and aborted the process. The fix leaves the controller to its animation. Unloading still stops the controller's binding and the path animation, and closes the geometry.

Class: product race (taxonomy #10). Sibling sweep: this is the only TryGetAnimationController or AnimationController in the repository.

Evidence

Root cause from crash dumps (Crabbox RTX 2, ARM64, Windows App Runtime 2.7.0.0)

WER caught the testhost (dotnet.exe) fault in ucrtbase.dll, 0xc0000409, subcode 7 (FAST_FAIL_FATAL_APP_EXIT, i.e. abort()). The UI thread was in a render tick:

ucrtbase!abort+0x3c
dcompi!purecall+0x2c
dcompi!DirectComposition::CDevice::CRebuildableObjectList::Rebuild+0x50
dcompi!DirectComposition::CDevice::Commit+0x874
dcompi!Microsoft::UI::Composition::InteropCompositor::Api::Commit+0x68
Microsoft_UI_Xaml!DCompTreeHost::CommitMainDevice+0x68
...
Microsoft_UI_Xaml!CXcpBrowserHost::OnTick+0x54

In a full dump, the rebuild-list item that was called has the base CRebuildableObject vtable (pure virtual slots), with dcompi!Microsoft::UI::Composition::AnimationController::Api at +0x20: a destroyed AnimationController that is still queued. In another dump, the .NET finalizer thread was inside ContextRuntimeClass::OnFinalRelease_NoLock, waiting for the Composition lock that the UI thread held in Commit.

Bisection (StoreMigrationWindowProofTests with an uncommitted, env-gated background GC.Collect/WaitForPendingFinalizers loop; 21 windows per run):

Variant Result
main crashed 10/10 runs
controller not kept and not closed (this fix's shape) passed 10/10
controller kept until unload, Progress binding stopped, not closed passed 8/8
controller closed, binding not stopped crashed on run 1

Without injection, main crashed in about 3 of 10 class runs on the host. The fix passed 20/20 runs without injection and 10/10 with it.

Regression test: OnboardingArtworkRenderingTests.UnloadedMascots_SurviveConcurrentFinalization mounts and unloads 8 mascots while a background loop keeps finalizing. Before the fix it crashed the testhost in 6/6 runs (WER: dotnet.exe, ucrtbase.dll, 0xc0000409). With the fix it passed 10/10. A failure here crashes the testhost instead of failing an assertion; the test summary says so.

Required proof pools

  • windows-11-arm64: native ARM64 runs on Crabbox RTX 2 cover RED, GREEN, repeats, soak and the lane below.
  • windows-winui-interactive: covered by native UI tests on the console desktop, including the mascot's composed-pixel checks in OnboardingArtworkRenderingTests. There is no visual change, so there are no screenshots.

Validation

Check Result
./build.ps1 (local x64, proxy NuGet config, sanitized PATH) ✅ all builds succeeded
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj (isolated OPENCLAW_TRAY_*) ✅ 6187 passed, 0 failed, 29 skipped (opt-in gates)
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj (isolated OPENCLAW_TRAY_*) ✅ 7148 passed, 0 failed
pwsh -NoProfile -File ./scripts/validate-test-timing-patterns.ps1 ✅ passed
git diff --check ✅ clean
RED: new test on main + test only, 6 runs (RTX 2) ✅ 6/6 testhost crashes, 0xc0000409
GREEN: new test with the fix, 10 runs (RTX 2) ✅ 10/10 passed
Invoke-NativeUiTest.ps1 -Repeat 10, screenshots 0 and 1, OnboardingArtworkRenderingTests + StoreMigrationWindowProofTests (excluding the opt-in NativeOnboardingProof category) ✅ 20/20 runs, 53/53 tests each
Get-CiChangedTests.ps1 + Invoke-CiTestSoak.ps1 (10 runs, 3 with CPU burners), OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=0 and =1 ✅ both passed
CI Tray UI lane filter, once (RTX 2) ✅ no crash; 1322 passed, 1 failed: GatewayThemeBrandingTests.WorkingIndicatorAndBrandMarkFollowTheThemeBranding, which also fails 3/3 on unfixed main on this ARM64 host

Review: dual-model Hanselman review (claude-opus-5.5, gpt-6-astra long context, high effort) plus a delta re-review of the rewritten test. Neither model found a defect in the product change. Fixed from review:

  • every finalization is now followed by a commit inside the test;
  • the test reads the mascot's player field instead of walking the visual tree, which threw a COMException once in 20 runs under finalization.

Not changed: finally cleanup for a failed mount (LOW, matches the sibling mascot tests) and a reverse-order stop in Dispose (LOW, the bisection shows the current order is safe).

Real behavior proof

Native runs used the shared desktop lock, an Active console desktop, isolated OPENCLAW_TRAY_* folders and a check that the real profile was unchanged, on Crabbox RTX 2 (testuser@20.10.146.47:2222). Runs are under C:\oc\failfast-runs\ (w-red, w-green, w-lane), C:\oc\failfast-native4\ and C:\oc\failfast-soak4-*.log.

Not verified:

  • a crash dump from a hosted runner (the native stack is from ARM64);
  • a field report of the crash in Companion itself.

The setup and Store migration mascot closed the AnimationController that
drives its mouth morphs, although the geometry's Path animation owns it.
Composition keeps that controller queued for rebuild, so when it is
finalized before the next commit, dcompi calls the destroyed object
(purecall in CRebuildableObjectList::Rebuild) and the process fail-fasts
with 0xC0000409. Since openclaw#2380 this crashed the hosted Tray UI testhost in
tests that host the mascot.

Leave the controller to its animation. Dispose still stops its Progress
binding and the Path animation and closes the geometry. Add a UI
regression test that finalizes continuously while mascots unload.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@clawsweeper

clawsweeper Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦞👀
Pull request received.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. impact:crash-loop This issue is about crashes, hangs, restart loops, or process-level availability. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Dec 1, 2026
@clawsweeper

clawsweeper Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codex review: passed.

What this changes

This PR stops explicitly disposing the mascot’s animation controller and adds a regression test for unloading during concurrent finalization.

Example: Close a setup or Store migration window while native mascot resources are being finalized.

  • Before: Explicit controller disposal can leave Composition rebuilding a destroyed object and terminate the process with 0xC0000409.
  • After: The animation retains controller lifetime ownership while unload still stops its bindings and disposes the geometry.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, worthwhile repair with a distinct native regression test; confidence rests on source inspection, reported native runs and CI metadata rather than inspected shipped-app evidence.
Proof confidence 🦐 gold shrimp (3/6) The contributor proof gate is exempt: supplied ARM64 evidence exercises the production mascot against native Composition through UI tests, and current-head hosted soak metadata reports success, but no shipped-app close scenario was independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Closing a window containing the shared mascot can terminate Companion without a managed exception.
Reason: The maintainer-authored direction repairs process termination while preserving native playback, public behavior and existing cleanup responsibilities.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete native crash path still present on main, and the reviewed diff introduces no actionable defect.

Reviewed head: 835d42bb674f22b432f42cc0cd7bdbebc4104438

Before merge

None.

Findings

None.

Agent review details

How this fits together

Setup, migration and desktop surfaces host OnboardingMascot; its AnimatedVisualPlayer drives retained Composition geometry, and unloading detaches the source and releases native resources.

flowchart LR
  A[Setup and migration windows] --> C[OnboardingMascot]
  B[Desktop companion] --> C
  C --> D[AnimatedVisualPlayer]
  D --> E[Native mascot geometry]
  E --> F[Path animation controller]
  C --> G[Unload cleanup]
  G --> E
Loading

Technical review

Best possible solution:

Keep controller lifetime with the native animation while preserving binding shutdown and geometry disposal in the existing mascot owner.

Do we have a high-confidence way to reproduce the issue?

Main source confirms explicit controller disposal during mascot teardown, and the body reports repeatable native crashes with that ownership; this read-only review did not independently reproduce the crash.

Is this the best way to solve the issue?

Removing the controller from the existing disposal list directly addresses the diagnosed lifetime error without retries, catches, delays or a parallel cleanup path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 416f678aff51.

Provenance checked

  • Native mascot controller disposal changes intended behavior with a stated reason (29f0553: The native playback refactor retained geometry and centrally disposed created Composition objects; this PR explains why an animation-owned controller must be excluded from that list.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit 29f0553 adds src/OpenClaw.SetupEngine.UI/Controls/OnboardingMascotVisual.cs:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 29f0553fbed0; files: src/OpenClaw.SetupEngine.UI/Controls/OnboardingMascotVisual.cs)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production and regression scope Production +3/-1 lines; tests +47/-0 lines The lifetime repair adds no production machinery, and the native stress test covers a finalization failure absent from ordinary unload assertions.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed December 1, 2026, 12:44 AM ET / 05:44 UTC.

@bkudiess
bkudiess merged commit 4ad1937 into openclaw:main Dec 1, 2026
38 checks passed
bkudiess added a commit to bkudiess/openclaw-windows-node that referenced this pull request Dec 1, 2026
…s mascot fix

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
bkudiess added a commit that referenced this pull request Dec 1, 2026
…UI thread (#2434)

The #2425 regression test ran full garbage collections back to back while
mascots loaded and unloaded. Under the coverage collection on main push
runs, that starved the UI thread: the test took 1m51s to 4m56s and once
passed VSTest's 5-minute inactivity limit, aborting the Tray UI lane
(run 46660200446).

Each cycle now holds the UI thread just after the mascot's own Unloaded
handler disposes its visual, runs one collection and its finalizers, then
releases the thread for the next commit. That is the exact window in which
a closed controller crashed Composition, so the test still crashes the
pre-#2425 code on every run, and it now waits until the visual is
collected. In the full Tray UI lane under coverage it takes about 3 s.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:crash-loop This issue is about crashes, hangs, restart loops, or process-level availability. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant