tauri: [bug] "Command failed with exit code 3221225781" and "Command failed with exit code 4294967295"?

Describe the bug

image

Reproduction

No response

Expected behavior

The app should start and print sim connect data

Platform and versions

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 113.0.1774.35
    ✔ MSVC:
        - Visual Studio Community 2022
        - Visual Studio Build Tools 2022
    ✔ rustc: 1.69.0 (84c898d65 2023-04-16)
    ✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.15.0
    - pnpm: 8.4.0
    - yarn: 1.22.19
    - npm: 9.5.0

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.1
    - @tauri-apps/api [NPM]: 1.3.0
    - @tauri-apps/cli [NPM]: 1.3.0 (outdated, latest: 1.3.1)

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

Stack trace

No response

Additional context

main.rs

// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use sim_connect::SimConnect;

mod events;
mod sim_connect;

fn main() {
    let _sim = SimConnect::new();
    tauri::Builder::default()
        .setup(|app| {
            let _app_handle = app.handle();
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

events.rs

use simconnect_sdk::SimConnectObject;

#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second")]
#[allow(dead_code)]
pub struct AircraftData {
    #[simconnect(name = "TITLE")]
    aircraft_title: String,
    #[simconnect(name = "CATEGORY")]
    aircraft_category: String,
    #[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
    aircraft_lat: f64,
    #[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]
    aircraft_lon: f64,
    #[simconnect(name = "PLANE ALTITUDE", unit = "feet")]
    aircraft_alt: f64,
    #[simconnect(name = "PLANE ALT ABOVE GROUND", unit = "feet")]
    aircraft_alt_above_ground: f64,
    #[simconnect(name = "VERTICAL SPEED", unit = "ft/min")]
    aircraft_vertical_speed: f64,
}

#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second")]
#[allow(dead_code)]
pub struct SimData {
    #[simconnect(name = "SIM ON GROUND")]
    sim_on_ground: bool,
}

#[derive(Debug)]
#[allow(dead_code)]
pub enum SimConnectEvent {
    AircraftData(AircraftData),
    SimData(SimData),
}

#[allow(dead_code)]
pub enum TauriEvent {}

sim_connect.rs

use std::{thread, time::Duration};

use crate::events::{AircraftData, SimData};
use simconnect_sdk::SimConnect as Sim;

pub struct SimConnect {}

impl SimConnect {
    pub fn new() -> Self {
        thread::spawn(|| {
            let client = Sim::new("VirtualFlyer");
            match client {
                Ok(mut c) => loop {
                    {
                        match c.get_next_dispatch() {
                            Ok(notification) => match notification {
                                Some(event) => match event {
                                    simconnect_sdk::Notification::Open => {
                                        println!("SIM CONNECTED");
                                        c.register_object::<SimData>().ok();
                                        c.register_object::<AircraftData>().ok();
                                    }
                                    simconnect_sdk::Notification::Object(obj) => {
                                        if let Ok(sim_data) = SimData::try_from(&obj) {
                                            println!("{:?}", sim_data);
                                        }
                                        if let Ok(sim_data) = AircraftData::try_from(&obj) {
                                            println!("{:?}", sim_data);
                                        }
                                    }
                                    _ => {}
                                },
                                None => {}
                            },
                            Err(_) => {}
                        }
                    }
                    thread::sleep(Duration::from_millis(20));
                },
                Err(_) => {}
            }
        });
        Self {}
    }
}

cargo.toml

[package]
name = "virtual_flyer"
version = "0.0.0"
description = "A Tauri App"
authors = ["SafeShows#5341 <safeshows@za110.club>"]
license = ""
repository = ""
edition = "2021"
publish = false

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

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

[dependencies]
simconnect-sdk = { version = "0.2.2", features = ["derive"] }

tauri = { version = "1.3", features = ["shell-open", "window-close", "window-hide", "window-maximize", "window-minimize", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.28.0", features = ["full"] }
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
[features]
custom-protocol = ["tauri/custom-protocol"]

More context can be gotten from discord -> https://discord.com/channels/616186924390023171/1105525711453827152

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@FabianLars, that is a very good description of the behavior. simconnect-sdk’s build.rs normally links the DLL, and that works fine in typical cases like cargo run. However, something in Tauri breaks that. I’m still trying to figure out what and why, but it’s on my TODO list to investigate at some point.

Btw, Tauri release builds also require the DLL to be specified as a resource.