[bug] Black screen in windows while screen sharing for contentProtected App
Describe the bug
So, I have an application for which the contentProtected is set to True in config. So ideally, it must be invisible to screen sharing. And it works as expected
Then, I have created a keyboard shortcut. Whenever I use the shortcut, the application either hides or shows on the screen. That is it toggles between window.hide() and window.show()
When I launch the application, it is invisible to screen sharing. Now when I toggle keyboard shortcut, the app hides, i.e. even for me it does not show up on the screen. Now when I toggle the keyboard shortcut again, I can see the app. But in the screen sharing, it shows up as a blank screen instead of being invisible
This issue only occurs on Windows and works perfectly on Mac. Attaching a video for the same.
In the video you can see that a sudden black screen appears. For me the app looks as it should look like, but on the screen share, instead of being invisible, it create a black screen
https://github.com/user-attachments/assets/4b194657-52f3-46a7-88a5-a7a5aaec7a14
Reproduction
The below is my lib.rs
use tauri::Manager;
mod shortcut;
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::new().build())
.setup(|app| {
let window = app
.get_webview_window("main")
.expect("Failed to get window");
let result = window.set_content_protected(true).unwrap();
shortcut::register_shortcuts(&app.handle()).unwrap();
Ok(())
})
// .plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Below is my shortcut.rs
use tauri::{AppHandle, Manager};
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
pub fn register_shortcuts(app: &AppHandle) -> tauri::Result<()> {
let window = app.get_webview_window("main").unwrap();
let ctrl_backslash = Shortcut::new(Some(Modifiers::CONTROL), Code::Backslash);
// Attach plugin with handler
app.plugin(
tauri_plugin_global_shortcut::Builder::new()
.with_handler(move |_app, shortcut, event| {
println!("{:?}", shortcut);
if shortcut == &ctrl_backslash {
match event.state() {
ShortcutState::Pressed => {
if window.is_visible().unwrap() {
window.hide().unwrap();
} else {
window.show().unwrap();
}
}
ShortcutState::Released => {}
}
}
})
.build(),
)
.unwrap();
// Register shortcut
app.global_shortcut().register(ctrl_backslash).unwrap();
Ok(())
}
Expected behavior
Black screen should not appear
Full tauri info output
[✔] Environment
- OS: Windows 10.0.19045 x86_64 (X64)
✔ WebView2: 140.0.3485.66
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.89.0 (29483883e 2025-08-04)
✔ cargo: 1.89.0 (c24e10642 2025-06-23)
✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.19.5
- yarn: 1.22.22
- npm: 10.8.2
[-] Packages
- tauri 🦀: 2.8.5
- tauri-build 🦀: 2.4.1
- wry 🦀: 0.53.3
- tao 🦀: 0.34.3
- @tauri-apps/api : 2.8.0
- @tauri-apps/cli : 2.8.4
[-] Plugins
- tauri-plugin-store 🦀: 2.4.0
- @tauri-apps/plugin-store : 2.4.0
- tauri-plugin-global-shortcut 🦀: 2.3.0
- @tauri-apps/plugin-global-shortcut : 2.3.0
- tauri-plugin-opener 🦀: 2.5.0
- @tauri-apps/plugin-opener : 2.5.0
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: React
- bundler: Vite
Stack trace
Additional context
No response
@LuciAkirami Are you still facing this issue?
I am facing same issue
Seems like after window.show() / window.hide() WDA_EXCLUDEFROMCAPTURE resets to WDA_MONITOR / WDA_NONE, i tried to reset it manually, but its not helping(