dotnet / dotnet/wpf

CPU Perfomance issue occurs when setting the visual states.

Open
#5,891 1 comment 2 reactions 0 assignees View on GitHub
Bug Performance
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* 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.

```










```
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](https://user-images.githubusercontent.com/88649640/147747476-2b9f2926-a3a0-4d8f-bc84-1ddd29bb3cf1.png)

**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](https://github.com/dotnet/wpf/files/7792658/WpfApp1.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.