Skip to content

CPU Perfomance issue occurs when setting the visual states. #5891

@sampath-narayanan

Description

@sampath-narayanan
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

Problem description:

While setting the visual states for the content control, the performance issue occurs even though the application is idle. Please refer the below image. I have created the following visualstategroup and have used the animation to increase the border thickness. Please find the code snippet below.

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="BorderStates">
        <VisualState x:Name="Normal" />
        <VisualState x:Name="Bold">
            <Storyboard BeginTime="0">
                <ThicknessAnimationUsingKeyFrames BeginTime="0"
                                                              Duration="1"
                                                              Storyboard.TargetName="Border1"
                                                              Storyboard.TargetProperty="BorderThickness">
                    <EasingThicknessKeyFrame KeyTime="0" Value="5" />
                </ThicknessAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

And have set the visualstates in the code behind as follows.

VisualStateManager.GoToState(this, "Bold", true);

While running the application, I have found that the continuous memory allocation occurs even when the application is idle. Please find the image below.

image

Actual behavior:

Cpu performance issue occurs and memory allocation of 1% or 2% occurs even when the application is idle

Expected behavior:

This performance issue should not occurs and memory allocation while application is idle is not acceptable.

Minimal repro:
Please find the attached sample.
Run sample using the performance profiler (Enable the Cpu usage).

WpfApp1.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)PerformancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions