Repository navigation
fix: keep Companion from crashing after the setup mascot closes - #2425
Conversation
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 review completeClawSweeper finished reviewing this revision. |
|
Codex review: passed. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSetup, 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
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed December 1, 2026, 12:44 AM ET / 05:44 UTC. |
…s mascot fix Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…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>
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
835d42bb674f22b432f42cc0cd7bdbebc4104438↑ 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.
dcompi!purecallinCRebuildableObjectList::Rebuild; the dead list item has theAnimationController::Apivtable.↑ Bisection: closing the controller crashes; stopping its binding without closing passes 8/8.
↑ 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
TryGetAnimationControlleror 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 inucrtbase.dll,0xc0000409, subcode 7 (FAST_FAIL_FATAL_APP_EXIT, i.e.abort()). The UI thread was in a render tick:In a full dump, the rebuild-list item that was called has the base
CRebuildableObjectvtable (pure virtual slots), withdcompi!Microsoft::UI::Composition::AnimationController::Apiat +0x20: a destroyed AnimationController that is still queued. In another dump, the .NET finalizer thread was insideContextRuntimeClass::OnFinalRelease_NoLock, waiting for the Composition lock that the UI thread held inCommit.Bisection (StoreMigrationWindowProofTests with an uncommitted, env-gated background
GC.Collect/WaitForPendingFinalizersloop; 21 windows per run):Progressbinding stopped, not closedWithout 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_SurviveConcurrentFinalizationmounts 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 inOnboardingArtworkRenderingTests. There is no visual change, so there are no screenshots.Validation
./build.ps1(local x64, proxy NuGet config, sanitized PATH)dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj(isolatedOPENCLAW_TRAY_*)dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj(isolatedOPENCLAW_TRAY_*)pwsh -NoProfile -File ./scripts/validate-test-timing-patterns.ps1git diff --check0xc0000409Invoke-NativeUiTest.ps1 -Repeat 10, screenshots 0 and 1,OnboardingArtworkRenderingTests+StoreMigrationWindowProofTests(excluding the opt-inNativeOnboardingProofcategory)Get-CiChangedTests.ps1+Invoke-CiTestSoak.ps1(10 runs, 3 with CPU burners),OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=0and=1GatewayThemeBrandingTests.WorkingIndicatorAndBrandMarkFollowTheThemeBranding, which also fails 3/3 on unfixed main on this ARM64 hostReview: 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:
COMExceptiononce in 20 runs under finalization.Not changed:
finallycleanup for a failed mount (LOW, matches the sibling mascot tests) and a reverse-order stop inDispose(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 underC:\oc\failfast-runs\(w-red,w-green,w-lane),C:\oc\failfast-native4\andC:\oc\failfast-soak4-*.log.Not verified: