-
Notifications
You must be signed in to change notification settings - Fork 15.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setContentProtection not working on macOS #19880
Comments
Thank you for taking the time to report this issue and helping to make Electron better. Would it be possible for you to fork electron-quick-start for a small app that reproduces the issue by itself? Standalone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests. |
@sofianguy , yes i will post shortly the link . Thanks ! |
@sofianguy , here you can see it https://github.com/veemex/electron-quick-start "git clone https://github.com/veemex/electron-quick-start setContentProtectionBug" :) |
It's not working because WebRTC recently switched to a CGDisplayStream-based capturer, which doesn't respect NSWindowSharingNone. Here's the relevant issue https://bugs.chromium.org/p/webrtc/issues/detail?id=8652 AFAICT the only option is for Electron to expose SetExcludedWindow of the DesktopCapturer instance that WebRTC is holding. We'd also probably want to patch it to allow you to exclude multiple windows. But even if we do that work, Windows still won't work, as the DXGI capturer doesn't support excluded windows 😕 |
Can we expand on this? I'm looking for answers to protect my electron app content from screen shares and remote desktop software. |
Is this going to be have any fixes? Also does someone recommend a way to use another capturer for the MacOS or another way of achieving this effect of not showing the app during a screen recording that can be converted to a media-stream ? Thanks ! |
Is there any fix for this now? Google Meets can capture my screen even if the screen protection is set to true. I need to urgently fix this! My electron app is valued only because it can't be seen on screen shares! |
But since windows has the affinity setting, shouldn't it work with that? Also, what ID do I pass to SetExcudedWindow to fix this? |
On Mac, pass the chromium flag |
And what if I want my window to not be seen by other Screen Recording software? This used to work well with setContentProtection() but now any screenshare from Chrome Mac shows the window. Will this help with that? Or will I have wait for electron to change to setExcludedWindow? |
Yes, to have |
This doesn't seem to work. On Mac OS, Chrome (Google meets specifically) screen share, my window is exposed. |
Probably Google meets ignores all chromium flags. What I meant has to be set for an electron based application on which you have control on the build, so calling |
Yeah I did that, didn't help. I need Google Chrome (Google meets screen share etc. i.e. webrtc capturer) to not record my electron app which has sensitive content. I was using setContentProtection() to do that. This works fine with firefox on Mac and any browser on Windows, but the screen capturer in Mac chrome is not respecting setContentProtection, I need a way around that. |
Oh I see you would need to pass |
So, as suggested here : https://bugs.chromium.org/p/webrtc/issues/detail?id=8652#c45 can we use webrtc::DesktopCapturer::SetExcludedWindow instead of relying on NSWindowSharingNone for mac? |
@sajjanbalar there is no solution for what you are trying to do since you do not have control to Google Chrome or Google Meeting. The webrtc::DesktopCapturer::SetExcludedWindow API would to use when you setup the screen capture from your own app. |
Oh, but setContentProtection works well in windows, also in Firefox mac. I guess what I am seeking is a way to tell the mac os chrome browser to respect the windows choice to not get captured. No way to do that? |
OK, thanks, So we will wait to enable it by default to avoid all the side effects 😁 |
Hello Electron team, Could you kindly provide us with any updates on this issue and possibly a timeline for resolution? This would be greatly beneficial in helping us manage our project's timeline and expectations. Thank you for your time and consideration :) |
The setContentProtection API is based on the NSWindow's sharingType on MacOS. |
Is there any progress on this problem? |
Is there any workaround for this problem? |
In electron utils 2.0.15 we mark them as protected content, but on macOS WebRTC uses a low level API which sidesteps that. An extra command line argument is passed to fix that. See: electron/electron#19880
This fixes the AoT and screensharing tracker from being captured based on electron/electron#19880
It is ignored by Microsoft because of incompatibilities BUT you can use my fork: https://github.com/lnxx-kernel/electron_touch |
Is there any progress on this problem? |
We were able to get this working if:
ScreenCaptureKit support is still being developed in Chromium so I'd only recommend doing this for Electron v26+. |
Hello Electron Team, |
https://bugs.chromium.org/p/chromium/issues/detail?id=1309653 @MarshallOfSound based on these findings, and the versioning checks, It should be safe to enable this feature rn? |
@derekcicerone |
I have made it work with this flag
and BUT make sure you are on electron version |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Electron 20 is EOL, you shouldn't be using that or recommending it to anyone. |
@saghul I have been struggling with this issue for couple of days now, our app requires some windows to be ignored when screen recording, and the only solution which worked for me was downgrading electron to 23.3.13 as latest, above this |
Here is a gist that shows this: https://gist.github.com/phwang4/655231b026fdedac408f430604dee0b8 If I disable that line the screen share will work again (although setContentProtection still doesn't work) |
Hey @divyanshunegi, I have been trying the same for a while but it's not working for me, like I can still see the app while doing screen share on google meet, anyway you can share a demo project with it implemented ? |
Beginning with macOS 14.4, releasing in the next 30 days, the old CGDisplayStreamCreate methods are resulting in per-session alerts. What is the current plan to support ScreenCaptureKit in its place, @MarshallOfSound ? :) |
@KlausMikhaelson I am facing the same issue, did you found some solution? |
any solution for protecting electron app while sharing entire screen on Zoom app for electron version v30. |
I'm also wondering if this issue has become a lost cause? In which case the docs really need updating. They already acknowledge it doesn't work on Linux and should specify the same for macOS. |
I tried some solution which is working intermediately |
Hey, guys! I have come up with one solution for screen recording protection on MacOS. I found that the VTEncoderXPCService process starts when capturing the screen. And I wrote a function that periodically checks the list of processes. You can check through Electron Fiddle: I checked on Ventura 13.0 (22A8380) and it works for me. |
Is there any solution for this without killing the screenshare process? Can't we detect screenshare and blur the app? The blur should only be visible in screenshare and user should be able to see the app. |
Electron team doesn't really seem to care if their promised feature set breaks, as long as it worked once in the past. It's not good. At least update the docs... |
@ansien I tried v24, the bug is still present on MacOS. |
Preflight Checklist
Issue Details
6.0.x , 7.0.x
*4.x.x
Expected Behavior
The function {browserwindow}.setContentProtection(true) , should make the app unrecordable for "Electron desktopCapturer" module.
Actual Behavior
It does not work .
To Reproduce
Make a simple blank app, setContentProtection of the browserWindow, capture the desktop stream using the desktopCapturer module and show it on a canvas.
The text was updated successfully, but these errors were encountered: