FAQ - Frequently Asked Questions #1336
Replies: 41 comments 90 replies
-
It seems JSON is used as the default IPC (inter-process communication) format between the web and rust layer. In applications with many messages being passed, especially when the messages contain a lot of data, this could potentially be a hit on performance due to the time spent serializing the data on both sides. Would it be feasible to make the default a more efficiently-(de)serialized format such as bincode, capnproto, flatbuffers etc? |
Beta Was this translation helpful? Give feedback.
-
How can I emit events from the backend to the webview from a separate thread? This is for an audio application that changes its state in the audio thread and needs to update the UI accordingly. fn ready(&self, webview: &mut Webview) {
let mut mut_window = webview.as_mut();
std::thread::spawn(move || {
thread::sleep_ms(3000);
emit(&mut mut_window, "rust-event", Some("Hello".to_string())).unwrap();
});
} This panics because the webview has already been dropped when emit triggers. |
Beta Was this translation helpful? Give feedback.
-
Is there currently a way to keep the process running after the window is closed by a user? I would think this would be basically an Essentially the use case would be after the window is closed by the user and no longer rendered, background tasks can be ran to do some housekeeping tasks with Rust like cleanup or logging or whatever is needed before the process fully exits. |
Beta Was this translation helpful? Give feedback.
-
When we are making a web app and also a tauri app with the same codebase is there an easy way to tell when the app is running in desktop with tauri and when it is running on the web? thank you |
Beta Was this translation helpful? Give feedback.
-
Is auto update supported in Tauri Apps? how does that work or how will it work? |
Beta Was this translation helpful? Give feedback.
-
Hiya, |
Beta Was this translation helpful? Give feedback.
-
CLI App? I remember there being instructions for making our own CLI app with tauri, i cant find the docs for that. Is there a way to make a CLI app that accepts command line arguments using Tauri? |
Beta Was this translation helpful? Give feedback.
-
For which browsers the javascript code should be polyfilled? I know IE11 is not used. Will the webview support esnext or es2020 code? |
Beta Was this translation helpful? Give feedback.
-
Got a two-fold: 1: Is Tauri GPU-accelerated? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
When setting decorations to false, I hope to have the ability to preserve borders and shadows It seems a bit difficult to make window shadows and borders in webview |
Beta Was this translation helpful? Give feedback.
-
Cannot use
and a blank page with why It cannot find index.html? |
Beta Was this translation helpful? Give feedback.
-
I'm still new to rust/tauri so bear with me. I'd like to be able to modify the state, but I can't find a way to set the underlying state as mutable: // game definition:
pub struct GameState {
// stuff
}
impl GameState {
pub fn reset(&mut self) {
// do stuff
}
}
#[tauri::command]
fn new_game(state: tauri::State<game::GameState>) {
state.reset(); // error (cannot borrow data in a dereference of `tauri::State<'_, game::GameState>` as mutable)
} Error message:
Is there a way to do this? Or should we consider state as immutable? If state is immutable, how do we create new state? |
Beta Was this translation helpful? Give feedback.
-
How to enable dev tool (ctrl+shift+i) in production build? |
Beta Was this translation helpful? Give feedback.
-
Can I use VueJs/Vuex dev tools while developing my Quasar application in Tauri? |
Beta Was this translation helpful? Give feedback.
-
How do I listen for routing changes in the WebView? |
Beta Was this translation helpful? Give feedback.
-
Can I create a micro service architecture with tauri? What I would like to achieve it is to have for example a repository for file system manager written in tauri (with functions written in rust that interact with os fs and web UI), which I can then embed in another tauri application in another repository, let's call it If not, I'd say that would be a good feature to have :) |
Beta Was this translation helpful? Give feedback.
-
Hi! What's the best way to implement "Check for updates" button that will trigger auto-updater? |
Beta Was this translation helpful? Give feedback.
-
How can I reduce the number of auxiliary processes tauri launch? I was able to do so in Electron when trying to reduce memory footprint, would like to do the same with tauri. |
Beta Was this translation helpful? Give feedback.
-
I would like to get the size of the taskbar, is it possible? |
Beta Was this translation helpful? Give feedback.
-
Hi! I am using tauri with sveltekit. One issue that is quite annoying is how errors are displayed: as you can see, there is no stack trace and it's very hard to find where the error is coming from. (in this case it's a simple 'throw' inside the main page's <script> tag) is this a known issue? maybe I should configure somethings more that just enabling source maps? |
Beta Was this translation helpful? Give feedback.
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
What will happen if my command handler panics? |
Beta Was this translation helpful? Give feedback.
-
Has there been any updates on data sharing the between backend and frontend for big files like images, sound or video? |
Beta Was this translation helpful? Give feedback.
-
I managed to get register_uri_scheme_protocol working fine.
but either blocks the main rendering thread. Is there any better approach to this? |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
Hi! I have already seen the documents about Window, but I couldn't find a feature that is similar to Electron.I might have missed it in the documentation, and if so, I would appreciate it if you could point me in the right direction. If tauri dosen't support this, is there possibly another way to workaround and take snapshot for a window? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi! Is there a I have to spawn a async task to do some network functions. A I tried I then tried What I have as a workaround is spawn the aysnc task in the tauri::Builder::default()
.plugin(tauri_plugin_window::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init())
.invoke_handler(tauri::generate_handler![
send_text_message,
send_updated_profile,
request_available_peers
])
.manage(sender) // manage sender so I can send messages to network_client in commands
.setup(move |app| {
let _ = build_system_tray(app.app_handle());
let handle = app.app_handle().clone();
tauri::async_runtime::spawn(async move {
thread::sleep(Duration::from_secs(5));
let mut network_client = NetworkClient::new(receiver, keypair);
network_client.listen(handle).await;
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
Ok(()) It works but I would not call it a solution. Are there better approaches to do this? |
Beta Was this translation helpful? Give feedback.
-
What are the rules for lookup of For example, I'd like a dir structure as follows. Would it work?
where Tauri and warp_server share both the javascript and the core library logic. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to "catch" a failed command (a #[tauri::command]
fn failable() -> Result<(), &str> {
Err("owo")
} When it fails, the JavaScript Currently to invoke a command (when front uses Rust) we need use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])] // tauri v2: core; tauri v1: tauri
pub async fn invoke(cmd: &str, args: JsValue) -> JsValue;
} ... but as we can see here it returns a So... is it possible to handle command error when frontend uses Rust? |
Beta Was this translation helpful? Give feedback.
-
We want to start collecting your frequently asked questions! So ask away and we will do our best to answer them. After a while we will bring the most frequently upvoted questions back to the website and make special care that we answer the questions to the best of our ability.
So write a question, upvote other people's questions, and try to answer questions!
Beta Was this translation helpful? Give feedback.
All reactions