Skip to content

fix(progressring): Repaint when the assigned brush changes colour - #24613

Merged
DerekRaven merged 3 commits into
masterfrom
dev/dr/24555-progressring-brush-colour
Sep 24, 2026
Merged

DerekRaven merged 3 commits into
masterfrom
dev/dr/24555-progressring-brush-colour

Conversation

@DerekRaven

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24555

PR Type:

🐞 Bugfix

What changed? 🚀

Current behavior. A ProgressRing handed its colours to its animated visual only when the Foreground or Background dependency property itself changed. If the property kept pointing at the same brush and that brush's Color changed, the ring went on painting the old colour indefinitely. This shows up in themed apps, where a brush resource is re-evaluated by mutating it in place rather than being replaced: every other control repaints, the ring does not. The only ways out were to force the property to change — toggle IsIndeterminate and back, or set Foreground to null and back to the same brush.

New behavior. The ring repaints in the brush's new colour, like every other control drawn with the same brush.

WinUI already does this — ProgressRing.cpp registers a change callback on the assigned brush next to the property callback. The Uno port only ever had the property callback, since well before the recent Composition rework.

Reviewer's guide

Start at ProgressRing.cs:141-155 — that is the whole fix. The two property-changed handlers went from a one-line push to dispose-then-resubscribe:

private void OnForegroundPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
    _foregroundBrushSubscription?.Dispose();
    _foregroundBrushSubscription = Brush.SetupBrushChanged(Foreground, ref _foregroundBrushChanged, SetLottieForegroundColor);
}

Everything else in the diff is the four backing fields these need.

Nothing changed in the generated visuals or in AnimatedVisualPlayer, deliberately. The push path already worked: SetColorProperty writes into _themeProperties, the ring's brushes are ExpressionAnimation-bound to that property set, and CompositionPropertySet.SetValue short-circuits an unchanged value. Only the trigger was missing. The issue's own measurement shows this — setting Foreground to null and back repainted correctly.

Two choices worth a look:

  • Brush.SetupBrushChanged rather than a literal MUX transliteration. It is the mechanism Shape, Border, TextBlock and TextBoxCore already use, it is weak-event based, and it covers every brush kind TryGetColorWithOpacity reads — SolidColorBrush.Color and Brush.Opacity, GradientBrush.FallbackColor, XamlCompositionBrushBase.FallbackColor. MUX watches SolidColorBrush.Color alone, so this is a deliberate superset.
  • Dispose before resubscribe, following AnimatedIcon.cs:702-714 rather than ProgressRing.cpp:74-82. MUX assigns the revoker only inside its if, so moving to a brush that is not a SolidColorBrush leaves the old brush still driving the ring.

The test that proves it is Given_ProgressRing.When_Foreground_Brush_Colour_Mutated: it rasterizes a determinate ring, mutates the assigned brush's Color, and asserts the new colour appears and no pixel of the old one survives. When_Background_Brush_Colour_Mutated does the same for the track ring. Both fail on master on the repaint assertion, having passed their baseline assertion first.

Validation evidence

Compile — SamplesApp.csproj -c Release -f net10.0-desktop: 0 warnings, 0 errors.

Runtime, red phase (tests only, fix not applied) — both new tests failed on CountPixels(SUT, IsLime) > 0, after passing their baseline assertion.

Runtime, green phase — all 5 tests in Given_ProgressRing passed, including the 3 pre-existing ones.

