Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Indeterminate Progress Bar animation with CacheMode set up #10649

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Mar 25, 2025

Fixes #8960

Description

Adjusts the logic behind transitioning to Determinate state to avoid background animation to exclude a case when a CacheMode is set up on the ProgressBar and the ProgressBar is not a part of the visual tree (IsVisible evaluates to false).

It is worth nothing that the pre-NET 7.0 behaviour would work even without explicit CacheMode set-up. This basically provides a middle ground for the solution used commonly in applications, where explicitly setting up CacheMode solves the immediate issue but if you had only used the resource as a target of BitmapCacheBrush, it will not work (which seems alright though).

Imho that is an acceptable behavioral change from pre-NET7.0 behaviour and should be documented accordingly.

Customer Impact

If this change is not taken, customers will not be able to cache their indeterminate progress bars as they used to be.

Regression

Yeah, broken in #6266.

Testing

Local build, repro in #8960 and #6264.

Risk

Medium, we should have more test cases covering these kinda changes.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners March 25, 2025 23:34
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Mar 25, 2025
@h3xds1nz h3xds1nz changed the title Fix Indeterminate Progress Bar animation with Cache Mode set up Fix Indeterminate Progress Bar animation with CacheMode set up Mar 25, 2025
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 11.25824%. Comparing base (6514196) to head (149ca7e).
Report is 11 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10649         +/-   ##
===================================================
+ Coverage   11.22814%   11.25824%   +0.03010%     
===================================================
  Files           3352        3353          +1     
  Lines         668000      668062         +62     
  Branches       74980       74980                 
===================================================
+ Hits           75004       75212        +208     
+ Misses        591745      591604        -141     
+ Partials        1251        1246          -5     
Flag Coverage Δ
Debug 11.25824% <0.00000%> (+0.03010%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ThomasGoulet73 ThomasGoulet73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, that was definitely an oversight by me.

// However, we can only allow ourselves to do that if the ProgressBar is not being cached, since when the UIElement is defined within
// resources, IsVisible property will always evaluate to false as the UIElement is not a part of the visual tree at that point. (#8960)

if (!IsIndeterminate || (!IsVisible && CacheMode is null))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to check if the ProgressBar is part of the visual tree instead of checking CacheMode ?

Something like this:

Suggested change
if (!IsIndeterminate || (!IsVisible && CacheMode is null))
if (!IsIndeterminate || (!IsVisible && VisualTreeHelper.GetParent(this) is not null))

I haven't tested it but to me it's more precise because the bug does not seem specific to `CacheMode`.

Copy link
Member Author

@h3xds1nz h3xds1nz Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasGoulet73 Maybe I scoped too narrowly, I'll check this but imho should work indeed.

@h3xds1nz h3xds1nz added regression status: This issue is a regression from a previous build or release and removed regression status: This issue is a regression from a previous build or release labels Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indeterminate progress bar used as BitmapCacheBrush target do not animate
2 participants