Repository navigation
Description
Summary
The WinUI tray app enters an unbounded render loop in the Reactor chat root. The UI thread pegs one core indefinitely, the tray stops responding to input, and the managed heap grows without limit — I observed 16.1 GB working set and ~10.2 hours of CPU over 10.1 hours of uptime (≈1.01 cores pegged continuously since launch).
The memory growth is a direct consequence of the render loop, not a separate leak. Fixing the loop fixes both symptoms.
Environment
- Commit
08c825b7, localDebugbuild,net10.0-windows10.0.22621.0,win-arm64 - .NET SDK 10.0.400 / runtime 10.0.11
- Windows 11 Enterprise 10.0.28000, ARM64
Microsoft.UI.Reactor0.1.0-preview.12
Evidence
The UI thread never leaves Render()
Four independent dotnet-stack samples of the UI thread (0x5A60, 26,776 s CPU) were all inside the render loop:
Microsoft.WinUI!ABI.Microsoft.UI.Xaml.Controls.IBorderMethods.get_Child(...)
Reactor!Microsoft.UI.Reactor.Core.Reconciler.ReconcileComponent(...)
Reactor!Microsoft.UI.Reactor.Core.Reconciler.Update(...)
Reactor!Microsoft.UI.Reactor.Core.Reconciler.ReconcilePanelChildrenInto(...)
...
Reactor!Microsoft.UI.Reactor.Hosting.ReactorHostControl.Render()
Reactor!Microsoft.UI.Reactor.Hosting.ReactorHostControl.RenderLoop()
Microsoft.InteractiveExperiences.Projection!ABI.Microsoft.UI.Dispatching.DispatcherQueueHandler.Do_Abi_Invoke(int)
OpenClaw.Tray.WinUI!OpenClawTray.Program.Main(string[])
It never returns to pumping messages, which is why the tray is unresponsive. Background threads (node websocket, logging) keep working normally — the log kept advancing the whole time, so the app looks alive while the UI is wedged.
The heap is 99.7% COM callable wrappers
dumpheap -stat on a full dump — note the heap holds only 115,596 objects total, i.e. the visual tree is completely normal-sized (517 BorderElement, 416 ButtonElement, 315 TextBlockElement):
MT Count TotalSize Class Name
7ff8cd3ec7e8 955 15,846,538,856 System.Runtime.InteropServices.ComWrappers+ManagedObjectWrapperHolder[]
Total 115,596 objects, 15,898,028,565 bytes
37 of those arrays account for 15.85 GB; two are 4.29 GB each. gcroot traces them through dependent handles to exactly two managed objects — OpenClawTray.Pages.ChatPage and Microsoft.UI.Reactor.Hosting.ReactorHostControl. The backing list for ChatPage:
Name: System.Collections.Generic.List`1[[ComWrappers+ManagedObjectWrapperHolder]]
_items 0000008268000048 ManagedObjectWrapperHolder[] (4,294,967,320 bytes)
_size 355567468
_version 355567468
_size == _version means 355 million Add calls and not one removal. Every render pass mints fresh CCWs as these objects cross into WinRT, and .NET's per-object ComWrappers holder list is append-only and never trimmed. So heap size is purely a function of loop iterations.
Consistent with this, the finalizer thread had burned 913 s in WinRT.IObjectReference.Finalize(), and a GC thread another 4,928 s.
Root cause
The cycle is in OpenClawReactorChatRoot / ChatComposerViewModel, and it is unconditional and self-sustaining:
Chat/OpenClawReactorChatRoot.cs:312callsprops.ComposerSession.ApplyInputs(...)directly insideRender()— a side effect performed during render.- It passes
Revision: ++inputsRevisionRef.Current(OpenClawReactorChatRoot.cs:313), so the revision advances on every render. The staleness guard inApplyInputs(Chat/ChatComposerViewModel.cs:238,if (_inputs is { } current && inputs.Revision <= current.Revision) return;) can therefore never reject anything. Mutate→DrainQueue(Chat/ChatComposerViewModel.cs:421-423) runsnext(); RenderRevision++; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));— unconditionally, with no check for whether the mutation actually changed anything.Chat/ReactorChatComposer.cs:77is subscribed to exactly that event:void OnChanged(...) => setRenderRevision(vm.RenderRevision);— a state change, which schedules another render.- Back to step 1, at full CPU speed.
There are two compounding defects here. Note that the guard in ApplyInputs returns from inside the Mutate lambda, so even on the path where it does reject the stale input, Mutate still bumps RenderRevision and raises PropertyChanged. Either defect alone would sustain the loop given the other.
A contributing factor for why nothing memoizes out: ChatTimelinePresentationContext is a record rebuilt every render carrying freshly-allocated delegates (e.g. dataProvider.ResolveAssistantMediaAsync as a method group, and inline lambdas such as () => setScrollToBottomToken(...) at OpenClawReactorChatRoot.cs:326), so ReactorChatTimelineProps never compares equal to the previous props and the whole subtree re-reconciles each pass.
Suggested fix
- Move the
ApplyInputscall out ofRender()into aUseEffectkeyed on the actual input values, and deriveRevisionfrom content rather than incrementing it per render. - Independently, make
DrainQueueskipRenderRevision++/PropertyChangedwhen the mutation was a no-op. That breaks the cycle defensively even if a side effect is reintroduced into a render path later. - Optionally, stabilize the delegates on
ChatTimelinePresentationContext(cache viaUseRef/UseCallback) so unchanged subtrees can actually bail out of reconciliation.
Secondary, unrelated finding
Services/DeviceStatusProvider.cs:39-52 samples PerformanceCounter.NextValue() on a fixed 2 s timer. In the same dump I caught two threads simultaneously inside PerformanceMonitor.GetData — each sample is taking longer than the 2 s period, so callbacks overlap and pile up. That API also allocates a large buffer for the entire Processor category on every call. Recommend re-arming the timer via Change after each sample completes instead of using a fixed period.
Repro
Not yet reduced to a deterministic sequence — the loop was already running when investigated. It requires the Reactor chat surface to be mounted (ChatPage + ReactorChatComposer); given that ApplyInputs is called unconditionally on every render of the chat root, any render of a mounted chat root should be sufficient to start it. Happy to try to pin down an exact trigger if that would help.
Diagnostic method
dotnet-stack report (repeated samples), dotnet-counters collect --counters System.Runtime, and dotnet-dump collect --type Full + dumpheap -stat / gcroot / dumpobj. Note dotnet-gcdump cannot complete against the process in this state — the heap walk never finishes even with a 600 s timeout; a full dump was required.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Sep 4, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 4, 2026, 3:21 PM ET / 19:21 UTC.
Summary
Current main still contains the reported render-to-notification feedback path. This is a source-reproducible P0 tray-chat bug; the active-landing status indicates it already has maintainer ownership, so it should not receive a competing repair job.
Reproducibility: yes. from source. Current main renders an unconditional, monotonically revised input update, then unconditionally notifies a subscriber that schedules another Reactor update.
Regression provenance
Regression provenance — verified: source commit
686afdc8d4a2by Barbara Kudiess; canonical PR #1098 (blame-to-merge-commit).Next step
The bug has a small, source-proven repair shape, but
status: 🚢 actively landingshows active maintainer ownership; do not open a competing repair job.Review details
Best possible solution:
Apply composer inputs from a semantic-effect boundary rather than Render, suppress notifications for rejected or unchanged input projections, add regression coverage for no-op invalidation, then prove idle tray behavior on Windows.
Do we have a high-confidence way to reproduce the issue?
Yes, from source. Current main renders an unconditional, monotonically revised input update, then unconditionally notifies a subscriber that schedules another Reactor update.
Is this the best way to solve the issue?
Yes, with a semantic input-change guard in addition to moving the side effect out of Render. That breaks both the immediate cycle and the stale-input notification path without adding product surface.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 35cb92dcf28d.
Label changes
Label changes:
clawsweeper:queueable-fix: Current issue advisory state no longer selects this label.clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.Label justifications:
P0: The source-visible cycle can make the tray UI unresponsive while consuming a CPU core and exhausting memory.impact:crash-loop: The composer notification loop repeatedly schedules rendering from the mounted chat surface.Evidence reviewed
What I checked:
src/OpenClaw.Tray.WinUI/Chat/OpenClawReactorChatRoot.cs:312, 35cb92dcf28d)src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs:131, 35cb92dcf28d)src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs:75, 35cb92dcf28d)tests/OpenClaw.Tray.Tests/ChatComposerViewModelTests.cs:103, 35cb92dcf28d)src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs:136, 686afdc8d4a2)Likely related people:
src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs)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.larroy commentedon Sep 4, 2026
Seems related to dotnet/runtime#129191