Repository navigation
Windows Tray app crash-loops with Microsoft.UI.Xaml.LayoutCycleException under rapid event throughput #1270
Description
Environment
OpenClaw Windows Tray version: 2026.7.1 (also reproduced on 2026.7.1-2)
OS: Windows 10.0.29648.0, x64
Gateway version: 2026.7.1 (remote gateway over wss://)
Topology: Remote gateway, node mode enabled
Summary
The Windows tray app repeatedly crashes and auto-restarts under load, with the following unhandled exception in crash.log:
Copy
Microsoft.UI.Xaml.LayoutCycleException: The text associated with this error code could not be found.
Element is already the child of another element.
Observed pattern
Over a ~30 minute window, the tray app restarted at least 6 times:
21:05:41, 21:08:54, 21:12:30, 21:25:43 (local +02:00), plus the crash itself at 21:21:02
Restart intervals as short as ~3 minutes apart during the worst period
Suspected trigger
Tray log (openclaw-tray.log) shows very high-frequency inbound events during active sessions — presence, health, node.invoke.request/result, chat, sessions.changed, agent stream events — sometimes multiple events within the same millisecond. These appear to feed directly into UI-bound collections (activity stream, node list, session list). Under sustained high throughput, this likely races the WinUI layout/measure-arrange pass, causing an element to be re-parented while still attached elsewhere — the classic root cause of LayoutCycleException.
Impact
Tray app becomes unusable during high-activity sessions (agent actively running tool calls/exec approvals)
Requires manual force-kill + relaunch to recover
No user-facing error dialog observed — app just disappears/restarts silently
Suggested fixes
Batch/throttle UI updates from the event stream (e.g. coalesce rapid presence/health ticks before dispatching to UI thread)
Ensure all collection mutations happen on the UI thread via DispatcherQueue, not directly from the websocket receive callback
Add global unhandled-exception handling around the XAML layout pass to prevent full app termination (log + recover instead of crash)
Attached crash.log tail:
Copy
[2026-08-30 21:21:02.506] UnhandledException
Microsoft.UI.Xaml.LayoutCycleException: The text associated with this error code could not be found.
Element is already the child of another element.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Aug 30, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 4, 2026, 12:52 AM ET / 04:52 UTC.
Summary
Keep open for targeted maintainer diagnosis. The report documents a severe current-release crash loop, but the supplied exception tail does not identify the reparented control or a reproducible event sequence; current code already serializes gateway-driven state changes onto the UI thread and coalesces Event Stream rendering.
Reproducibility: no. The supplied crash tail and timestamps establish an observed failure, but do not name the control or provide a repeatable event burst; no current-main or latest-release load reproduction was available to inspect.
Regression provenance
Possible regression — suspected (failure trace). No predecessor PR is attributed.
Ways to help us reproduce this
Maintainer decision needed
Why: The report establishes serious user impact, but source review disproves the proposed direct background collection-mutation mechanism and does not identify the actual WinUI owner.
Next step
The report remains actionable but lacks the control-level failure evidence needed for a safe bounded repair, and its existing labels already route it to maintainer review rather than a new fix PR.
Review details
Best possible solution:
Capture a sanitized full exception stack or dump plus a focused high-throughput reproduction on the latest tray release, then repair the identified view update boundary with a regression-oriented load test.
Do we have a high-confidence way to reproduce the issue?
No. The supplied crash tail and timestamps establish an observed failure, but do not name the control or provide a repeatable event burst; no current-main or latest-release load reproduction was available to inspect.
Is this the best way to solve the issue?
Unclear. UI-thread dispatch and Event Stream refresh coalescing already exist, so adding another generic throttle or exception handler is not yet a demonstrated fix; identify the reparenting owner first.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against c5105ab06a2f.
Label changes
Label justifications:
P1: Repeated tray termination during active gateway sessions breaks a real user workflow, but the currently supported scope is limited to the reported high-throughput condition.impact:crash-loop: The report describes at least six tray restarts and manual recovery during a roughly 30-minute activity window.Evidence reviewed
What I checked:
src/OpenClaw.Tray.WinUI/Services/GatewayService.cs:88, c5105ab06a2f)src/OpenClaw.Tray.WinUI/Services/AppState.cs:178, c5105ab06a2f)src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml.cs:155, c5105ab06a2f)src/OpenClaw.Tray.WinUI/Services/GatewayService.cs, cff1033b3bb3)Likely related people:
How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.MilkyWay008 commentedon Aug 30, 2026
Saw your LayoutCycleException on 2026.7.1-2 too, the silent crash-loop with no dialog is the worst part of it. Before you keep force-killing, flip on WER LocalDumps (HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps) and grab a full dump the next time it dies, then check the .NET Runtime entries in Event Viewer...... those two together will show whether it's really the reparenting view or something earlier in the event burst. Correlating the crash timestamps with the openclaw-tray.log flood is what finally pinned it down for me. oh btw, I keep a portable Hermes OTG on a USB stick as my rescue agent for these Windows agent crash moments, https://github.com/MilkyWay008/Hermes-OTG if you want to look at it.
MilkyWay008 commentedon Sep 1, 2026
The "Element is already the child of another element" under LayoutCycleException is a reparenting race in WinUI 3, and it usually hides behind rapid collection churn like you're seeing from the gateway event bursts. What helped me narrow a similar one down: enable the WinAppSDK XAML diagnostics (XamlDiagnostics) and capture a dump at the crash, then look at which ItemsRepeater/ListView is mid-update; the reparenting owner is almost never where the crash log points. In the meantime, one thing worth trying is disabling the tray's live event list rendering during active agent sessions (a settings toggle, or just let the tray show only status and route the event log to a window you open on demand), since batching the UI updates is a legit stopgap while the actual owner gets found. If you want to poke at a standalone Windows tool that runs beside a broken gateway install to test this pattern in isolation, I keep a portable Hermes OTG on a USB stick for exactly these crash-loop situations, https://github.com/MilkyWay008/Hermes-OTG. Hope that unblocks you.
github-actions commentedon Sep 19, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.