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

[bug] tauri dev fails silently when calling autocxx binding #7148

Closed
Raphiiko opened this issue Jun 6, 2023 · 2 comments
Closed

[bug] tauri dev fails silently when calling autocxx binding #7148

Raphiiko opened this issue Jun 6, 2023 · 2 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@Raphiiko
Copy link
Contributor

Raphiiko commented Jun 6, 2023

Describe the bug

First of all: I am not entirely sure if this is an issue with Tauri, autoccx, or just me using something incorrectly. However as tauri dev seems to fail silently for no apparent reason, this seemed like the logical place to ask first. Apologies for what is probably a very specific case, but I have not been able to find something more generic. Let me explain the context:

I am interfacing with openvr through autocxx. This works fine standalone. When I combine this into a Tauri project, I can tauri build and I can cd src-tauri and cargo run from there just fine too. The application works fine as I would expect.

However, when I use tauri dev, it exits without any error messages right after it's done compiling the Rust code:
image

This only happens when referencing some of the function bindings generated by autocxx. It does not matter whether the function is actually called, not even if it's referenced in a code path that actually runs. If the code exists, tauri dev seems to exit silently after compiling.

Reproduction

I've set up a clean Tauri project, with a single function binding using autocxx, which triggers this issue:

Here is how it can be reproduced (on Windows):

  1. Make sure you have LLVM installed and LIBCLANG_PATH set, as this is required for autocxx.

  2. Clone the example: git clone --recursive https://github.com/Raphiiko/tauri-autocxx-reproduction (Don't forget --recursive, as it references openvr as a git submodule).

  3. Change directory into the example: cd tauri-autocxx-reproduction

  4. Install npm dependencies: npm install

  5. Run tauri dev, and notice how it exits silently after it's done building.

At this point, you can also run cd src-tauri followed by cargo run, to see how it does function when not using tauri dev.

Once you comment out line 22 in src-tauri/src/main.rs, you will see that tauri dev starts working correctly again:

// Note that this command or function is never called. It is only here to demonstrate the issue.
#[tauri::command]
async fn unsafe_function() {
    unsafe {
        ffi::vr::VR_Shutdown(); //L22: When you comment this out, `tauri dev` works fine
    }
}

Expected behavior

I would expect tauri dev to function normally, like cargo run, or to at least produce an error to give me context on why it's failing.

Platform and versions

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.37
    ✔ MSVC:
        - Visual Studio Build Tools 2019
        - Visual Studio Build Tools 2022
        - Visual Studio Community 2022
    ✔ rustc: 1.67.0 (fc594f156 2023-01-24)
    ✔ Cargo: 1.67.0 (8ecd4f20a 2023-01-10)
    ✔ rustup: 1.25.1 (bb60b1e89 2022-07-12)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.13.0
    - yarn: 1.22.19
    - npm: 8.19.3

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:4201/

Stack trace

-

Additional context

Running tauri dev -v for verbose logging seems to give no additional info regarding what happens.

@Raphiiko Raphiiko added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jun 6, 2023
@FabianLars
Copy link
Member

I wonder if it's somehow similar to #6924 🤔

@Raphiiko
Copy link
Contributor Author

Raphiiko commented Jun 7, 2023

I wonder if it's somehow similar to #6924 🤔

It indeed looks very similar! Adding one of the dlls to src/tauri and referencing it as a resource in tauri.conf.json seems to fix tauri dev exiting abruptly.

I think with this I've got enough to be able to go from here.
Thanks a lot for the info @FabianLars :)

Closing

@Raphiiko Raphiiko closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants