Skip to content

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

Merged
agneszitte merged 3 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24613
Oct 27, 2026
Merged

agneszitte merged 3 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24613

Conversation

@mergify

@mergify mergify Bot commented Sep 25, 2026

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 ✅


This is an automatic backport of pull request #24613 done by [Mergify](https://mergify.com).

DerekRaven and others added 3 commits September 25, 2026 13:38
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]>
(cherry picked from commit 9e90643)
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]>
(cherry picked from commit 5a91237)
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]>
(cherry picked from commit 1168878)
@agneszitte agneszitte added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 25, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@agneszitte agneszitte removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2026
@agneszitte
agneszitte merged commit 9154d00 into release/stable/6.7 Oct 27, 2026
47 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-24613 branch October 27, 2026 23:59
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.

4 participants