Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a6b40e9
Name the component, not its element, in RenderError
azchohfi Oct 2, 2026
3404692
Report render errors an ErrorBoundary catches
azchohfi Oct 2, 2026
6728ac4
Cover RenderError on func/memo mount, nested boundary throws, and bot…
azchohfi Oct 5, 2026
96b4ab9
Cache generic component names and skip ComponentUnmount naming when t…
azchohfi Oct 5, 2026
d348e74
CHANGELOG: RenderError names the component and reports every render e…
azchohfi Oct 5, 2026
fe20e8f
Record the render-error catches in the spec-044 swallowed-error ledger
azchohfi Oct 5, 2026
5f95751
Don't read Exception.Message when emitting RenderError
azchohfi Oct 5, 2026
b1c100e
Report every exception an ErrorBoundary recovers from; fix stale attr…
azchohfi Oct 5, 2026
d8496be
Report OOM/SO render failures outside a boundary too
azchohfi Oct 6, 2026
4075055
Merge origin/main into azchohfi-render-error-component-name
azchohfi Oct 7, 2026
9ee41ea
Report root effect failures; name rollback unmounts like other unmounts
azchohfi Oct 7, 2026
0469209
Attribute root failures to the root that threw; format generic array …
azchohfi Oct 7, 2026
10f0fdb
Merge origin/main into azchohfi-render-error-component-name
azchohfi Oct 7, 2026
ef58dd2
Name derived function/memo elements by their own type on mount
azchohfi Oct 7, 2026
288575b
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi Oct 7, 2026
b585258
Format generic derived element names like any other generic component
azchohfi Oct 7, 2026
918ab90
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi Oct 7, 2026
3cc6999
Use System.Threading.Lock for the host registry gate (IDE0330)
azchohfi Oct 7, 2026
671fed2
Merge remote-tracking branch 'origin/main' into azchohfi-render-error…
azchohfi Oct 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ Conventions for contributors:

### Fixed

