Skip to content

fix(binding): Always apply animation and setter values - #24601

Merged
MartinZikmund merged 4 commits into
masterfrom
dev/mazi/flaky-wasm-combobox
Sep 24, 2026
Merged

MartinZikmund merged 4 commits into
masterfrom
dev/mazi/flaky-wasm-combobox

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24600

PR Type:

🐞 Bugfix

What changed? 🚀

BindingPath.Value skipped the write when the new value equalled the property's current effective value. For VisualState setters and animations (the _forAnimations binding path), that's wrong in two ways:

  1. An equal value from a lower precedence. A setter whose value is the same object as an inherited value was never stored at animation precedence, so a later inherited change won over it. Example: an editable ComboBox in a Dark app goes Focused → Normal → Focused. On re-entry, the Focused Foreground setter's brush equals the inherited Dark brush, so it isn't stored, and the state's RequestedTheme=Light then freezes the Light default text brush (dark text on a dark background).
  2. A local value newer than the animation. The next animated value must win again, which is what WinUI's "local value is newer" flag does.

WinUI stores setter and animation values unconditionally: VisualStateSetterHelper → SetAnimatedValue, which always stores the value and clears that flag. Animation-mode writes now never skip. Property-changed callbacks are still gated on the effective value actually changing, so equal writes stay silent.

Why it showed up as a flaky test: on WebAssembly with accessibility enabled, focusing a TextBox bounces focus (Focused → Normal → Focused within one call), which hits case 1 on every focus. Given_ElementTheme.When_Editable_ComboBox_Focused_In_Dark_Theme_Text_Is_Light and …Without_Theme_Walk_Text_Is_Light failed in WASM shard 1 in 12 of the last 30 master builds, because earlier Given_Accessible* tests leave accessibility on for the rest of the shard. The CI retry passes because it starts a fresh app. The bug itself isn't WASM-specific: focus, focus elsewhere, focus again reproduces it on any Skia head.

A first version compared against the value already stored at animation precedence instead. Review showed that breaks case 2 (a Storyboard re-begun after a local value was set kept showing the local value), so that approach was dropped and the new Given_Storyboard test guards against it.

Validation

Runtime, all tests below:

scenario head result
New tests on master's binding code Skia Desktop When_Editable_ComboBox_Refocused_In_Dark_Theme_Text_Is_Light fails, When_Setter_Value_Equals_Inherited_Value_Setter_Still_Wins fails, When_Begin_Again_After_Local_Value_Animated_Value_Wins passes (regression guard)
First (dropped) approach Skia Desktop the Storyboard test fails
This fix: all Given_VisualStateManager suites, the animation suites (Given_Storyboard, Given_DoubleAnimation, Given_DoubleAnimationUsingKeyFrames, Given_ObjectAnimationUsingKeyFrames, Given_ColorAnimationUsingKeyFrames, Given_TemplateBindingAfterAnimation, Given_ThemeAnimation) and the editable-ComboBox tests Skia Desktop 52/52 pass
Accessibility-enabling test followed by the ComboBox pair, plus the new tests WASM 7/7 pass (the pair failed before)

The setter and Storyboard tests have no PlatformCondition, so they also run against native WinUI.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 42s —— View job


Review complete ✅

  • Gather context (PR diff, files changed)
  • Review BindingPath.cs / BindingPath.BindingItem.cs changes
  • Review new runtime tests
  • Post inline findings
  • Post summary

Verdict: ship (fix is sound, well-tested; only minor non-blocking notes below)

The fix is narrow and well-targeted: it makes BindingPath.Value's write always occur for _forAnimations binding items (Setters and animations), matching WinUI's unconditional SetAnimatedValue behavior, while leaving the equality-skip optimization intact for ordinary (non-animation) bindings. I traced the precedence flow (Setter.cs → forAnimations: true, Timeline.cs/Timeline.animation.cs → PropertyInfo.Value = on every frame) and the fix correctly covers both failure modes described in the PR body — an equal value from a lower precedence never getting stored, and a local value set after an animation needing to be re-overridden on restart.

