← Back to Pull requests

Managed view hierarchy: object names are an opt-in of CaptureSceneGraph; nodes labelled by their most telling component; names_omitted marker #305

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 01, 2026 12:01 UTC
Author

What

Object names become an opt-in of the managed view hierarchy, so that the capture is as cheap and as steady as it can be. The Unity-only launch option CaptureSceneGraph (com.bugsee.option.unity.capture-scene-graph) keeps its key; its enum SceneGraphCapture now encodes two independent choices, positions and object names:

| Value | Object names | Positions (bounds + scene block) | Was |
|---|---|---|---|
| None | no | no | None |
| Structure | no | no | new |
| StructureWithNames | yes | no | NamesOnly |
| Scene (default when omitted) | no | yes | new |
| SceneWithNames | yes | yes | All (the old default) |

Three behavior changes, all in the CHANGELOG under Unreleased:

1. Default: an app that does not set the option used to send every GameObject name and scene name; it now reads and sends none. SceneWithNames restores the old default.
2. class_name at every level: a node is labelled by the component that says best what the object is, not by its first component (a mesh was MeshFilter, now MeshRenderer; a button was Image, now Button; an object with your script reads the script's name).
3. New root key: a reply made without names carries "names_omitted": true on its root node.

Related PRs (none has to merge first; the key is optional and an unknown key is ignored):

  • Spec, defines names_omitted: bugsee/specs#90

  • Viewer, reads it and shows names when they are there: bugsee/bugsee-web-viewer#229

  • Docs site (draft, to merge with the release): bugsee/docs#188
  • Stacked on #304 (perf/vh-walker-per-node), which rewrites the same walker. This PR's base is that branch; retarget it to main after #304 merges. #303 (fix/au377-scene-feed) touches ManagedViewBudget / ManagedViewCaptureEngine.Submit next to lines changed here, so whichever lands second may need a one-line rebase. CHANGELOG and #301: see "CHANGELOG" below.

    Why names are off by default

    Performance and stability first: Object.name is the one per-object read of the walk that allocates (a string per object, on the main thread, garbage for the collector). Without it a capture costs about 2 µs (20 %) less per node, reads 17 to 19 % more nodes in its 250 ms window and leaves nothing to collect (numbers below). Embedders who accept the overhead opt in through the launch option. Privacy is a side benefit: a name is free text a game can fill at run time, and by default none is collected. The docs, the CHANGELOG, DESIGN.md and the XML docs say it in this order.

    Scene names stay withheld at the default level (decided): a Scene node carries its name only at the WithNames levels.

    How it works

  • Walker (Runtime/Internal/ManagedViewHierarchy.cs): Object.name and Scene.name are read only when the level sends names. A source-text test pins these as the only two name reads, and forbids Scene.path, ToString of a Unity object, interpolation and concatenation with one.

  • Node label (ManagedViewLabel in Runtime/WrapperPolicy/ManagedViewTypeCache.cs): each component type has a rank, worked out once per type and kept in the type cache beside the type's name: a script from outside the UnityEngine, Unity, TMPro and Cinemachine namespaces (the app's and third-party assets') > a uGUI control (derived from Selectable) > any other component > a MeshFilter or a missing script. class_name is the component of the highest rank, the first in component order among equals; no component gives RectTransform / GameObject as before. In the walk this replaces if (first == null) first = name; by if (rank > bestRank) { bestRank = rank; best = name; }: no engine call, no allocation, no GetType added (a test pins the loop's text and its single GetType / GetComponents). Types are recognised by full name, so the pure code needs no reference to the engine or to uGUI and is unit-tested with stand-in types.

  • Marker (ManagedViewTreeJson.NamesOmittedKey): "names_omitted":true right after the root's class_name / bounds, written by the writer when it writes no names, so also in the tree-only fallback, in a tree cut by its deadline, with or without positions and beside the scene block. Never written with names.

  • Writer and engine: EmitNames beside EmitBounds; the engine writes names (and positions) only when both the snapshot and the capture's level say so.

  • Secure rectangles: unchanged. Under a rectangle a node loses its component list, and its name at the levels that send names; it keeps class_name (a type name) and its bounds.

  • Parsing: by constant name, any case, _ and - ignored; anything else is None and logged. SendsNames(level) / SendsPositions(level).
  • The marker: name and shape

    names_omitted, boolean, true only, root only. A flag written only when true is how this tree already states something exceptional about a capture (truncated, best_effort), so absence keeps meaning "nothing to say" and every older document stays valid; "omitted" is the spec's word for data a wrapper is set not to send (bounds, scene). The capture level itself is not written: it is this wrapper's vocabulary, and a consumer needs the one fact. It sits on the root, not in scene, because a reply without positions has no scene. Without it a missing options.name is ambiguous (names off, a node under a secure rectangle, an older SDK).

    Viewer check for the class_name change

    bugsee/bugsee-web-viewer main uses class_name as the row title and breadcrumb (nodeDisplayName), as the "Class" row of the properties sheet, for the TOPITEM sentinel of native roots, and in the list of class fields for symbolication. No icon, filter or type label is keyed on a particular class name, and nothing mentions MeshFilter, MeshRenderer or UnityPlayer outside test fixtures. Nothing breaks; rows simply read better.

    Migration (beta)

  • The enum members NamesOnly and All are removed: code that names them stops compiling and has to choose (StructureWithNames / SceneWithNames are what they sent).

  • The stored strings "NamesOnly" and "All" are still read, as exactly what they sent before. Neither can send more than the same string did. (Whether they should log a deprecation note is on hold.)

  • An omitted option is the only thing that changes meaning: it was All (with names) and is now Scene (without).

  • An assembly compiled against the old enum carries the numbers 1 and 2, which now mean Structure and StructureWithNames: less than before, never more.

  • Anything that matched on the old first-component value of class_name has to be adjusted.
  • CHANGELOG (item 6, and #301)

    Open PR #301 already adds the missing heading: its whole diff is ## [7.0.0-beta.2] - 2026-11-27 and a blank line directly under ## [Unreleased], which is right, because everything under Unreleased on main is in the tag v7.0.0-beta.2 (checked: main's Unreleased body equals the tag's beta.2 section).

    I did not add a second heading somewhere else. This branch contains the same two lines at the same place, and puts under Unreleased only what is not in the tag: this PR's entries and the one entry #304 added ("The managed view hierarchy walk does less for every object it reads", moved up verbatim, since it sat in what becomes the released section). From the beta.2 heading down the file is byte-identical to main with #301 applied (asserted by the script that built it, and checked again by a reviewer against origin/main and the tag).

    What to do: merge #301 first. After that, when this PR is retargeted and rebased, the heading lines are already there; check grep -c '^## \[7.0.0-beta.2\]' CHANGELOG.md gives 1 (both sides insert at the same spot, so git may report a conflict or, depending on alignment, duplicate the heading). If #304 merges before this, its bullet lands under the beta.2 heading on main and has to move up; this branch already has it in the right place.

    Verification

  • dotnet test Tests~/WrapperPolicy: 2698 passed. sh Tools~/scripts/compile-check.sh: 11/11.

  • Options manifest tests: capture-scene-graph stays Unity-only; OptionPlatformGate passes the value through unchanged.

  • Device: HONOR WOD-LX1 (Android 14), Unity 2021.3.45f1, IL2CPP, BUGSEE_NO_SYMBOL_UPLOAD=1, device lock held, test app uninstalled afterwards. Release builds for everything timed.

  • - vhscene (self-checking, release), with the new label rule and the marker, at every level: default 56 PASS / 0 FAIL, scenewithnames 55/0, structure 21/0, structurewithnames 20/0, none 2/0, old all 55/0 (read as SceneWithNames), old namesonly 20/0 (read as StructureWithNames), bogus 2/0 (refused, no tree). It checks, among the rest: a cube is MeshRenderer with components MeshFilter,MeshRenderer, the object with the scenario's script is labelled by it, a camera is Camera, an object without components is RectTransform; the root carries names_omitted exactly when the level sends no names, once; no fixture name is anywhere in a reply without names.
    - vhsecurescale (release): PASS at the default level and at scenewithnames.
    - vh on a development build (functional run only, no timing claim), the scenario that could not be run before:

        default level:
        [Sample] vh PASS capture 1 answered with a tree
        [Sample] vh PASS capture 2 answered with a tree
        [Sample] vh PASS tree has nodes
        [Sample] vh PASS tree is non-empty JSON
        [Sample] vh PASS capture call to reply stayed inside the SDK's 500 ms window
        [Sample] vh PASS no node is secured while no secure rectangle is registered
        [Sample] vh labelled share of the nodes without a rectangle=0.93
        [Bugsee] managed view hierarchy: 250 nodes, 24267 chars, ... truncated, secured 134; scene 19 objects, 1 cameras
        [Sample] vh PASS many nodes under the screen-sized rectangle lost their name or components
        [Sample] vh PASS nothing is secured once the rectangle is removed
        [Sample] vh e2e done failures=0
    
        bugsee_scene_graph=scenewithnames: the same lines, labelled share 0.99, secured 55 of 106, failures=0
        

  • Not run: iPhone XS (KRSFT is still offline in xctrace list devices), so no iOS device run; the iOS bridge is not touched and CI's iOS bridge tests pass. The last commit (the Cinemachine namespace in the once-per-type rank, tests and wording) was made after the device runs; it does not touch the per-node path.
  • Measured (HONOR WOD-LX1, release, 21 warm captures per cell, medians)

    Harness: vhscale / vhscaleunsliced as in #304's evidence, synthetic scenes of 1000 and 5000 objects, 3 launches per cell, launches alternated, 8 captures per N per launch with the first dropped. Tree cost per node = (main ms - scene main ms) / nodes.

    Names off against names on (same APK, level given at launch):

    | Mode | N | Scene (default, no names) | SceneWithNames | Difference |
    |---|---|---|---|---|
    | Unsliced, tree µs/node | 1000 | 8.01 (7.69..9.71) | 10.34 (9.17..12.11) | -2.33 µs, -22.5 % |
    | Unsliced, tree µs/node | 5000 | 7.62 (7.29..8.42) | 9.51 (8.73..11.65) | -1.89 µs, -19.9 % |
    | Sliced, nodes in 250 ms | 1000 | 1186 (992..1439) | 1013 (825..1252) | +17.1 % |
    | Sliced, nodes in 250 ms | 5000 | 1323 (1106..1500) | 1114 (785..1402) | +18.8 % |

    The new label rule against the old one (two APKs, default level, launches alternated; "old" is this branch one commit before the rule):

    | Mode | N | New rule | Old rule (first component) | Difference |
    |---|---|---|---|---|
    | Unsliced, tree µs/node | 1000 | 8.17 (7.83..8.95) | 8.31 (7.83..9.01) | -0.15 µs, -1.8 % |
    | Unsliced, tree µs/node | 5000 | 7.93 (7.54..8.59) | 7.96 (7.56..8.74) | -0.03 µs, -0.4 % |
    | Sliced round 1, tree µs/node | 1000 | 11.59 (10.73..13.08) | 11.24 (10.56..14.55) | +0.35 µs, +3.1 % |
    | Sliced round 1, tree µs/node | 5000 | 9.92 (9.48..14.24) | 9.48 (8.75..10.96) | +0.44 µs, +4.6 % |
    | Sliced round 2, tree µs/node | 1000 | 11.23 (10.51..11.89) | 11.15 (10.44..13.51) | +0.08 µs, +0.7 % |
    | Sliced round 2, tree µs/node | 5000 | 9.87 (9.51..14.20) | 10.15 (9.37..12.99) | -0.28 µs, -2.7 % |
    | Sliced, nodes in 250 ms (rounds 1, 2) | 1000 | 1111, 1169 | 1147, 1136 | -3.1 %, +2.9 % |
    | Sliced, nodes in 250 ms (rounds 1, 2) | 5000 | 1239, 1238 | 1260, 1261 | -1.7 %, -1.8 % |

    Reading: in the unsliced walk, the cleanest per-node number, the new rule is not slower. In the sliced walk the first round was 3 to 5 % slower and the second, run with the launch order reversed, was within 1 % at N=1000 and 2.7 % faster at N=5000; every difference is smaller than the p10..p90 spread of its own cell, and two measurements of identical walker code in different sessions (the default-level row of the first table against the "old rule" row here) differ by as much (8.01 against 8.31, 7.62 against 7.96). So: no cost that this measurement can tell from its noise, which is what one integer comparison per component should give. The rule is kept. (A stricter bound would need many more launches; say so if you want them.)

    Review

    Fresh Opus reviewers, no shared context, the diff and the task text only. First part of the PR: three rounds, the third clean. This second part: three rounds on the SDK diff (the first found four should-fix items: a marker test that never cut its tree, Cinemachine 2 ranked as an app script, two stale sentences; the third was clean) and four rounds on the spec and viewer diffs (the fourth clean).

    Open questions

    1. Old strings "All" / "NamesOnly": a deprecation note and a removal date (on hold, per the coordinator).
    2. The label rule's namespace list (UnityEngine, Unity, TMPro, Cinemachine count as Unity's): a project that puts its own code under Unity. gets it ranked as a package's, and a third-party asset's script ranks like the app's. Both are documented; say if another root should be on the list.
    3. An iOS device run when the iPhone XS is back.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01WeiJxQSiPP4vp79ZPpBsqf

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: krassx Review duration: 358m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #305"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%