Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions apps/app/src/linux.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::{env, path::Path};

const NVIDIA_EXPLICIT_SYNC_ENV: &str = "__NV_DISABLE_EXPLICIT_SYNC";

pub fn configure_webkit() {
if should_disable_nvidia_explicit_sync(
env::var_os("WAYLAND_DISPLAY").is_some(),
Path::new("/sys/module/nvidia").exists(),
env::var_os(NVIDIA_EXPLICIT_SYNC_ENV).is_some(),
) {
env::set_var(NVIDIA_EXPLICIT_SYNC_ENV, "1");
}
}

fn should_disable_nvidia_explicit_sync(
wayland: bool,
nvidia: bool,
explicitly_configured: bool,
) -> bool {
wayland && nvidia && !explicitly_configured
}

#[cfg(test)]
mod tests {
use super::should_disable_nvidia_explicit_sync;

#[test]
fn disables_explicit_sync_for_nvidia_wayland() {
assert!(should_disable_nvidia_explicit_sync(true, true, false));
}

#[test]
fn leaves_other_graphics_stacks_unchanged() {
assert!(!should_disable_nvidia_explicit_sync(false, true, false));
assert!(!should_disable_nvidia_explicit_sync(true, false, false));
}

#[test]
fn preserves_explicit_configuration() {
assert!(!should_disable_nvidia_explicit_sync(true, true, true));
}
}
6 changes: 6 additions & 0 deletions apps/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ mod error;
#[cfg(target_os = "macos")]
mod macos;

#[cfg(target_os = "linux")]
mod linux;

#[cfg(feature = "updater")]
mod updater_impl;
#[cfg(not(feature = "updater"))]
Expand Down Expand Up @@ -114,6 +117,9 @@ async fn set_restart_after_pending_update(
// if Tauri app is called with arguments, then those arguments will be treated as commands
// ie: deep links or filepaths for .mrpacks
fn main() {
#[cfg(target_os = "linux")]
linux::configure_webkit();

#[cfg(feature = "export-app-events")]
theseus::export_app_event_bindings(
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
Expand Down