tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] tauri has `segmentation fault (core dumped)` when used `screenshots-rs` at Archlinux

Open PeterDing opened this issue 1 year ago • 2 comments

Describe the bug

At my Archlinux environment, tauri can not work with screenshots-rs. The segmentation fault (core dumped) occurs when the app is running. But, the same code runs correctly on MacOS. At same time, the alone screenshots-rs without tauri can runs without any errors at Archlinux. So, I infer that the segmentation fault error is attributed to tauri.

Reproduction

At the updated Archlinux environment, I use vite.js to initiate a project with React framework. Then I install @tauri-apps/cli. I only modify src-tauri/Cargo.toml and src-tauri/src/main.rs as following.

  • src-tauri/Cargo.toml
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.5.1", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.5.4", features = [] }

screenshots = "0.8"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
# DO NOT REMOVE!!
custom-protocol = [ "tauri/custom-protocol" ]
  • src-tauri/src/main.rs
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use screenshots::Screen;

#[tauri::command]
fn screencapture(x: i32, y: i32, image_path: &str) {
    let screens = Screen::all().unwrap();
    for screen in screens {
        let info = screen.display_info;
        if info.x == x && info.y == y {
            let image = screen.capture().unwrap();
            image.save(image_path).unwrap();
            break;
        }
    }
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![screencapture])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Expected behavior

After these steps are done at Reproduction, the error happens when running npm run tauri dev.

Full tauri info output

$ npm run tauri info

> [email protected] tauri
> tauri info


[✔] Environment
    - OS: EndeavourOS Rolling Release X64
    ✔ webkit2gtk-4.0: 2.42.4
    ✔ rsvg2: 2.57.1
    ✔ rustc: 1.77.0-nightly (bf8716f1c 2023-12-24)
    ✔ cargo: 1.77.0-nightly (363a2d113 2023-12-22)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: nightly-x86_64-unknown-linux-gnu (default)
    - node: 21.4.0
    - pnpm: 8.6.0
    - npm: 10.2.5

[-] Packages
    - tauri [RUST]: 1.5.4
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.5
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.5.9

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:3000/
    - framework: React
    - bundler: Vite


### Stack trace

```text
[1]    173879 segmentation fault (core dumped)

Additional context

No response

PeterDing avatar Dec 25 '23 14:12 PeterDing

@nashaofu you may have an attention.

PeterDing avatar Dec 25 '23 15:12 PeterDing

  1. I guess it is renamed to xcap.
  2. Anyway, I tried to use xcap, and I used use xcap::Monitor;, and it compiled fine, but nothing shows up. So, I guess it is upstream bug

naman-crabnebula avatar Jan 24 '24 16:01 naman-crabnebula

any update on this?

xcap just return my empty desktop instead of apps i see (macos m3)

everything works well outside tauri

update: for some reason it works now (didnt change anything)

louis030195 avatar Jul 21 '24 15:07 louis030195