Test coverage is solid: the new Given_Storyboard, Given_VisualStateManager, and Given_ElementTheme tests each have a clear fail-before/pass-after story, the Storyboard regression test specifically guards against the dropped "compare against animation-precedence value" approach, and the setter/storyboard tests correctly carry no PlatformCondition so they also validate against native WinUI.

Findings posted inline (2, both non-blocking):

  1. Performance note on BindingPath.cs — the unconditional write for _forAnimations items now reaches the property system on every animation frame (not just when the value actually changes), which could matter for long-running discrete/held key-frame animations. Likely an accepted, deliberate tradeoff (mirrors WinUI), but worth a one-line acknowledgment.
  2. Traceability nit on Given_ElementTheme.cs — the new refocus test could carry [GitHubWorkItem(...)] for issue VisualState setter equal to the inherited value is not stored, so later inherited changes win #24600, consistent with its sibling tests in the same file.

No correctness, security, or cross-platform concerns found. No breaking changes, no new warnings anticipated from the diff.

Comment thread src/Uno.UI/DataBinding/BindingPath.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 7s —— View job


Review complete ✅

  • Gather context (PR diff, changed files)
  • Review BindingPath.cs / BindingPath.BindingItem.cs changes
  • Review new runtime tests (Given_ElementTheme, Given_VisualStateManager, Given_Storyboard)
  • Post inline findings
  • Post summary

Verdict: ship (non-blocking nits only)

This review covers the full PR, including the newest commit (4ae7a66e, wrapping the Given_Storyboard restart test in try/finally so it stops the filling storyboard instead of leaking it into later tests in the shard — a real fix for the kind of cross-test state bleed the PR itself is about).

The core fix in BindingPath.cs/BindingPath.BindingItem.cs is unchanged since the previous review pass on this PR: the unconditional write for _forAnimations binding items (Setters/animations) correctly mirrors WinUI's SetAnimatedValue, is narrowly scoped (ordinary bindings keep the equality-skip optimization), and is backed by fail-before/pass-after runtime tests including a regression guard for the dropped first approach.

New findings (2, both non-blocking, same category as a nit already flagged in the prior pass on this PR):

Carried over from the earlier review pass (still open, not re-posted to avoid duplicate threads): the perf note on BindingPath.cs:215 about unconditional per-frame writes for held/discrete animation values, and the same [GitHubWorkItem] nit on the Given_ElementTheme.cs refocus test.

No correctness, security, async/cancellation, or cross-platform concerns found. No breaking changes, no new warnings anticipated.
· branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235264 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ClipboardTests.png-dark
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
  • skia-windows-screenshots: 2310 changed over 2442

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSpanningRectsPage.png-dark
    • AppWindowTitleBar Properties.png-dark
    • Attributed_text_Simple.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutoSuggestBox_Icons.png-dark
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Generic.png
    • BorderCenteredwithmargins.png-dark
    • BorderCenteredwithmargins.png
    • BorderVersusPanelClipping.png-dark
    • BorderVersusPanelClipping.png
    • Border_BorderThickness.png-dark
    • Border_BorderThickness.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

MartinZikmund and others added 4 commits September 24, 2026 10:11
A VisualState setter (or storyboard target) sets through BindingPath.Value,
which skipped the write whenever the new value was reference-equal to the
property's effective value. When that effective value came from a lower
precedence, e.g. inheritance, the Animations slot stayed empty. The
setter then silently lost to later inherited changes and did not count as
"set" for anything that checks precedence.

