Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix(studio): enable microphone/camera access in Linux WebKitGTK webview (#8720)

Darshan Poudel5991194df803
diff --git a/studio/src-tauri/Cargo.lock b/studio/src-tauri/Cargo.lock
index 94e7cc5aa26..e216cb29560 100644
--- a/studio/src-tauri/Cargo.lock
+++ b/studio/src-tauri/Cargo.lock
@@ -5759,6 +5759,7 @@ dependencies = [
"tempfile",
"time",
"tokio",
+ "webkit2gtk",
"webkit2gtk-sys",
"webview2-com",
"windows 0.62.2",
diff --git a/studio/src-tauri/Cargo.toml b/studio/src-tauri/Cargo.toml
index 5e1f26b8f36..23d92c0c061 100644
--- a/studio/src-tauri/Cargo.toml
+++ b/studio/src-tauri/Cargo.toml
@@ -58,6 +58,7 @@ glib = "0.18"
gtk = "0.18"
elevated-command = "1.1.2"
webkit2gtk-sys = "2.0.2"
+webkit2gtk = "2.0.2"
[target.'cfg(windows)'.dependencies]
# Keep these versions aligned with Tauri's WebView2 controller bindings.
diff --git a/studio/src-tauri/src/main.rs b/studio/src-tauri/src/main.rs
index 77d36a57343..56424907368 100644
--- a/studio/src-tauri/src/main.rs
+++ b/studio/src-tauri/src/main.rs
@@ -802,6 +802,40 @@ fn setup_custom_titlebar(app: &tauri::App) -> Result<(), Box<dyn std::error::Err
Ok(())
}
+// WebKitGTK ships two defaults that together break voice dictation on Linux:
+// `enable-media-stream` is off, and the stock `permission-request` handler
+// denies every request it never saw a listener override, including
+// microphone/camera grabs. Neither is fixable from outside the embedding
+// application, so opt in here and auto-allow only user-media requests --
+// every other permission kind (notifications, geolocation, ...) keeps the
+// default deny.
+#[cfg(target_os = "linux")]
+fn setup_linux_media_permissions(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
+ use webkit2gtk::{
+ glib::Cast, PermissionRequestExt, SettingsExt, UserMediaPermissionRequest, WebViewExt,
+ };
+
+ let window = app.get_webview_window("main").ok_or_else(|| {
+ std::io::Error::new(std::io::ErrorKind::NotFound, "main window not found")
+ })?;
+ window.with_webview(|webview| {
+ let webview = webview.inner();
+ if let Some(settings) = webview.settings() {
+ settings.set_enable_media_stream(true);
+ }
+ webview.connect_permission_request(|_webview, request| {
+ match request.downcast_ref::<UserMediaPermissionRequest>() {
+ Some(request) => {
+ request.allow();
+ true
+ }
+ None => false,
+ }
+ });
+ })?;
+ Ok(())
+}
+
// Compile in both Windows profiles so dependency skew fails in CI, even though
// the guard is installed only in release builds.
#[cfg(windows)]
@@ -1905,6 +1939,8 @@ fn main() {
}
#[cfg(any(target_os = "windows", target_os = "linux"))]
setup_custom_titlebar(app)?;
+ #[cfg(target_os = "linux")]
+ setup_linux_media_permissions(app)?;
#[cfg(all(windows, not(debug_assertions)))]
setup_windows_browser_guards(app)?;
#[cfg(target_os = "macos")]