From c61c966bea4c37b5252c6075bdafe8516c3847ce Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 10 Feb 2026 01:49:46 +0000 Subject: [PATCH 1/3] Desktop: Disable more chromium features --- desktop/src/cef/context/builder.rs | 5 ++-- .../src/cef/internal/browser_process_app.rs | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/desktop/src/cef/context/builder.rs b/desktop/src/cef/context/builder.rs index 071648eb74e..b326269ebb9 100644 --- a/desktop/src/cef/context/builder.rs +++ b/desktop/src/cef/context/builder.rs @@ -1,9 +1,9 @@ use std::path::{Path, PathBuf}; use cef::args::Args; -use cef::sys::{CEF_API_VERSION_LAST, cef_resultcode_t}; +use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t, cef_resultcode_t}; use cef::{ - App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash, + App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, LogSeverity, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash, browser_host_create_browser_sync, execute_process, }; @@ -79,6 +79,7 @@ impl CefContextBuilder { root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(), cache_path: CefString::from(""), disable_signal_handlers: 1, + log_severity: LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL), ..Default::default() } } diff --git a/desktop/src/cef/internal/browser_process_app.rs b/desktop/src/cef/internal/browser_process_app.rs index 55df7c22c4f..eb871833897 100644 --- a/desktop/src/cef/internal/browser_process_app.rs +++ b/desktop/src/cef/internal/browser_process_app.rs @@ -38,11 +38,33 @@ impl ImplApp for BrowserProcessAppImpl { cmd.append_switch_with_value(Some(&CefString::from("disk-cache-size")), Some(&CefString::from("0"))); cmd.append_switch(Some(&CefString::from("incognito"))); cmd.append_switch(Some(&CefString::from("no-first-run"))); + cmd.append_switch(Some(&CefString::from("no-default-browser-check"))); + cmd.append_switch(Some(&CefString::from("disable-component-update"))); + cmd.append_switch(Some(&CefString::from("disable-geolocation"))); + cmd.append_switch(Some(&CefString::from("disable-notifications"))); + cmd.append_switch(Some(&CefString::from("disable-media-stream"))); + cmd.append_switch(Some(&CefString::from("disable-audio-input"))); + cmd.append_switch(Some(&CefString::from("disable-audio-output"))); + cmd.append_switch(Some(&CefString::from("disable-webrtc"))); + cmd.append_switch(Some(&CefString::from("disable-sync"))); cmd.append_switch(Some(&CefString::from("disable-file-system"))); cmd.append_switch(Some(&CefString::from("disable-local-storage"))); cmd.append_switch(Some(&CefString::from("disable-background-networking"))); - cmd.append_switch(Some(&CefString::from("disable-audio-input"))); - cmd.append_switch(Some(&CefString::from("disable-audio-output"))); + cmd.append_switch(Some(&CefString::from("disable-default-apps"))); + cmd.append_switch(Some(&CefString::from("disable-extensions"))); + cmd.append_switch(Some(&CefString::from("disable-breakpad"))); + cmd.append_switch(Some(&CefString::from("disable-machine-learning-model-loader"))); + cmd.append_switch_with_value(Some(&CefString::from("disable-blink-features")), Some(&CefString::from("WebBluetooth,WebUSB,Serial,IdleDetection"))); + + let extra_disabled_features = ["OptimizationHints", "GCM", "OnDeviceModelService", "Optimization", "TranslateUI"]; + let disabled_features_switch = Some(&CefString::from("disable-features")); + let disabled_features: String = CefString::from(&cmd.switch_value(disabled_features_switch)) + .to_string() + .split(',') + .chain(extra_disabled_features) + .collect::>() + .join(","); + cmd.append_switch_with_value(disabled_features_switch, Some(&CefString::from(disabled_features.as_str()))); #[cfg(not(feature = "accelerated_paint"))] { From f64604b48a0e61a4d986bc1fda0b0735f044239a Mon Sep 17 00:00:00 2001 From: Timon Date: Wed, 11 Feb 2026 22:06:27 +0000 Subject: [PATCH 2/3] Make browser logging configurable with env --- desktop/src/cef/context/builder.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/desktop/src/cef/context/builder.rs b/desktop/src/cef/context/builder.rs index b326269ebb9..e6ad318688c 100644 --- a/desktop/src/cef/context/builder.rs +++ b/desktop/src/cef/context/builder.rs @@ -74,12 +74,24 @@ impl CefContextBuilder { } fn common_settings(instance_dir: &Path) -> Settings { + let log_severity = match std::env::var("GRAPHITE_BROWSER_LOG") { + Ok(level) => match level.to_lowercase().as_str() { + "debug" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_VERBOSE), + "info" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_INFO), + "warn" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_WARNING), + "error" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_ERROR), + "none" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_DISABLE), + _ => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL), + }, + Err(_) => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL), + }; + Settings { windowless_rendering_enabled: 1, root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(), cache_path: CefString::from(""), disable_signal_handlers: 1, - log_severity: LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL), + log_severity, ..Default::default() } } From 7eacf51a795460aff41107f2466623d2e3549dd7 Mon Sep 17 00:00:00 2001 From: Timon Date: Wed, 11 Feb 2026 22:53:41 +0000 Subject: [PATCH 3/3] fixup --- desktop/src/cef/internal/browser_process_app.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/desktop/src/cef/internal/browser_process_app.rs b/desktop/src/cef/internal/browser_process_app.rs index eb871833897..413eb042281 100644 --- a/desktop/src/cef/internal/browser_process_app.rs +++ b/desktop/src/cef/internal/browser_process_app.rs @@ -42,21 +42,17 @@ impl ImplApp for BrowserProcessAppImpl { cmd.append_switch(Some(&CefString::from("disable-component-update"))); cmd.append_switch(Some(&CefString::from("disable-geolocation"))); cmd.append_switch(Some(&CefString::from("disable-notifications"))); - cmd.append_switch(Some(&CefString::from("disable-media-stream"))); cmd.append_switch(Some(&CefString::from("disable-audio-input"))); cmd.append_switch(Some(&CefString::from("disable-audio-output"))); - cmd.append_switch(Some(&CefString::from("disable-webrtc"))); cmd.append_switch(Some(&CefString::from("disable-sync"))); cmd.append_switch(Some(&CefString::from("disable-file-system"))); cmd.append_switch(Some(&CefString::from("disable-local-storage"))); cmd.append_switch(Some(&CefString::from("disable-background-networking"))); cmd.append_switch(Some(&CefString::from("disable-default-apps"))); - cmd.append_switch(Some(&CefString::from("disable-extensions"))); cmd.append_switch(Some(&CefString::from("disable-breakpad"))); - cmd.append_switch(Some(&CefString::from("disable-machine-learning-model-loader"))); - cmd.append_switch_with_value(Some(&CefString::from("disable-blink-features")), Some(&CefString::from("WebBluetooth,WebUSB,Serial,IdleDetection"))); + cmd.append_switch_with_value(Some(&CefString::from("disable-blink-features")), Some(&CefString::from("WebBluetooth,WebUSB,Serial"))); - let extra_disabled_features = ["OptimizationHints", "GCM", "OnDeviceModelService", "Optimization", "TranslateUI"]; + let extra_disabled_features = ["OptimizationHints", "OnDeviceModelService", "TranslateUI"]; let disabled_features_switch = Some(&CefString::from("disable-features")); let disabled_features: String = CefString::from(&cmd.switch_value(disabled_features_switch)) .to_string()