- **`RenderError` names the component that threw, and now reports every render
error** (issue #1321, spec 044 §6.2.1). For class components the event reported
Comment thread
azchohfi marked this conversation as resolved.
the element record (``ComponentElement`1`` / `ComponentElement`) instead of the
component unless the `Render` keyword was also on, so an Errors-only listener
such as `winapp devtools logs` could not tell which component failed. It now
reports the component's type name (`Counter`; a generic one as `Foo<Int32>`),
and the other per-component events agree on it. **Listeners now also receive
errors that were previously silent:** a component (class, function or memo)
throwing on its first render, a `ReactorHost` / `ReactorHostControl` root
component or render function throwing, and any render error an `ErrorBoundary`
catches — reported once, at the throw site, even though the app shows the
fallback. Same event, same payload; the message stays redacted. Generic
component names change from ``Foo`1`` to `Foo<Int32>` in every component event.

- **Dropping an `AutoSuggestBox` right after its text changed can no longer crash
the app** (PR #1302, supersedes #559). WinUI raises the box's `TextChanged` from
an internal timer 150 ms after its text last changed, keeps that timer running
Expand Down
13 changes: 9 additions & 4 deletions docs/_pipeline/templates/source-mapping.md.dt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ consumers can subscribe to just the render channel:
```csharp snippet="source:src/Reactor/Core/Diagnostics/ReactorEventSource.cs#etw-keywords"
```

`ComponentRenderStart` / `ComponentRenderStop` fire with
`componentName = node.Component?.GetType().Name`. That string is the
`ComponentRenderStart` / `ComponentRenderStop` fire with the component's
type name — `Counter` for a `Counter : Component<CounterProps>`, whichever
factory created it. That string is the
attribution token that flows into PerfView / `dotnet-trace` /
`xperf`, and it is the same string [`devtools-internals`](devtools-internals.md)
uses to label overlay frames. Per-component, not per-element — but
sufficient for the common question "which component is re-rendering
on every tick".
on every tick". `RenderError`, `EffectsFlushStart` / `Stop` and
`ComponentUnmount` use the same name. A generic component reports its type
arguments in C# form (`ItemList<Int32>`, not ``ItemList`1``); function and memo
components, which have no type of their own, report `FuncElement` and
`MemoElement`.

![Source attribution: component-name attribution flows Component.GetType().Name into ETW, while per-element attribution stamps each DSL call site with file and line via the interceptor generator, readable from any realized control through ReactorSourceMap.GetSource.](images/source-mapping/attribution.svg)

Expand All @@ -67,7 +72,7 @@ on every tick".
| `ReconcileStart` / `Stop` | Root element type + diff counters | ETW `Reconcile` keyword |
| `EffectsFlushStart` / `Stop` | Component CLR type name | ETW `Render` keyword |
| `StateChange` | Hook kind + value type | ETW `State` keyword |
| `RenderError` | Component name + exception type only (message redacted) | ETW `Errors` keyword |
| `RenderError` | Component name + exception type only (message redacted); emitted on mount, update and host-root renders, including errors an `ErrorBoundary` catches (named at the throw site, once) | ETW `Errors` keyword |
| Per-element file:line | Element call site | `Element.CallSite` / `ReactorSourceMap.GetSource` (when source mapping is enabled at build time) |

The reconcile pass also emits a counter summary on stop:
Expand Down
13 changes: 9 additions & 4 deletions docs/guide/source-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ public static class Keywords
}
```

`ComponentRenderStart` / `ComponentRenderStop` fire with
`componentName = node.Component?.GetType().Name`. That string is the
`ComponentRenderStart` / `ComponentRenderStop` fire with the component's
type name — `Counter` for a `Counter : Component<CounterProps>`, whichever
factory created it. That string is the
attribution token that flows into PerfView / `dotnet-trace` /
`xperf`, and it is the same string [`devtools-internals`](devtools-internals.md)
uses to label overlay frames. Per-component, not per-element — but
sufficient for the common question "which component is re-rendering
on every tick".
on every tick". `RenderError`, `EffectsFlushStart` / `Stop` and
`ComponentUnmount` use the same name. A generic component reports its type
arguments in C# form (`ItemList<Int32>`, not ``ItemList`1``); function and memo
components, which have no type of their own, report `FuncElement` and
`MemoElement`.

![Source attribution: component-name attribution flows Component.GetType().Name into ETW, while per-element attribution stamps each DSL call site with file and line via the interceptor generator, readable from any realized control through ReactorSourceMap.GetSource.](images/source-mapping/attribution.svg)

Expand All @@ -74,7 +79,7 @@ on every tick".
| `ReconcileStart` / `Stop` | Root element type + diff counters | ETW `Reconcile` keyword |
| `EffectsFlushStart` / `Stop` | Component CLR type name | ETW `Render` keyword |
| `StateChange` | Hook kind + value type | ETW `State` keyword |
| `RenderError` | Component name + exception type only (message redacted) | ETW `Errors` keyword |
| `RenderError` | Component name + exception type only (message redacted); emitted on mount, update and host-root renders, including errors an `ErrorBoundary` catches (named at the throw site, once) | ETW `Errors` keyword |
Comment thread
azchohfi marked this conversation as resolved.
Outdated
| Per-element file:line | Element call site | `Element.CallSite` / `ReactorSourceMap.GetSource` (when source mapping is enabled at build time) |

The reconcile pass also emits a counter summary on stop:
Expand Down
24 changes: 20 additions & 4 deletions docs/specs/044/swallowed-error-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ row gains a column and the gate rejects it.

| Verdict | Sites | Shipped | Deferred |
|---|---|---|---|
| `Keep` | 24 | 24 | 0 |
| `Keep` | 32 | 32 | 0 |
| `Narrow` | 38 | 38 | 0 |
| `Propagate` | 7 | 7 | 0 |
| `TryFinally` | 7 | 7 | 0 |
| `TryXxx` | 10 | 0 | 10 |
| `PromoteEvent` | 26 | 18 | 8 |
| `PromoteEvent` | 30 | 22 | 8 |
| `Deleted` | 7 | 7 | 0 |
| `Trace` | 5 | 5 | 0 |

Expand Down Expand Up @@ -253,7 +253,7 @@ file that exists, unless the heading carries a `(retired …)` marker.
| `EndOfStreamException` reject | 1 | `PromoteEvent` | shipped | Same. |
| Outer catches — `Capture`, `Restore` | 2 | `Narrow` | shipped | Narrowed to `IOException`. One clause each on the capture and restore paths; the original entry said "Outer catches" without a count. |

### `src/Reactor/Core/Reconciler.cs` — Phase C.7b (commit `054c53ef`) + Phase C.8 (commit `21cd6ef9`)
### `src/Reactor/Core/Reconciler.cs` — Phase C.7b (commit `054c53ef`) + Phase C.8 (commit `21cd6ef9`) + render-error reporting (issue #1321)

| Site(s) | Sites | Verdict | Status | Notes |
|---|---|---|---|---|
Expand All @@ -263,12 +263,16 @@ file that exists, unless the heading carries a `(retired …)` marker.
| ConnectedAnimation `GetAnimation` | 1 | `Keep` | shipped | **fail-safe-to-default.** Same. |
| ConnectedAnimation `TryStart` | 1 | `Keep` | shipped | **fail-safe-to-default.** Same. |
| `ApplyThemeBindings` | 1 | `Keep` | shipped | **fail-safe-to-default.** LogCategory.Theme — the catch wraps a XAML `Style.Load` compile. Could narrow to `XamlParseException` in a follow-up. |
| `ReconcileComponent` render catch outside any `ErrorBoundary` (`_errorBoundaryDepth == 0`) | 1 | `Keep` | shipped | **user-callback isolation** per §6.7.3 — the `try` wraps the app's `Render()` and the effect flush, so the failure class is arbitrary app code and cannot be narrowed. The render is replaced by `ErrorFallback`, and the failure is reported through `ILogger` and the typed `RenderError` event, naming the component (issue #1321, PR #1323). `OutOfMemoryException` / `StackOverflowException` are filtered out and propagate. Pre-dates the ledger; adjudicated when #1321 touched it. |
| `ReconcileComponent` render catch inside an `ErrorBoundary` (`_errorBoundaryDepth > 0`) | 1 | `PromoteEvent` | shipped | Report-and-rethrow, **not a swallow**: emits `RenderError` naming the component that threw — the only frame that knows it — then `throw;` rethrows unchanged to the enclosing boundary, which renders its fallback and does not report again (one event per throw). Added by issue #1321 / PR #1323. |

### `src/Reactor/Core/Reconciler.Mount.cs` — Phase C.8 (commit `21cd6ef9`)
### `src/Reactor/Core/Reconciler.Mount.cs` — Phase C.8 (commit `21cd6ef9`) + render-error reporting (issue #1321)

| Site(s) | Sites | Verdict | Status | Notes |
|---|---|---|---|---|
| `ContentDialog.ShowAsync + OnClosed` | 1 | `Keep` | shipped | **user-callback isolation** per §6.7.3 — the try wraps both `ShowAsync` AND the user-supplied `OnClosed` delegate. Cannot narrow without splitting the try-catch into two; deferred. |
| First-render catches outside any `ErrorBoundary` (`_errorBoundaryDepth == 0`) — `MountComponent`, `MountFuncComponent`, `MountMemoComponent` | 3 | `Keep` | shipped | **user-callback isolation** per §6.7.3 — each `try` wraps the app's first `Render()` (class, function or memo component) and its effect flush; arbitrary app code, so no narrowing. The render is replaced by `ErrorFallback` and reported through `ILogger` and, since issue #1321 (PR #1323), the typed `RenderError` event — these arms previously only logged. `OutOfMemoryException` / `StackOverflowException` propagate. Pre-date the ledger; adjudicated when #1321 touched them. |
| First-render catches inside an `ErrorBoundary` (`_errorBoundaryDepth > 0`) — `MountComponent`, `MountFuncComponent`, `MountMemoComponent` | 3 | `PromoteEvent` | shipped | Report-and-rethrow, **not a swallow**: emits `RenderError` naming the component that threw, then `throw;` rethrows unchanged to the enclosing boundary, which does not report again (one event per throw). Added by issue #1321 / PR #1323. |

### `src/Reactor/Core/RenderContext.cs` — Phase C.6 (commit `90d516b0`) + Phase C.9 narrowing

Expand Down Expand Up @@ -307,6 +311,18 @@ types without making it a narrowing. Same shape as the existing convention at
| `CanResolvePageType` resolver probe | 1 | `Keep` | shipped | **fail-safe-to-default.** The method's contract is "true **only if** definitively resolvable". Any failure to answer means we cannot confirm, and returning `false` refuses the navigation — the safe direction, and the one that cannot produce the access violation. Expected types are `COMException` at the WinRT boundary and `InvalidOperationException` / `ArgumentException` from a generated or hand-written `IXamlMetadataProvider`; propagating anything else would convert a third-party provider's bug into a render-loop error **while the navigation is refused either way**, i.e. strictly worse for identical safety. `OutOfMemoryException` / `StackOverflowException` still propagate. |
| `TryNavigate` around `Frame.Navigate` | 1 | `Keep` | shipped | **user-callback isolation** (§6.7.3). What surfaces here is the **page constructor's** exception — arbitrary application code — and routing it into the element's declared `OnNavigationFailed` channel is the arm's entire purpose. Directly analogous to the `ContentDialog.ShowAsync + OnClosed` entry above. **Narrowing would reintroduce the defect this fix exists to remove:** an unanticipated page-constructor failure would escape the mount pass. **Coverage gap, stated rather than hidden:** reaching this arm needs a target that *resolves* but whose constructor then throws, i.e. a real `.xaml`-backed page. The selftest host ships no XAML, so every target it can offer is either refused before `Navigate` (code-only) or a framework type that constructs fine. The arm is therefore reasoned-about, not exercised — unlike the refusal path, which `FrameNav_CodeOnlyPageRefusedNotFatal` pins directly. |

### `src/Reactor/Hosting/ReactorHost.cs` — render-error reporting (issue #1321)

| Site(s) | Sites | Verdict | Status | Notes |
|---|---|---|---|---|
| Root render catches in `Render` — root component `Render()`, root render function | 2 | `Keep` | shipped | **user-callback isolation** per §6.7.3 — each `try` wraps the app's root render, arbitrary app code. The host shows its error fallback and keeps running; the failure is reported through `ILogger` and, since issue #1321 (PR #1323), the typed `RenderError` event — previously these arms only logged. A `HookOrderException` during a hot-reload render is handled by the preceding, narrower clause. Pre-date the ledger; adjudicated when #1321 touched them. |

### `src/Reactor/Hosting/ReactorHostControl.cs` — render-error reporting (issue #1321)

| Site(s) | Sites | Verdict | Status | Notes |
|---|---|---|---|---|
| Root render catches in `Render` — root component `Render()`, root render function | 2 | `Keep` | shipped | **user-callback isolation** per §6.7.3. Same shape and reporting as `ReactorHost.cs` above. |

### `src/Reactor/Hosting/ReactorWindow.cs` — Phase C.8 (commit `21cd6ef9`) + Phase C.9 narrowing

Phase C.8 migrated the file's `Debug.WriteLine` calls to `DiagnosticLog` with
Expand Down
82 changes: 82 additions & 0 deletions src/Reactor/Core/Diagnostics/ComponentNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
namespace Microsoft.UI.Reactor.Core.Diagnostics;

/// <summary>
/// The component name Reactor's diagnostics report (<c>ReactorEventSource</c>
/// <c>RenderError</c>, <c>ComponentRenderStart</c>/<c>Stop</c>,
/// <c>EffectsFlushStart</c>/<c>Stop</c>, <c>ComponentUnmount</c>, and the
/// reconciler's <c>ILogger</c> messages).
///
/// <para><b>Why not <c>element.GetType().Name</c>.</b> A class component is carried by a
/// <see cref="ComponentElement"/> — and by <c>ComponentElement&lt;TProps&gt;</c> for
/// <c>Component&lt;T, TProps&gt;(…)</c> — so naming the <em>element</em> reports
/// <c>ComponentElement</c> / <c>ComponentElement`1</c> for every class component in
/// the app. The component is <see cref="ComponentElement.ComponentType"/> (or the live
/// instance's type, which wins after a hot-reload type swap).</para>
///
/// <para><b>Shape.</b> The type's own simple name, as before, for a non-generic
/// component (<c>Counter</c>), so existing traces and greps are unchanged. A generic
/// component renders its arity in C# form (<c>Counter&lt;Int32&gt;</c>) instead of the
/// metadata name (<c>Counter`1</c>). Function and memo components have no type of their
/// own and keep reporting <c>FuncElement</c> / <c>MemoElement</c>.</para>
///
/// <para><b>PII.</b> Output is built only from developer-authored type names — never
/// props, state, keys or paths — so it is safe on the ETW payload
/// (spec 044 §6.2.1).</para>
///
/// <para>Reflection-light (<c>Type.Name</c> and <c>Type.GetGenericArguments()</c>),
/// so it is trim- and AOT-safe.</para>
/// </summary>
internal static class ComponentNames
{
/// <summary>
/// Name for a component node: the live <paramref name="instance"/>'s type when there
/// is one, else the component type an element declares, else the element's own type
/// (<c>FuncElement</c>, <c>MemoElement</c>).
/// </summary>
internal static string For(Component? instance, Element? element)
{
if (instance is not null) return For(instance.GetType());
if (element is ComponentElement componentElement) return For(componentElement.ComponentType);
return element?.GetType().Name ?? "unknown";
Comment thread
azchohfi marked this conversation as resolved.
Outdated
}

/// <summary>Display name of a component type; see the class remarks for the shape.</summary>
internal static string For(Type type)
{
if (!type.IsGenericType) return type.Name;

// Generic names are built, so cache them: the name is asked for on every traced
// render and unmount. A weak table, so it never roots a collectible or hot-reloaded type.
return s_genericNames.GetValue(type, static t =>
{
var sb = new global::System.Text.StringBuilder();
Append(sb, t);
return sb.ToString();
});
}
Comment thread
azchohfi marked this conversation as resolved.

private static readonly global::System.Runtime.CompilerServices.ConditionalWeakTable<Type, string> s_genericNames = new();

private static void Append(global::System.Text.StringBuilder sb, Type type)
{
var name = type.Name;
var tick = name.IndexOf('`');
sb.Append(tick >= 0 ? name.Substring(0, tick) : name);

if (!type.IsGenericType) return;

// For a nested generic the flat argument list also carries the declaring type's
// arguments; this name only reports the ones it introduces itself.
var args = type.GetGenericArguments();
int own = tick >= 0 && int.TryParse(name.AsSpan(tick + 1), out var arity) ? arity : 0;
if (own == 0) return;

sb.Append('<');
for (int i = args.Length - own; i < args.Length; i++)
{
if (i > args.Length - own) sb.Append(", ");
Append(sb, args[i]);
}
sb.Append('>');
}
}
27 changes: 26 additions & 1 deletion src/Reactor/Core/Reconciler.Mount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,18 @@ private UIElement MountComponent(ComponentElement compElement, Action requestRer
}
component.Context.FlushEffects();
}
// Inside an ErrorBoundary: name the failing component, then let the boundary
// handle it (see ReconcileComponent).
catch (Exception ex) when (_errorBoundaryDepth > 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
EmitRenderError(Diagnostics.ComponentNames.For(component, compElement), ex);
throw;
Comment thread
azchohfi marked this conversation as resolved.
Outdated
}
catch (Exception ex) when (_errorBoundaryDepth == 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
_logger?.LogError(ex, "Component Render() threw during mount: {ComponentName}", compElement.GetType().Name);
var failedName = Diagnostics.ComponentNames.For(component, compElement);
_logger?.LogError(ex, "Component Render() threw during mount: {ComponentName}", failedName);
EmitRenderError(failedName, ex);
childElement = ErrorFallback.BuildElement(ex);
}
UIElement? childControl = Mount(childElement, componentRerender);
Expand Down Expand Up @@ -905,9 +914,17 @@ private UIElement MountFuncComponent(FuncElement funcElement, Action requestRere
}
ctx.FlushEffects();
}
// Inside an ErrorBoundary: name the failing component, then let the boundary
// handle it (see ReconcileComponent).
catch (Exception ex) when (_errorBoundaryDepth > 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
EmitRenderError(nameof(FuncElement), ex);
Comment thread
azchohfi marked this conversation as resolved.
Outdated
throw;
}
catch (Exception ex) when (_errorBoundaryDepth == 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
_logger?.LogError(ex, "FuncComponent Render() threw during mount");
EmitRenderError(nameof(FuncElement), ex);
childElement = ErrorFallback.BuildElement(ex);
}
UIElement? childControl = Mount(childElement, componentRerender);
Expand Down Expand Up @@ -945,9 +962,17 @@ private UIElement MountMemoComponent(MemoElement memoElement, Action requestRere
}
ctx.FlushEffects();
}
// Inside an ErrorBoundary: name the failing component, then let the boundary
// handle it (see ReconcileComponent).
catch (Exception ex) when (_errorBoundaryDepth > 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
EmitRenderError(nameof(MemoElement), ex);
Comment thread
azchohfi marked this conversation as resolved.
Outdated
throw;
}
catch (Exception ex) when (_errorBoundaryDepth == 0 && ex is not OutOfMemoryException and not StackOverflowException)
{
_logger?.LogError(ex, "MemoComponent Render() threw during mount");
EmitRenderError(nameof(MemoElement), ex);
childElement = ErrorFallback.BuildElement(ex);
}
UIElement? childControl = Mount(childElement, componentRerender);
Expand Down
Loading
Loading