dotnet / dotnet/wpf

WPF TextBox stutters on update

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

Description

* .NET Core Version: 6.0.100
* Windows version: 19044.1387
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No

**Problem description:**
The attached example WPF application has a number of System.Windows.Controls.TextBox instances that are updated each 100ms when the "Go" button is pressed.

![image](https://user-images.githubusercontent.com/9577365/147667407-21393eac-feca-4b21-8bdf-7f6a1f85643c.png)

The Go button starts an update of the value Data bound to all TextBox:es according to:

![image](https://user-images.githubusercontent.com/9577365/147667461-540679b4-6532-40e1-be2e-a08ef42e31df.png)

The UI freezes quite quickly although I have ample of system resources:

Processor Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz 2.90 GHz
Installed RAM 64,0 GB (63,8 GB usable)
System type 64-bit operating system, x64-based processor

During net framework era we have employed a trick that adds memory pressure and garbage collects "all the time" so that a bug garbage collect that seems to cause the freeze does not need to happen. **This however is not a good long term solution**:
(The "solution" was initially described in http://connect.microsoft.com/VisualStudio/feedback/details/376495/wpf-sporadically-slow-textbox-text-anystring that is no longer available. )

![image](https://user-images.githubusercontent.com/9577365/147667685-40e5e5df-a430-4126-ac8d-bec7c4ea79f3.png)

This can be tested by checking the checkbox "UseUglyMitigation" in the first image.

Repro by running the attached application.

[WpfTextBoxPerfIssue.zip](https://github.com/dotnet/wpf/files/7789096/WpfTextBoxPerfIssue.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.