Repository navigation
Description
Severity: High - anyone who hides a busy indicator by collapsing an indeterminate ProgressBar keeps paying ~120 fps of rendering and 8-18 % CPU for as long as the page lives, for nothing visible on screen (battery drain, wasted GPU).
Current behavior 🐛
An indeterminate ProgressBar that is Visibility.Collapsed stays in the Indeterminate visual state, so its forever storyboard keeps ticking. The window re-renders at display rate while nothing on screen changes.
Measured at runtime (Skia desktop, Windows, Release build of master 4636b705e97, frames counted from the frame-rate counter's frame generation over a 5 s idle window):
progressbar-indeterminate: frames/s=120.0 cpu%=14.6
progressbar-indeterminate-turned-off: frames/s=0.0 cpu%=0.3 (IsIndeterminate=false)
progressbar-indeterminate-collapsed: frames/s=118.0 cpu%=17.8 (IsIndeterminate=true, Visibility=Collapsed)
An earlier run gave 118.2 fps / 14.7 % CPU for the collapsed case, vs 0 fps when IsIndeterminate is cleared. The code path is shared Uno.UI code (not renderer specific), so other heads are likely affected too, but only Skia desktop was run.
Expected behavior 🎯
Same as WinUI: a collapsed ProgressBar leaves the Indeterminate* states and goes to the Determinate* states, so the animation stops. WinUI's ProgressBar registers a VisibilityProperty changed callback in its constructor, and UpdateStates() only picks the indeterminate states when IsIndeterminate() && Visibility() == Visible:
ProgressBar.cppctor, line 25:RegisterPropertyChangedCallback(winrt::UIElement::VisibilityProperty(), { this, &ProgressBar::OnVisibilityPropertyChanged });OnVisibilityPropertyChangedjust callsUpdateStates()(line 76-79)UpdateStates():if (IsIndeterminate() && Visibility() == winrt::Visibility::Visible)(line 89)
This is backed by the WinUI C++ sources (read, not run against native WinUI).
How to reproduce it 🔬
- Create an app with this page content (any Uno app on Skia desktop):
var pb = new ProgressBar { IsIndeterminate = true, Width = 300, VerticalAlignment = VerticalAlignment.Top };
var root = new Grid();
root.Children.Add(pb);
Window.Content = root;
// after the bar is shown:
pb.Visibility = Visibility.Collapsed;- Wait a couple of seconds and leave the window idle.
- Watch the frame-rate counter (
Application.Current.DebugSettings.EnableFrameRateCounter = true) or the process CPU in Task Manager.
Result: frames keep flowing at display rate (~120 fps on the test machine) and the process uses a steady ~15 % CPU. Setting IsIndeterminate = false instead drops to 0 fps.
The visual state is also wrong: the collapsed bar stays in Indeterminate, where WinUI moves it to Determinate.
Workaround 🛠️
Clear IsIndeterminate when hiding the bar, or bind IsIndeterminate to the same flag as Visibility.
Works on UWP/WinUI
Yes, per the WinUI sources above (the animation stops when the bar is collapsed).
Renderer 🎨
Skia
Affected platforms 📱💻🖥️
Verified on Desktop (Windows, Skia). The logic is shared, so likely all platforms.
Uno.Sdk version (and other relevant versions) 📦
Uno master 4636b705e97 (net11.0-desktop, .NET SDK 11.0.100). ProgressBar.cs is unchanged on current master (46ea872727d).
Anything else we need to know? 💬
Root cause (source-backed): src/Uno.UI/UI/Xaml/Controls/ProgressBar/ProgressBar.cs registers property-changed callbacks for Value, Minimum, Maximum and Padding in the constructor (L31-L34) but none for Visibility, and UpdateStates() (L95) checks only IsIndeterminate.
Suggested fix (small, localized): port OnVisibilityPropertyChanged (register a VisibilityProperty callback calling UpdateStates()), and change the condition to IsIndeterminate && Visibility == Visibility.Visible.
Related but a different bug: #26166 (VisualStateGroup.CurrentState timing), which was probed using a collapsed ProgressBar.
Activity
test(progressbar): Stop animation when collapsed