Runtime, regression sweep — Given_ProgressRing_Visuals, Given_AnimatedVisualPlayer, Given_AnimatedAcceptVisualSource, MUX ProgressRingTests, legacy Windows_UI_Xaml_Controls.Given_ProgressRing: 37 passed, 1 skipped (ProgressRingDefaultHeightShouldBe32, gated out by its own pre-existing #if !(__WASM__ || HAS_SKOTTIE)).

All runs on Skia desktop (net10.0-desktop).

Known limitations

  • Verified on Skia desktop only. The new tests carry #if !__SKIA__ [Ignore], matching the sibling When_Stretch_Fill and the #if __SKIA__ wrapper on Given_ProgressRing_Visuals. The issue was not checked on other targets either.
  • Not addressed here: Uno pushes the colour into a caller-supplied DeterminateSource/IndeterminateSource, where WinUI deliberately does not (ProgressRing.cpp:92-102). That divergence predates this PR, but it now fires on every brush mutation rather than only on property changes. Correcting it is a behaviour change and wants its own issue rather than riding along in a bug fix.

PR Checklist ✅

DerekRaven and others added 2 commits September 22, 2026 09:21
A ProgressRing pushes its colours into the animated visual only when the
Foreground/Background dependency property itself changes. A brush mutated
in place - the shape a re-evaluated theme resource takes - never reaches
the ring, so it keeps painting the old colour.

Rasterize a determinate ring, mutate the assigned brush's Color, and
assert the ring repaints: the new colour appears and no pixel of the old
one survives. Both tests fail today.

Part of #24555

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
OnForegroundPropertyChanged/OnBackgroundPropertyChanged fired only when
the dependency property itself changed, so a brush mutated in place never
reached the animated visual and the ring kept its old colour. MUX's
ProgressRing.cpp registers a change callback on the assigned brush for
exactly this; the Uno port dropped it.

Subscribe through Brush.SetupBrushChanged, as Shape, Border and TextBlock
do. It also covers Opacity and gradient/acrylic fallback colours, which
TryGetColorWithOpacity already reads but MUX's SolidColorBrush.Color-only
callback would miss. The previous subscription is disposed before the new
one is made, so a replaced brush stops driving the ring.

fixes #24555

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@DerekRaven
DerekRaven marked this pull request as ready for review September 23, 2026 17:08
@unodevops

Copy link
Copy Markdown
Contributor

Both counts now come from one screenshot, so the two assertions in a phase
describe the same frame instead of three separately rasterized ones, and
the tally is carried in named locals a breakpoint can read and in every
assertion message.

Addresses review feedback on #24613.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235325 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) 🚨🚨
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Examples.png-dark
    • Examples.png
  • skia-windows-screenshots: 2310 changed over 2442

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBar_KeyBoard.png-dark
    • AppWindowClosing.png
    • ArcSegment.png
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutoSuggestBox_Description.png
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Monochromatic.png-dark
    • BitmapIcon_Monochromatic.png
    • BorderCenteredwithmargins.png-dark
    • BorderCenteredwithmargins.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.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.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • 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
    • 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

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235351 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) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Examples.png-dark
  • skia-windows-screenshots: 2310 changed over 2442

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonTest.png-dark
    • AppBarButtonWithIconTest.png-dark
    • ApplicationViewMode.png-dark
    • AppWindowFeatures.png-dark
    • AppWindowTitleBar Properties.png-dark
    • Arrange_Performance01.png-dark
    • Attributed_text_Simple.png-dark
    • AutoBorderStretchwithbottommargin.png-dark
    • AutoBorderStretchwithtopmargin.png
    • AutomationPropertiesExtensions_Role.png-dark
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_Keyboard.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • 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.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@mergify

mergify Bot commented Sep 23, 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.

@DerekRaven

Copy link
Copy Markdown
Contributor Author

Before

Recording.2026-09-24.122236.mp4

After

Recording.2026-09-24.122149.mp4

@DerekRaven
DerekRaven merged commit a34a3e4 into master Sep 24, 2026
56 checks passed
@DerekRaven
DerekRaven deleted the dev/dr/24555-progressring-brush-colour branch September 24, 2026 16:25
@DerekRaven

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport servicing/6.8

@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

backport servicing/6.8

✅ Backports have been created

Details

DerekRaven added a commit that referenced this pull request Sep 24, 2026
…r-24613

fix(progressring): Repaint when the assigned brush changes colour (backport #24613)
@DerekRaven

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Oct 27, 2026
…6.7/pr-24613

fix(progressring): Repaint when the assigned brush changes colour (backport #24613)
ramezgerges pushed a commit to ramezgerges/uno that referenced this pull request Nov 2, 2026
Both counts now come from one screenshot, so the two assertions in a phase
describe the same frame instead of three separately rasterized ones, and
the tally is carried in named locals a breakpoint can read and in every
assertion message.

Addresses review feedback on unoplatform#24613.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 1168878)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProgressRing keeps its old colour when the brush assigned to Foreground changes colour

4 participants