crabnebula-dev / drag-rs

Draggable for GUI apps
https://crabnebula.dev
Apache License 2.0
48 stars 9 forks source link

[Tauri] App crashes when using the js api #23

Open skyslide22 opened 5 months ago

skyslide22 commented 5 months ago

I am on macos, the tauri v1 app crashes as soon as i call startDrag.

    import { startDrag } from "@crabnebula/tauri-plugin-drag";

    async onmousedown()
    {
        const item = this.action.options.dropped_paths[0]; // example: /Users/skyslide/Desktop/favicon.png (32x32)
        if(!item) return;

        startDrag({item: [item], icon: null}) // or icon = item
    }

When i don't pass the icon key at all it doesn't crash, but no drag either. The file definitly exist and the app has access to /Desktop.

There is no message in the terminal when the app closes...

npm run tauri info output:

[✔] Environment
    - OS: Mac OS 14.1.2 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.74.0 (79e9716c9 2023-11-13)
    ✔ cargo: 1.74.0 (ecb9851af 2023-10-18)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 21.2.0
    - pnpm: 8.14.0
    - yarn: 1.22.21
    - npm: 10.2.3

[-] Packages
    - tauri [RUST]: 1.5.3
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.6
    - tao [RUST]: 0.16.5
    - tauri-cli [RUST]: 1.5.7
    - @tauri-apps/api [NPM]: 1.5.1 (outdated, latest: 1.5.3)
    - @tauri-apps/cli [NPM]: 1.5.7 (outdated, latest: 1.5.9)

[-] App
    - build-type: bundle
    - CSP: default-src 'self' https://*.fontawesome.com https://kit.fontawesome.com 'unsafe-inline'; style-src 'self' https://*.fontawesome.com https://kit.fontawesome.com 'unsafe-inline'; script-src 'self' 'unsafe-inline' ; img-src 'self' asset: https://asset.localhost
    - distDir: ../dist
    - devPath: http://localhost:8080/
    - framework: Svelte
    - bundler: Vite

main.rs:

#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use tauri::{Manager, WindowBuilder};

mod commands;
mod device_listener;

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_drag::init())
        .setup(|app| {
            let handle = app.handle();
            crate::device_listener::create_device_query_listener(handle);
            let window = app.get_window("main").unwrap();

            Ok(())
        })
        .invoke_handler(tauri::generate_handler![
            crate::commands::console_log,
            // and more
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

I have also tested your example at https://github.com/crabnebula-dev/drag-rs/blob/main/examples/tauri/index.html and it crashes the app aswell

vincehi commented 2 weeks ago

I have the same problem

vincehi commented 1 week ago

@skyslide22 Have you found a solution?

skyslide22 commented 1 week ago

@skyslide22 Have you found a solution?

no, i have not touched this crate/rust in general since

vincehi commented 6 days ago

https://github.com/crabnebula-dev/drag-rs/assets/25566437/53015e14-1736-4cc5-bc8a-4d9b956c4f1e

2024-06-26 11:03:43.278 tauri-app[6272:46699] -[__NSTaggedDate _nsib_usesPointIntegralizationForLayout]: unrecognized selector sent to instance 0x617274736e6f4373
thread 'main' panicked at /Users/USER/Sites/perso2024/drag-rs/crates/drag/src/platform_impl/macos/mod.rs:67:45:
Uncaught exception <NSException: 0x7fd2e87e48a0>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at /Users/USER/Sites/perso2024/drag-rs/crates/tauri-plugin-drag/src/lib.rs:146:15:
called `Result::unwrap()` on an `Err` value: RecvError

npm run tauri info :

[✔] Environment
    - OS: Mac OS 12.7.4 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 20.11.0
    - pnpm: 7.13.4
    - yarn: 1.22.19
    - npm: 10.8.1
    - bun: 1.1.12

[-] Packages
    - tauri [RUST]: 1.6.8
    - tauri-build [RUST]: 1.5.2
    - wry [RUST]: 0.24.10
    - tao [RUST]: 0.16.2
    - cargo-tauri [RUST]: 1.0.0
    - @tauri-apps/api [NPM]: 1.5.6
    - @tauri-apps/cli [NPM]: 1.5.6 (outdated, latest: 1.5.14)

[-] App
    - build-type: bundle
    - CSP: default-src 'self' asset: https://asset.localhost; img-src 'self'; media-src 'self'
    - distDir: ../dist
    - devPath: http://localhost:5173/
    - framework: SolidJS
    - bundler: Vite