Repository navigation
refactor: Register DependencyObject.Name without the holder - #25214
MartinZikmund wants to merge 2 commits into
Conversation
|
Claude finished @MartinZikmund's task in 22s —— View job Review of #25214Verdict: ship (0 blocking, 1 minor, 0 nits beyond that).
|
| /// Returns the backing table: sparse, in hash order (not registration order), and a snapshot that may | ||
| /// or may not reflect properties added while it is being walked. | ||
| /// </summary> | ||
| internal DependencyPropertyDetails?[] GetAllDetails() => _entries; |
There was a problem hiding this comment.
Minor (non-blocking): GetAllDetails() returns the live table, and the Enter/Leave and theme-update walks (DependencyObject.PropertySystem.mux.cs:56,127, DependencyObject.Theming.cs:717) call GetValue, which can create details, inside the loop. If that triggers Grow(), the walk keeps reading the old array, so properties added mid-walk are skipped. Before, they would have been visited. The doc comment already says this may happen, and it was true of the bucket storage too. Still, the enter/leave walks now visit properties in hash order, not registration order. WinUI walks them in field order, so any enter-order-sensitive logic (e.g. the theme-before-children comment at PropertySystem.mux.cs:61) is only protected by the tests in this PR. Consider one runtime test that asserts enter order for a DO that holds both a collection and a child DO.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25214/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25214/docs/index.html |
|
The build 238895 found UI Test snapshots differences: Details
|
|
|
eb2b871 to
e159388
Compare
|
Claude finished @MartinZikmund's task in 16s —— View job Review of #25214Verdict: ship. 0 blocking, 0 major, 1 minor (already raised by the earlier review, so no new inline comment).
|
e159388 to
bf49253
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25214/wasm-skia-net9/index.html |
bf49253 to
b946bb2
Compare
|
Claude finished @MartinZikmund's task in 13s —— View job Review of #25214Verdict: ship. Blocking 0, major 0, minor 1 (already raised, so no new inline comment).
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25214/docs/index.html |
b946bb2 to
7b2aceb
Compare
|
Claude finished @MartinZikmund's task in 13s —— View job Review of #25214Verdict: ship. Blocking 0, major 0, minor 1 (already raised in the earlier inline review, so no new inline comment).
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Verified by inspection at head 7b2aceb: the storage change is identical to #25047 (the carried commits match its diff). IsNameVisibleOn keeps its truth table after dropping the owner check, because the old check only avoided forcing registration of DependencyObject.NameProperty. FrameworkElement.NameProperty is still a public static new property with the same value. WinUI parity holds for DO-level registration: WinUI treats DependencyObject_Name as a DO-level property (dxaml/xcp/components/DependencyObject/PropertySystem.cpp:2137). No _entryOffsets, _pool, or Dispose references remain.
I did not build or run anything, so this is code review by inspection only. The allocation, cycle-count and test-count numbers are the author's.
Findings, most important first:
-
CI is red at head 7b2aceb (Azure build 238895). The Android group-3 job fails with "does not contain any results". Its retry filter names
SamplesApp.Tests.Given_ShellLayout.When_Focus_Mode_Exit_Button_Idles_It_Hides_Until_Activity Cleanup | invalid-test-for-retry. That test does not exist in this tree, so the retry ran nothing. The same filter appears in #25047's build, which points to a stale failure list on the agent.PublishTestResultsalso reports test failures in the result files, and I could not read the names. Please rerun, or post the failing names and confirm they also fail on master. -
Screenshot diffs: build 238895 reports 118 changed on Linux and 2458 of 2486 on Windows. PR #25307 (base master, no storage change) shows the same counts, so this is most likely baseline drift. Please confirm against master before merge.
-
Static initialization:
DependencyObject.NamePropertyis now registered inDependencyObject's type initializer, not lazily. The PR body itself notes that static init order across partial files is undefined. Please confirm thatDependencyProperty.Registerdoes not read aDependencyObjectstatic field that could still be unset at that point. Also confirm that a lookup ofNamemade during that initializer cannot observe a nullNameProperty. If it could,IsNameVisibleOnwould return true. A short runtime check that resolvesNamebefore any otherDependencyObjectmember would pin this. -
Minor, test comments:
OrderObjectsays "Names are of equal length, since the SetValue path also allocates by property name length in this test host". I could not find support for that claim. Either justify it or drop it. The comment inWhen_Property_Is_Registered_Far_From_The_Others_Then_Storage_Costs_The_Sameabout "an id-aligned group" is also hard to follow. Please reword both. -
Minor, stacking and docs: the diff includes #25047's commits, so the review scope is the three commits after the base. The docs checklist item is unticked. The file list has no docs change, so the bot comment about
migrating-to-uno-7.mddoes not match this PR's diff.
Once the CI red state is explained and item 3 is answered, I would expect to approve.
Property storage no longer depends on a property's UniqueId, so DependencyObject_Name can register with DependencyObject's statics and FrameworkElement.NameProperty can forward to it. A named Border still allocates 2,000 B (master: 2,160 B). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017TzDba3gSK3uYpvLmmBmaa
Storage no longer depends on registration order, so resolving the Name DP ahead of FrameworkElement's statics is harmless again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017TzDba3gSK3uYpvLmmBmaa
7b2aceb to
ff4448c
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Claude finished @MartinZikmund's task in 17s —— View job Review of #25214 (head after "Drop the Name owner check")Verdict: ship. Blocking 0, major 0, minor 2. Scope. This is a code review by inspection only. I did not build or run anything. I read the three files in this PR's own diff against the base: What I checked
On the static-init question (earlier reviewer's item 3). I found no Minor findings
Process
|
|
Claude finished @MartinZikmund's task in 15s —— View job Review of #25214 (latest head: the "Drop the Name holder" refactor)Verdict: ship, with one open question. I found 0 blocking and 0 major issues, and 1 minor point (below). Code review (inspection only). I read the three files changed by this PR's own commits:
Open question (this is the static-init point from the earlier review). I could not confirm by inspection that Minor. The earlier test-comment nits still stand: the Not verified. I did not build or run anything. The allocation, cycle and test-count figures in the description are the author's. Process.
|
GitHub Issue: part of #21129
Note
Stacked on #25308 (base branch
dev/mazi/flyout-owner-name-automationid, GitHub stack #24389). The diff shows only this PR's commits.Stack, bottom to top (#23935 has merged, so #25307 now targets
master):NamePropertyDependencyObject.Namewithout the holderRestacked on
masterc00f09910a9. #25047's four storage commits, which this PR used to carry verbatim, are inmasternow and dropped out. The registration-order tests moved to their own PR againstmaster, #26284.PR Type:
🔄 Refactoring (no functional changes, no api changes)
What changed? 🚀
#25184 declares
NameonDependencyObjectlike WinUI. With the old bucketed DP storage, registering it plainly cost +128 B perx:Name, becauseNamelanded in a 16-slot bucket FrameworkElements otherwise never touch. So #25184 added aNamePropertyHolderto delay the registration untilFrameworkElement's static initializer ran. That is fragile: anything that touches the property before FE's cctor (a named brush inApp.xaml, say) silently brings the cost back, and static-init order across partial files isn't defined.#25047 (now in
master) made DP storage cost depend only on how many properties an object holds, not on registration order. #26284 adds the tests that pin that down. With that in place, the holder has no job left:refactor: Register DO Name without the holder:DependencyObject.NamePropertyis a plain{ get; } = DependencyProperty.Register(...), andFrameworkElement.NamePropertyforwards to it.refactor: Drop the Name owner check in DP lookups: undoes the guard fix: Declare Name on DependencyObject like WinUI #25184 added inperf: Skip the Name holder in other DP lookups, which only kept other lookups from registeringNameahead of FrameworkElement's statics.No behavior change. Storage coverage for
Nameismaster'sWhen_Border_Is_Created_Then_Storage_Fits_Its_Properties(setsName) plus #26284's registration-order test. A dedicated "Name costs like any other property" test didn't discriminate (it passed on the old bucket storage too), so I didn't add one.Measured: the holder is no longer needed
Arms, each a Release build of
Uno.UI+ headless Skia host,net10.0, same harness source:masterc00f09910a9(Name onFrameworkElement)73115a62d63(Name onDependencyObject, with the holder)ff4448c76af(Name onDependencyObject, no holder)Allocation: bytes allocated on the UI thread (
GC.GetAllocatedBytesForCurrentThread()), after a warm-up of the same action. 3 alternating launches per arm, every row identical across launches (spread ≤ 0.5 B); a null arm (byte-identical copy of B in another directory) matched B exactly.new Border()new Border { Name }new SolidColorBrush()SolidColorBrush+NameResourceDictionaryin codeResourceDictionaryviaXamlReaderx:Name¹ On
master, settingFrameworkElement.NamePropertyon a brush throws (NullReferenceExceptionin the name backing-field callback); #25184 fixes that.C and D are byte-identical on every workload, so dropping the holder costs nothing. The B → D differences come from #25184 itself, not this PR: +696 B per templated Button (+0.46%) and +2,846 B per 300-brush XAML load (+0.2%), against −78,075 B (−4.6%) for the
x:Named dictionary.CPU: thread cycles per op (
QueryThreadCycleTime) on the UI thread, median of 7 in-process reps after a warm-up, 9 alternating launches per arm (DOTNET_TieredCompilation=0). Sweeps callGetValueover every public DP on the type's hierarchy plus 12 common attached ones (94 / 123 / 114 DPs). Cells: median of the 9 launches [min–max].NameSetValue(Tag)Two byte-identical builds (B vs its null copy) differ by up to 22% on a median, and every cross-arm range overlaps, so none of these CPU deltas is a claim. C vs D, the comparison this PR is about, is within 3 cycles everywhere.
Validation
Uno.UI+Uno.UI.UnitTestsat this PR's tip (net10.0,UnoFastDevBuild); Release builds ofUno.UI+ headless runtime at this tip and at fix: Declare Name on DependencyObject like WinUI #25184's restacked tip.Uno.UI.UnitTestsat this tip: 4,521 run, 4,486 passed, 23 skipped, 12 failed, all 12 the known timezone-dependentWhen_Gregorian_FixedDate*tests.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code