Skip to content
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

Fix nvidia on linux segfault #2542

Merged
merged 10 commits into from
Jun 7, 2024
Merged
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
494 changes: 440 additions & 54 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions apps/desktop/crates/linux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ edition = { workspace = true }

[dependencies]
tokio = { workspace = true, features = ["fs"] }
libc = { workspace = true }
libc = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
wgpu = { version = "0.20.0", default-features = false }
# WARNING: gtk should follow the same version used by tauri
# https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L85C1-L85C51
gtk = { version = "0.18", features = [ "v3_24" ] }
gtk = { version = "0.18", features = ["v3_24"] }
33 changes: 33 additions & 0 deletions apps/desktop/crates/linux/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ pub fn normalize_environment() {
],
)
.expect("PATH must be successfully normalized");

if has_nvidia() {
// Workaround for: https://github.com/tauri-apps/tauri/issues/9304
env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
}
}

// Check if snap by looking if SNAP is set and not empty and that the SNAP directory exists
Expand All @@ -198,3 +203,31 @@ pub fn is_flatpak() -> bool {

false
}

fn has_nvidia() -> bool {
use wgpu::{
Backends, DeviceType, Dx12Compiler, Gles3MinorVersion, Instance, InstanceDescriptor,
InstanceFlags,
};

let instance = Instance::new(InstanceDescriptor {
flags: InstanceFlags::empty(),
backends: Backends::VULKAN | Backends::GL,
gles_minor_version: Gles3MinorVersion::Automatic,
dx12_shader_compiler: Dx12Compiler::default(),
});
for adapter in instance.enumerate_adapters(Backends::all()) {
let info = adapter.get_info();
match info.device_type {
DeviceType::DiscreteGpu | DeviceType::IntegratedGpu | DeviceType::VirtualGpu => {
// Nvidia PCI id
if info.vendor == 0x10de {
return true;
}
}
_ => {}
}
}

false
}
17 changes: 11 additions & 6 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@ sd-core = { path = "../../../core", features = ["ffmpeg", "heif"] }
sd-fda = { path = "../../../crates/fda" }
sd-prisma = { path = "../../../crates/prisma" }

# Workspace dependencies
axum = { workspace = true, features = ["headers", "query"] }
hyper = "0.14.28"
futures = { workspace = true }
http = { workspace = true }
prisma-client-rust = { workspace = true }
rand = { workspace = true }
rspc = { workspace = true, features = ["tauri", "tracing"] }
serde = { workspace = true }
serde_json = { workspace = true }
specta = { workspace = true }
strum = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["sync"] }
tracing = { workspace = true }
tauri-specta = { workspace = true, features = ["typescript"] }
thiserror = { workspace = true }
uuid = { workspace = true, features = ["serde"] }
thiserror.workspace = true
directories = "5.0.1"

opener = { version = "0.6.1", features = ["reveal"] }
# Specific Desktop dependencies
directories = "5.0.1"
hyper = "0.14.28"
# WARNING: Do NOT enable default features, as that vendors dbus (see below)
opener = { version = "0.7.1", features = ["reveal"], default-features = false }
tauri = { version = "=2.0.0-beta.17", features = [
"macos-private-api",
"unstable",
Expand All @@ -40,10 +45,10 @@ tauri-plugin-updater = "2.0.0-beta"
tauri-plugin-dialog = "2.0.0-beta"
tauri-plugin-os = "2.0.0-beta"
tauri-plugin-shell = "2.0.0-beta"
serde_json.workspace = true
strum = { workspace = true, features = ["derive"] }

[target.'cfg(target_os = "linux")'.dependencies]
# WARNING: dbus must NOT be vendored, as that breaks the app on Linux,X11,Nvidia
dbus = { version = "0.9", features = ["stdfd"] }
sd-desktop-linux = { path = "../crates/linux" }
# https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L86
webkit2gtk = { version = "=2.0.1", features = ["v2_38"] }
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"files": {
"/usr/share/spacedrive/models/yolov8s.onnx": "../../.deps/models/yolov8s.onnx"
},
"depends": ["libc6", "libxdo3"]
"depends": ["libc6", "libxdo3", "dbus"]
}
},

Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ trash = "4.1.0"
trash = "4.1.0"

[target.'cfg(target_os = "ios")'.dependencies]
icrate = { version = "0.1.0", features = [
icrate = { version = "0.1.2", features = [
"Foundation",
"Foundation_NSFileManager",
"Foundation_NSString",
Expand Down
2 changes: 1 addition & 1 deletion core/src/api/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sd_prisma::{
prisma::{file_path, object, tag, tag_on_object},
prisma_sync,
};
use sd_sync::{option_sync_db_entry, option_sync_entry, sync_entry, OperationFactory};
use sd_sync::{option_sync_db_entry, OperationFactory};
use sd_utils::{msgpack, uuid_to_bytes};

use std::collections::BTreeMap;
Expand Down
1 change: 0 additions & 1 deletion core/src/library/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ impl Libraries {
.iter()
.flatten()
.filter_map(|i| RemoteIdentity::from_bytes(&i.remote_identity).ok())
.into_iter()
.any(|i| i == *instance)
.then(|| Arc::clone(library))
}),
Expand Down
1 change: 0 additions & 1 deletion core/src/object/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use sd_sync::*;

use chrono::{DateTime, FixedOffset, Utc};

use sd_utils::msgpack;
use serde::Deserialize;
use specta::Type;
use uuid::Uuid;
Expand Down
8 changes: 4 additions & 4 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ case "$(uname)" in

# Tauri dependencies
set -- build-essential curl wget file openssl libssl-dev libgtk-3-dev librsvg2-dev \
libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev
libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev libdbus-1-dev

# Webkit2gtk requires gstreamer plugins for video playback to work
set -- "$@" gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
Expand All @@ -161,7 +161,7 @@ case "$(uname)" in
echo "Installing dependencies with pacman..."

# Tauri dependencies
set -- base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool
set -- base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool dbus

# Webkit2gtk requires gstreamer plugins for video playback to work
set -- "$@" gst-plugins-base gst-plugins-good gst-plugins-ugly
Expand All @@ -185,7 +185,7 @@ case "$(uname)" in
fi

# Tauri dependencies
set -- openssl webkit2gtk4.1-devel openssl-dev curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel
set -- openssl webkit2gtk4.1-devel openssl-dev curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel dbus-devel

# Webkit2gtk requires gstreamer plugins for video playback to work
set -- "$@" gstreamer1-devel gstreamer1-plugins-base-devel gstreamer1-plugins-good \
Expand All @@ -205,7 +205,7 @@ case "$(uname)" in

# Tauri dependencies
set -- build-base curl wget file openssl-dev gtk+3.0-dev librsvg-dev \
webkit2gtk-4.1-dev libayatana-indicator-dev xdotool
webkit2gtk-4.1-dev libayatana-indicator-dev xdotool-dev dbus-dev

# Webkit2gtk requires gstreamer plugins for video playback to work
set -- "$@" gst-plugins-base-dev gst-plugins-good gst-plugins-ugly
Expand Down
Loading