Managed view hierarchy: RectTransform corners without GetWorldCorners' transform call #296
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 608 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.384
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #296"
general
weight: 0.35
krassx
What changed
Optimisation #3 of the scene-read research: the managed view hierarchy walker no longer calls
RectTransform.GetWorldCornersper UI node. On Unity 2021.3 and 2022.3 that method readsthis.transform(a native call) beforelocalToWorldMatrix; the walker now readsrectandlocalToWorldMatrixand runs the same arithmetic in a pure helper,ManagedViewCorners(Runtime/WrapperPolicy): same four-corner order (bottom-left, top-left, top-right, bottom-right) and the sameMultiplyPointoperation order, including the divide by w. On 6000.0GetWorldCornersalready has notransformread, so nothing is saved there.Also in the sample harness:
vhscaletakes an optionalbugsee_vh_countslist, logsusPerNodeand a bit-for-bit corner check;vhscenefails on a corner mismatch.Optimisation #2 (GetInstanceID -> GetHashCode) was NOT done: the premise is wrong in the player
The research read the editor assembly, where
Object.GetHashCode()isreturn m_InstanceID. The player assemblies differ. InPlaybackEngines/AndroidPlayer/Variations/il2cpp/Managed/UnityEngine.CoreModule.dllof 2021.3.45f1, 2022.3.62f3 and 6000.0.84f1,Object.GetHashCode()isbase.GetHashCode()(the CLR object hash), whileGetInstanceID()reads the id from the native object's memory (m_CachedPtr + OffsetOfInstanceIDInCPlusPlusObject) with no icall. On the HONOR (IL2CPP release, 2021.3.45f1) a first build that used GetHashCode failed the check for all 1002 objects (idMismatches=1002), so scene-block ids,drawnByand camera ids would have stopped matching. The ids stay onGetInstanceID(); its real cost there is about 0.37 to 0.40 us per call against 0.06 for GetHashCode, so there was little to gain anyway.How it was verified
Tests~/WrapperPolicy: 2603 passed, including 10 newManagedViewCornersTests: 8 cases whose expected values were produced by Unity 2021.3.45f1 itself (plain, offset pivot with scale, rotated, mirrored, mirrored and rotated, tilted in 3D, rotated and scaled parent with rotated child, zero size) plus order and 90 degree tests, compared with exact equality.sh Tools~/scripts/compile-check.sh: all 11 configurations ok.[VHSCALE] reads check PASS(401 RectTransforms, 0 corner mismatches, bit for bit againstGetWorldCorners).vhscene(development build) on the same device with main's walker and with this change: 45 PASS, 0 FAIL each, reply 3438 chars, identical md5 (40af080c...); a second launch of main's build differed only in theframecounter (15 vs 16).vhscale, IL2CPP release, 4 launches with data each in alternating order, 8 captures per N per launch (medians of main-thread ms per tree node; the walker reads only part of the scene within its slice budget, so a capture has a few hundred nodes):| N | before | after | change | per-launch medians before | per-launch medians after |
|---|---|---|---|---|---|
| 1000 | 25.79 us/node | 24.30 | -5.8% | 23.9, 26.0, 26.0, 26.7 | 23.6, 24.5, 23.6, 28.2 |
| 5000 | 19.03 us/node | 17.68 | -7.1% | 18.0, 19.8, 17.2, 20.0 | 17.2, 18.3, 17.4, 18.7 |
The launch-to-launch spread (about 2 to 5 us) is as large as the difference, and the microbenchmark says the real saving is small:
GetWorldCorners2.25 us vs own corners 1.72 to 1.86 us per RectTransform (about 0.4 us, roughly 0.15 us averaged over all nodes). Treat the gain as small and partly within noise. (One launch per variant was lost to an app that did not start and was re-run.)Evaluation of #4 / #10 (bulk enumeration), no production change
See
ENUM-BENCH-RESULTS.mdon branchspike/vh-enum-bench(EnumBench.cs, HONOR, IL2CPP release).GetComponentsInChildren<Transform>(false, list)costs 0.9 to 1.2 us per returned node against 1.7 to 2.9 for the bare walk, but rebuilding the tree needsparent(0.55 to 0.7 us) plus an id lookup: 1.7 to 2.3 us, no gain over the walk. The returned order was pre-order and sibling-equal in every configuration (booleans only, not relied on). A bulk call is not sliceable: 5.5 ms at 4889 nodes, 20 ms at 18889 nodes under one root (budget 0.83 ms), 2.7 ms for the largest of 8 roots at 20000.FindObjectsByType<Transform>(None): 1.5 to 5.2 us per node, up to 37 ms in one call, whole process. Recommendation: reject.Known gaps
No iPhone, 2022.3 or 6000.0 device numbers; no Mono build measured. The fresh Opus review found 2 low issues (loose ulp tolerance, README for the vhscale extras), both fixed in the last commit; no second review pass was run for that test and doc only follow-up.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WeiJxQSiPP4vp79ZPpBsqf