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

Progressbar: Fix issue with color changing when updating value while error state #3201

Conversation

marcelwgn
Copy link
Contributor

@marcelwgn marcelwgn commented Aug 26, 2020

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):

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 26, 2020
@marcelwgn marcelwgn changed the title Fix issue with color changing when updating value while error state Progressbar: Fix issue with color changing when updating value while error state Aug 26, 2020
<ColorAnimation
Storyboard.TargetName="DeterminateProgressBarIndicator"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
To="{Binding Source={ThemeResource SystemControlErrorTextForegroundBrush},Converter={StaticResource SolidColorBrushToColor}}"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@Felix-Dev Felix-Dev Aug 26, 2020

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@Felix-Dev Felix-Dev Aug 26, 2020

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

@YuliKl YuliKl added area-Progress ProgressBar, ProgressRing team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Aug 26, 2020
Storyboard.TargetName="ProgressBarRoot"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="{StaticResource SystemControlErrorBackgroundColor}"
Duration="0:0:0.0"/>
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -65,6 +70,22 @@
<VisualState x:Name="Normal" />
<VisualState x:Name="Determinate" />
<VisualState x:Name="Updating" />
<VisualState x:Name="UpdatingError">
<Storyboard>
<Storyboard>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have two storyboards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed now

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

@chingucoding The pipeline fix just went in, could you please merge master into this PR?

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

@kmahone do you know what is going on with the test failures for this PR? (we had the same error twice in a row)

@StephenLPeters
Copy link
Contributor

@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?

@marcelwgn
Copy link
Contributor Author

Just ran the tests again on my machine, and all of them run fine:

image

@StephenLPeters
Copy link
Contributor

Can you try putting the tests in different suites? hopefully with that we can get the pipeline to give us more diagnostics.

@marcelwgn
Copy link
Contributor Author

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.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

StephenLPeters commented Sep 10, 2020

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

@ranjeshj
Copy link
Contributor

Yeah, I'm also surprised... I'm hoping someone else from the team might have incite as to whats going on, looking through the code I still have no idea.

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 ?

@evelynwu-msft
Copy link
Contributor

evelynwu-msft commented Sep 15, 2020

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 Windows.UI.Xaml!OnFailureEncountered... it might be that the real root cause lies elsewhere and it's simply manifesting as this weird VSM crash.

@stevenbrix
Copy link
Contributor

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}"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link

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.

Copy link
Contributor

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)

Copy link
Contributor

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)

@stevenbrix
Copy link
Contributor

The only other thing that comes to mind is that something about the way vsm is deferred is causing hiccups.

@chingucoding can you set <DisableXbfGeneration>true</DisableXbfGeneration> in the project file and see if the issue still reproes?

@evelynwu-msft
Copy link
Contributor

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.

@marcelwgn
Copy link
Contributor Author

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?

@stevenbrix
Copy link
Contributor

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?

@marcelwgn
Copy link
Contributor Author

marcelwgn commented Sep 16, 2020

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

@StephenLPeters
Copy link
Contributor

The crash occurs in the mux controls test app without this change.

@stevenbrix
Copy link
Contributor

stevenbrix commented Sep 16, 2020

My old comment was wrong, @StephenLPeters is totally right.

@chingucoding I'm very confused, which comment? 😄

I'd still like @YuliKl to comment on whether using SystemControlErrorTextForegroundBrush is a necessity, or if we can use SystemErrorTextColor where we just need a Color

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"/>
Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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?

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@marcelwgn
Copy link
Contributor Author

Is there anything missing in this PR or are there any changes that need to be made?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Progress ProgressBar, ProgressRing team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update color of ProgressBar's error state
8 participants