dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.88k stars 1.14k forks source link

Extremely slow clipboard operation when some clipboard monitor application running #9106

Open cuiliang opened 1 month ago

cuiliang commented 1 month ago

Description

When running software that includes clipboard monitoring features, all WPF applications on the computer may become extremely slow when performing clipboard copy operations. Meanwhile, other programs such as Winform applications, browsers, and Windows Notepad operate normally. Symptoms: When selecting "Copy" (or "Cut") from the right-click menu in any text box, it takes 0.5 to 1 second for the menu to close.

https://github.com/dotnet/wpf/assets/1972649/8b74c764-2aa2-4d9a-ad00-30c9571fd256

Compared to winform application:

https://github.com/dotnet/wpf/assets/1972649/602add4b-9f90-490d-8fa5-c7597793ea73

Reproduction Steps

TestClipboard.zip

  1. Download and unzip the above TestClipboard.zip file, and unzip to a folder.
  2. Sample application was based on .Net8, you should have .Net8 installed on your computer.
  3. Start the applications in the following order. (Order is important) 1) WpfApp1.exe 2) ClipobardMonitor.exe 3) InsideClipboard.exe

image

  1. Select some text in WpfApp1.exe window, right click, then select COPY menu. it will close with big delay.

https://github.com/dotnet/wpf/assets/1972649/ad11f4b4-9542-4641-80b4-27f7e657e871

Expected behavior

Copy operation should complete immediately.

Actual behavior

Copy will complete with big delay and UI freeze.

Regression?

This problem exists for a long time, both .NET framework and .Net8.

Known Workarounds

No workgorund.

Impact

Very bad user experience.

Configuration

No response

Other information

Time was costed in System.Windows.Clipboard.CriticalSetDataObject, It fails to olesetclipboard and retry many times with Sleep().

0d5a2326547d4ed4f458a69531d2a057
rampaa commented 4 weeks ago

+1. This is really annoying.