-
Notifications
You must be signed in to change notification settings - Fork 821
Description
Current behavior 🐛
When a ProgressBar with IsIndeterminate="true" is shown and hid with Visibility="Collapsed", it keeps using CPU/GPU resources.
Expected behavior 🎯
When a ProgressBar with IsIndeterminate="true" is shown and hid with Visibility="Collapsed", it does not keep using CPU/GPU resources.
How to reproduce it (as minimally and precisely as possible) 🔬
Download the repro project.
Build the project.
Disable hardware acceleration in your browser. In Edge/Chrome settings search for "Use hardware acceleration when available" option.
Close all instances of the browser.
Check in "chrome://gpu" or "edge://gpu" that is using software rendering.
Open the browser and enter the app URL in the browser.
Open your OS resource monitor (i.e. Windows Tasks Manager) and monitor the browser processes.
Click the "Show/Hide Progress Bar" button. The progress bar will show and the CPU usage will increase significantly.
Click the "Show/Hide Progress Bar" button. The progress bar will hide but the CPU usage will not decrease.
If you reduce the size of the browser to only the URL bar the CPU usage will go away and will return when restored to a normal size.
Reenable hardware acceleration in browser and repeat the process. This time, the usage will be in the GPU and it will not decrease.
In Desktop (Windows) the same increase and not decrease of CPU/GPU usage can be observed (albeit it is less problematic that in Wasm).
Here there are some videos where it can be observed:
Wasm with hardware acceleration.
ProgressBarWebAssemblyWithHardwareAcceleration.webm
Wasm without hardware acceleration.
ProgressBarWebAssemblyWithoutHardwareAcceleration.webm
Desktop with hardware acceleration.
ProgressBarDesktopWithHardwareAcceleration.webm
Workaround 🛠️
Changing IsIndeterminate to false removes the resource usage so synchronizing the change of Visibility with a change to IsIndeterminate allows to maintain functionality.
Renderer 🎨
- Skia
- Native
Affected platforms 📱💻🖥️
Desktop (Windows), WebAssembly
Uno.Sdk version (and other relevant versions) 📦
6.3.28
IDE version 🧑💻
Visual Studio 2022 17.14.19
Anything else we need to know? 💬
I think this Storyboard is the problem.
| <Storyboard RepeatBehavior="Forever"> |
It keeps executing even after the control is collapsed, but it stops when changing from Indeterminate to Determinate. My best guess is that a change in the VisualState takes care of stopping the Storyboards but a change in Visiblity does not.
Also, it is concerning how much of CPU/GPU resources is using to do that "simple" animation.