Repository navigation
[release/11.0] Fix clipboard stalls during delayed rendering - #15371
Merged
Merged
Conversation
Shyam-Gupta
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #15346 to release/11.0
/cc @Shyam-Gupta @davkean
Issue
Clipboard operations can stall and fail with
CLIPBRD_E_CANT_OPEN. In a Visual Studio trace, Windows Clipboard User Service (cbdhsvc) was reading data through OLE and blocked in the delayed-rendering path:Root Cause
Windows was synchronously requesting clipboard data from the editor's UI thread (
WM_RENDERFORMAT), while the service held the clipboard open. That UI thread was trying to replace the clipboard contents and sleeping between failed open attempts, so it could not answer the render request until retries were exhausted.Fix
The retry wait now lets the UI thread answer sent messages, breaking that dependency without processing posted messages or queued input. Retry intervals and attempt limits remain unchanged.
Customer Impact
Clipboard operations in WinForms and WPF can recover from this contention instead of exhausting retries.
Regression?
Since .NET 11, WinForms runtime repo has started shipping an internal NuGet package, targeting .NET Framework, which includes the shared Clipboard and the new NRBF serializer/deserializer (the BinaryFormatter replacement). This package is consumed by VS AppLocal WPF which is shipped with VS and handles the Clipboard operations. This bug got introduced as part of that new package.
Till Dev17, the Clipboard was handled by the old WPF code which didn’t have this issue. So, it can be considered as a regression.
Risk
All pending sent messages can run, not just clipboard-render requests. Their handlers can reenter application code and change clipboard or UI state. The retry deadline does not bound time spent inside a handler.
Test methodology
Mock OLE operations and private windows cover all five retry paths, delayed rendering, unrelated sent messages, nested calls, retry exhaustion, and posted-message preservation without touching the system clipboard.
Also manually tested this with Visual Studio by continually holding down CTRL+X.
Before
After
Test environment(s)
Windows x64; .NET Framework 4.8.1 (x64 and x86) and .NET 12 (x64).
Microsoft Reviewers: Open in CodeFlow