For the editable ComboBox (and NumberBox) Focused state in a dark theme,
this happened on re-entering Focused. Leaving the state unfreezes
ContentElement back to the shared Dark text brush, which is the same
instance TextControlForegroundFocused resolves to. The Foreground setter
was skipped, so the following RequestedTheme=Light setter saw a default
Foreground and froze the Light default text brush (#E4000000) over the
text display block. On WASM, the a11y focus sync blurs and refocuses the
TextBox on every Focus() call once accessibility is enabled. That made the
#24021 regression tests fail whenever a Given_Accessible* test ran earlier
in the same shard.

Animation items now always write, like WinUI, where VisualStateSetterHelper
calls SetAnimatedValue unconditionally and CModifiedValue::SetAnimatedValue
clears the local-newer flag. Property-changed callbacks are still gated on
the effective value changing, so equal writes stay silent.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm
- A VisualState setter whose value is the very brush the target inherits
  must keep winning after the inherited value changes.
- An editable ComboBox focused, blurred and refocused in a dark theme
  keeps light text. This is the round trip the WASM a11y focus sync forces
  on every Focus() call.
- A storyboard restarted after a newer local value must retake
  precedence, even though its animated slot already holds the same value.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/flaky-wasm-combobox branch from 4ae7a66 to 4d7d323 Compare September 24, 2026 08:14
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 35s —— View job


Review complete ✅

  • Gather context (PR diff, changed files)
  • Review BindingPath.cs / BindingPath.BindingItem.cs changes against AGENTS.md rules
  • Review new runtime tests (Given_ElementTheme, Given_VisualStateManager, Given_Storyboard)
  • Post inline findings (none new — see below)
  • Post summary

Verdict: ship

This pass reviewed the full PR as of the latest commit (4d7d3230, which tags the three new regression tests with [GitHubWorkItem("...issues/24600")]). That commit resolves all three traceability nits raised in the two prior automated review passes on this PR — confirmed by diff: Given_ElementTheme.cs, Given_VisualStateManager.cs, and Given_Storyboard.cs each now carry the tag on their new test method, consistent with sibling issue-guarding tests in the same files.

Re-verified the core fix independently this pass:

  • BindingPath.cs:215 — the _value.IsForAnimations short-circuit is correctly scoped to the _forAnimations binding chain only; ordinary (non-animation) bindings keep the AreDifferent equality-skip. IsForAnimations (BindingPath.BindingItem.cs:77) is exposed as internal on the private nested BindingItem class — consistent with the existing convention for other internals on that type (IsDependencyProperty, GetSubstituteValue), and _value's static type is BindingItem directly so no IBindingItem interface change was needed.
  • Test coverage holds up: Given_Storyboard.When_Begin_Again_After_Local_Value_Animated_Value_Wins wraps storyboard.Begin()/re-Begin() in try/finally { storyboard.Stop(); } so a filling animation can't leak into later tests in the shard — this was the fix from commit 0693d0f8, and it's the right pattern per .claude/rules/runtime-tests.md. Given_VisualStateManager.When_Setter_Value_Equals_Inherited_Value_Setter_Still_Wins and the Given_ElementTheme refocus test both have clear repro comments explaining the non-obvious why (brush identity vs. inherited value, focus-bounce re-entry) and correctly use using var _ = ThemeHelper.UseApplicationDarkTheme(); for cleanup.
  • No SOLID/async/cross-platform/DP issues found in the diff. Commit messages and PR title follow Conventional Commits.

No new inline findings. The one item still open from the prior passes — the non-blocking perf note on BindingPath.cs:215 about unconditional per-frame writes for long-held discrete/ObjectAnimationUsingKeyFrames animations — remains valid but isn't re-posted here to avoid a third duplicate thread; it's a deliberate tradeoff mirroring WinUI's SetAnimatedValue and doesn't block merge.
· branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235424 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
  • skia-windows-screenshots: 2310 changed over 2498

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • Accessibility_ScreenReader.png-dark
    • AppWindowFeatures.png-dark
    • AnimatedIconPage.png
    • AppBarButtonTest.png-dark
    • AppWindowTitleBar Properties.png-dark
    • AppBarToggleButtonTest.png
    • ApplicationViewMode.png
    • AppXamlDefinedResources.png
    • ApplicationViewSizing.png
    • AppWindowFeatures.png
    • Attributed_text_Simple.png
    • AppWindowPositionAndSize.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AppXamlDefinedResources.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutomationProperties_AutomationId.png
    • Attributed_text_Simple.png-dark
    • AutomationProperties_AutomationId.png-dark
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@MartinZikmund
MartinZikmund merged commit 456ad73 into master Sep 24, 2026
55 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/flaky-wasm-combobox branch September 24, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VisualState setter equal to the inherited value is not stored, so later inherited changes win

4 participants