Skip to content

[release/11.0] Fix clipboard stalls during delayed rendering - #15371

Merged
Shyam-Gupta merged 1 commit into
release/11.0from
backport/pr-15346-to-release/11.0
Nov 7, 2026
Merged

Shyam-Gupta merged 1 commit into
release/11.0from
backport/pr-15346-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

CClipDataObject::GetData
  -> GetClipboardData
    -> xxxGetRenderData
      -> xxxInterSendMsgEx

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

Cut - Before

After

Cut - After

Test environment(s)

Windows x64; .NET Framework 4.8.1 (x64 and x86) and .NET 12 (x64).

Microsoft Reviewers: Open in CodeFlow

@github-actions
github-actions Bot requested a review from a team as a code owner November 6, 2026 01:28
@Shyam-Gupta Shyam-Gupta self-assigned this Nov 6, 2026
@Shyam-Gupta Shyam-Gupta added servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria area-Clipboard Issues related to Clipboard labels Nov 6, 2026
@Shyam-Gupta Shyam-Gupta added this to the .NET 11 milestone Nov 6, 2026
@Shyam-Gupta Shyam-Gupta added servicing-approved .NET Shiproom approved the PR for merge and removed servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria labels Nov 7, 2026
@Shyam-Gupta
Shyam-Gupta merged commit 6063a8e into release/11.0 Nov 7, 2026
8 checks passed
@Shyam-Gupta
Shyam-Gupta deleted the backport/pr-15346-to-release/11.0 branch November 7, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Clipboard Issues related to Clipboard servicing-approved .NET Shiproom approved the PR for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants