Vixen
dd8b0a81
csharp
public readonly struct UiDiagnostics

What a debug overlay may read about a document, without being able to disturb it.

Read the guide page for this →

Remarks

An aggregator rather than an instrument. Every number here but the dirty regions was already published by the pass that computes it, one property at a time across the UiDocument partials — see this assembly's README § Diagnostics, where the shape and the three constraints behind it are argued. What was missing was one place to read them from, which is the whole of what doc 13's UI-debug overlay was blocked on.

⚠ It reads; it never samples. The reactive graph is single-threaded by contract, so a diagnostics surface that could touch a signal to answer a question would be able to perturb the document it is describing. Every member here is a field read or a walk of results that already exist, and none of them marks anything dirty.

⚠ And nothing on the read path allocates. A UI-debug overlay is on for minutes at a time in the frame it is diagnosing, so a surface that allocated per read would be measuring itself — which is the trap #597 is about one level up, where three boxed IReadOnlyList<T> enumerators cost a settled frame 504 bytes. This is a struct over the document, the regions come back as a span, and there is no list or string anywhere in it.

Fields and properties (15)

  • public const bool RecordsRegions

    Whether this build records dirty regions at all.

  • public int LayoutNodes

    How many nodes the layout tree holds.

  • public int StylesResolved

    How many elements the last pass cascaded.

  • public int StylesApplied

    How many had their layout style rebuilt from the result.

  • public int ContainerScopesEntered

    How many container scopes the last pass entered.

  • public int StyleCompactions

    How many times the style store has been compacted.

  • public int SettlingPasses

    How many passes the last frame needed before nothing moved.

  • public bool Settled

    Whether the document has come to rest.

  • public bool LastPassWasCold

    Whether the last restyle had to resolve every element rather than a few.

  • public ReadOnlySpan<UiDirtyRegion> DirtyRegions

    What invalidated the document before the pass Update most recently ran.

  • public int RegionsRecorded

    How many invalidations were recorded, including any the ring had no room for.

  • public int DrawListsBuilt

    How many times a surface's draw list has been rebuilt from the tree.

  • public int DrawListsChanged

    How many of those rebuilds produced drawing that differs from the frame before.

  • public int BrokenBindings

    How many times a binding in this document has thrown and been suspended.

  • public string? LastBrokenBinding

    Where the last such binding was written, and what it threw. Null until one does.

Methods (3)

  • public UiDiagnostics(UiDocument document)

    What a debug overlay may read about a document, without being able to disturb it.

  • public bool TryDescribe(float x, float y, out UiElement? element, out UiBoxModel box)

    The element at a point, and its four boxes.

  • public UiBoxModel BoxOf(UiElement element)

    An element's four boxes.

Used by (6)

  • BrokenBindingTestsVixen.Ui.Tests
  • DiagnosticsPanelVixen.Ui.Controls
  • DiagnosticsPanelTestsVixen.Ui.Controls.Tests
  • DiagnosticsTestsVixen.Ui.Tests
  • IdleFrameWorkTestsVixen.Ui.Tests
  • UiDocumentVixen.Ui