Skip to content

fix: apply setContentProtection() in Windows remote sessions again - #54492

Merged
codebytere merged 2 commits into
mainfrom
fix-win-content-protection-remote-session
Sep 28, 2026
Merged

codebytere merged 2 commits into
mainfrom
fix-win-content-protection-remote-session

Conversation

@codebytere

Copy link
Copy Markdown
Member

Description of Change

Since Electron 44, win.setContentProtection(true) has done nothing when the app runs in a Windows remote session, while win.isContentProtected() kept returning true. Chromium stopped excluding windows from capture in remote sessions so that its own Picture-in-Picture windows stay visible to the remote user (https://chromium-review.googlesource.com/c/chromium/src/+/7918332), and setContentProtection() goes through the same code path.

This enables AllowWindowCaptureExclusionInRemoteSessions by default, so an explicit request for protection is honored again as it is on 43. Apps that would rather leave windows unprotected in remote sessions can pass the feature to --disable-features, which takes precedence. A second commit documents that the change takes effect with the next desktop composition.

Measured on Windows 11 24H2 in a Remote Desktop session: 43.7.5 sets WDA_EXCLUDEFROMCAPTURE, the window stays visible in the mstsc client and is absent from a capture taken inside the session; 44.4.5 leaves WDA_NONE and the capture contains the window. 44.4.3 launched with --enable-features=AllowWindowCaptureExclusionInRemoteSessions, which is what this change makes the default, applies the exclusion again and the window is absent from desktopCapturer.getSources(). At the console all of them set it. There's no spec because CI can't switch a session between console and remote.

Checklist

Release Notes

Notes: Fixed setContentProtection(true) having no effect in Windows remote sessions.

Chromium stopped excluding windows from capture in remote sessions so that
its own Picture-in-Picture windows stay visible to the remote user
(https://chromium-review.googlesource.com/c/chromium/src/+/7918332). The
same code path backs setContentProtection(), so since Electron 44 the call
has silently done nothing over Remote Desktop while isContentProtected()
kept returning true. Enable the feature that lifts the restriction by
default, and document the effect on remote users and how to opt out.
SetWindowDisplayAffinity is applied by the next DWM composition. Measured on
Windows 11 24H2, the first frame without the window was presented 9-42ms after
the call, and a capture started within about 11ms could still contain it.
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 27, 2026
@codebytere
codebytere merged commit 8af22fd into main Sep 28, 2026
92 checks passed
@release-clerk

release-clerk Bot commented Sep 28, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed setContentProtection(true) having no effect in Windows remote sessions.

@trop

trop Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54499

@trop

trop Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #54500

@trop trop Bot added in-flight/44-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. and removed target/45-x-y PR should also be added to the "45-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. in-flight/44-x-y in-flight/45-x-y labels Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants