-
Notifications
You must be signed in to change notification settings - Fork 706
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
Progressbar: Fix issue with color changing when updating value while error state #3201
Progressbar: Fix issue with color changing when updating value while error state #3201
Conversation
dev/ProgressBar/ProgressBar.xaml
Outdated
<ColorAnimation | ||
Storyboard.TargetName="DeterminateProgressBarIndicator" | ||
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" | ||
To="{Binding Source={ThemeResource SystemControlErrorTextForegroundBrush},Converter={StaticResource SolidColorBrushToColor}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
To="{Binding Source={ThemeResource SystemControlErrorTextForegroundBrush},Path=Color}"
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does to the same degree as converters: It doesn't pick up a resource override.
I've changed it to path as we should avoid those converters if they are not necessary, thanks for pointing that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That resource update failure seems familiar....and turns out in another issue, we already started speculating if the resource lookup initiated by the Binding
function is currently broken:
See the two messages starting here.
Somehow this managed to slip off my mind when it came to creating a separate issue but this PR serves as a good reminder for that. I would create such an issue if you don't mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to create an issue for this. Another issue caused by this, which also slipped my mind, is #3083 which exhibits the same behavior.
I think the issue with themresource lookup inside binding is the following:
The binding is inside WinUI, so the resource probably starts there. It then goes up the chain, and since you load WinUI in your app.xaml, this is the next place where it will look for that resource. Overriding those resources in App.xaml works as expected, but overriding on pages does not work with the classical setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding those resources in App.xaml works as expected, but overriding on pages does not work with the classical setup.
In my case linked above, not even the app level was working:
It also does not matter if I override these resources on the control level, the page level or the app level. Same effect - my overriden placeholder foreground theme resources will be ignored.
I will double-check that though before creating the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, with the progressbar, it worked once for some reason but now it doesn't anymore...
Really strange how resourcelookup behaves while inside binding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the comment from the other PR about bindings in styles only being applied once explain something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that comment is also explaining why this is not working as expected. What do you think should we do with this given that we would need to manually do the binding for it to update correctly?
dev/ProgressBar/ProgressBar.xaml
Outdated
Storyboard.TargetName="ProgressBarRoot" | ||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | ||
To="{StaticResource SystemControlErrorBackgroundColor}" | ||
Duration="0:0:0.0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a setter more appropriate than a 0 duration story board?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite frankly, I wasn't able to get a setter to that property working. I've tried different variations of brackets and they always crashed.
dev/ProgressBar/ProgressBar.xaml
Outdated
@@ -65,6 +70,22 @@ | |||
<VisualState x:Name="Normal" /> | |||
<VisualState x:Name="Determinate" /> | |||
<VisualState x:Name="Updating" /> | |||
<VisualState x:Name="UpdatingError"> | |||
<Storyboard> | |||
<Storyboard> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have two storyboards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed now
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@chingucoding The pipeline fix just went in, could you please merge master into this PR? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@kmahone do you know what is going on with the test failures for this PR? (we had the same error twice in a row) |
@chingucoding I think the Progressbar tests work item is failing because it is taking too long, probably because there are too many failing tests. You have confirmed that they pass locally right? |
Can you try putting the tests in different suites? hopefully with that we can get the pipeline to give us more diagnostics. |
Done hopefully that helps tracking the issue down. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Looking through the change history, I believe SystemControlErrorTextForegroundBrush was added in RS5, the majority of the downlevel failures are the binding to that resource failing. I think we need to do something like what we do for SystemErrorTextColor here |
The only difference between those should be the resources right ? I'm curious if some resource in high contrast is incorrect causing the VSM state parsing to fail - although I would have expected it fail/throw right there instead of returning null. Could you try to see what happens if you replace the high contrast resources with the default resources and see if it still repros ? perhaps we can track this down that way. @stevenbrix @alwu-msft any ideas why we might be seeing this behavior ? |
The only thing that comes to mind (note that this is pure speculation) is that the template lives in a theme dictionary (so there's different templates for different themes) and the template contained in the high contrast theme dictionary doesn't have a VSM specification. My recommendation would be to debug through the call to retrieve the visual state groups... unfortunately the people who have the most knowledge of how VSM works have long since left the team so I don't have any better suggestions. Also, set a breakpoint on |
I was going to say something similar to Alan, although we don't generally put templates in theme dictionaries. VSM silently fails, since @chingucoding doesn't have access to our source yet, maybe you can find something in the output spew? |
@@ -135,7 +154,7 @@ | |||
<ColorAnimation | |||
Storyboard.TargetName="DeterminateProgressBarIndicator" | |||
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" | |||
To="{ThemeResource SystemErrorTextColor}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to #1766 we should use SystemControlErrorTextForegroundBrush
which is a SolidColorbrush. However ColorAnimation does not support brushes, but expects us to pass a Color object, that's why we need to use the binding now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YuliKl can you comment? This seems like it's going to create 2 extra allocations (at a minimum - one for the Binding
and one for the Brush
) when I don't think it's necessary. Seems like having a ThemeResource
to SystemErrorTextColor
would do the trick just fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this question earlier. A potential problem I foresee with using a Color resource is what happens with the control is running in High Contrast. SystemControlErrorTextForegroundBrush falls back to SystemColorWindowTextColor in HC (which can be modified by the user), but SystemErrorTextColor retains its static value of #FFF000. If we hardcode a color, I think we might get the appearance wrong in HC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at generic.xaml the high contrast version of the brush should be
In reply to: 489609371 [](ancestors = 489609371)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yes, there is a tangible difference between the brush and the color, and I think its worth keeping the binding.
In reply to: 491100783 [](ancestors = 491100783,489609371)
The only other thing that comes to mind is that something about the way vsm is deferred is causing hiccups. @chingucoding can you set |
Oops, my bad, "debug the call" isn't going to be too useful then. :D In that case, if nothing is obvious from the debug spew, then capturing a Time Travel Debugging trace and attaching it to a new issue would allow somebody from our team to step through the scenario and figure out what's going wrong. |
I filed #3289 for tracking, unfortunately TTD didn't work as expected. Hopefully the DLM file is enough to help debugging, otherwise, the repro steps are also mentioned in the issue. Given that the CI is running now, is there any work left to do in this PR? |
Is the crash we're seeing new behavior, or is this already existing? |
The crash occured before this PR but is gone now as the missing high contrast resource would be added with this PR. My old comment was wrong, @StephenLPeters is totally right. Edit: Edited my comment, sorry about the confusion haha |
The crash occurs in the mux controls test app without this change. |
@chingucoding I'm very confused, which comment? 😄 I'd still like @YuliKl to comment on whether using Edit: Ahh, I see you edited your original comment. I get it now. That's why I was so confused haha |
@@ -32,6 +35,7 @@ | |||
<Color x:Key="SystemControlErrorBackgroundColor">#29C50500</Color> | |||
<!-- Hex value for SystemErrorText at 0.16 opacity --> | |||
<contract7NotPresent:Color x:Key="SystemErrorTextColor">#C50500</contract7NotPresent:Color> | |||
<contract7NotPresent:SolidColorBrush x:Key="SystemControlErrorTextForegroundBrush" Color="#C50500"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C50500 [](start = 103, length = 6)
These brushes should have their color set to the SystemErrorTextColor, not its value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reply to: 491099136 [](ancestors = 491099136)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The high contrast version in system xaml actually points to SystemColorWindowTextColor instead of SystemErrorTextColor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When trying to reference that resource, I get the same visual state bugs we got earlier in this PR. Any ideas what could lead to that resource not being found? A few control in OS XAML reference that brush, so this shouldn't be an issue right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, its been a while, can you remind me what the issue was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chingucoding ping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I am very sorry, thought that I already replied. The issue I am encountering is that the visual states of the ProgressBar seem to be missing resulting in crashes when visiting the page. As mentioned in my comment earlier, it seems that it fails to find the themeresource "SystemColorWindowTextColor". Should we add the resource to the ProgressBar_themeresources.xaml file to mitigate this?
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Is there anything missing in this PR or are there any changes that need to be made? |
Description
Fix issue with color changing when changing the value. That was caused as we moved to a visual state that didn't set the color to our error color resulting in that switch.
Also updated the template to use the
SystemControlErrorTextForegroundBrush
. For reasons unknown to me, lightweight styling of that resource does not really work. The themeresource lookup doesn't seem to pick up if that resource is specified on that page.Another thing I noticed is that switching themes DOES NOT update the progressbar color since we set the color of a solidcolorbrush instead of referencing a themeresource. What should we do with this?
While those animations seem awesome, they are currently create a few issues that we wouldn't have with plain setters to SolidColorBrushes.
Motivation and Context
Fixes #1766
How Has This Been Tested?
Screenshots (if appropriate):