-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
^12.0.6
What operating system are you using?
Windows
Operating System Version
Windows 10 Version 20H2
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Upon setting setContentProtection(true), I expect that this setting should be preserved following a .hide() and .show()/.showInactive() of the BrowserWindow
.
Actual Behavior
If setting setContentProtection(true) on the BrowserWindow, which behind the scene uses the SetWindowDisplayAffinity
WinAPI call (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity), it sets the window affinity as WDA_EXCLUDEFROMCAPTURE
for Windows 10 builds newer or equal to Windows 10 Version 2004, which means that the window is completely invisible in screenshots or any other screen captures. Please see screenshot below with window not showing, so content 'behind' it being fully visible.
This works fine up until a browserWindow.hide() is called. After that, regardless of doing browserWindow.show() or browserWindow.showInactive() afterwads, screencapture/screenshots then show the window without content, but just a black background, as if the window affinity changed to WDA_MONITOR
. Please see screenshot below with window showing with black content after hide and show commands:
Testcase Gist URL
No response
Additional Information
Steps to repro:
I created a small project :
https://github.com/horymury/content-protection
which sets setContentProtection
as true, then after 5 seconds it hides the BrowserWindow, and after 8 seconds it shows the BrowserWindow again.
If running Windows 10 Version 2004 or newer, if you do a screenshot in the first 5 seconds, you will see that the BrowserWindow correctly does not show up in the image. After 8 seconds ( after the browser window was hidden and then shown again) if you do a screenshot again, you will see that the BrowserWindow appears but with black content, as in the screenshots I uploaded.