-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
refactor(core): use webview's URI schemes for IPC #7170
refactor(core): use webview's URI schemes for IPC #7170
Conversation
A command returning a 150MB file now takes less than 60ms to resolve. Previously: almost 50 seconds. |
Needs tauri-apps/wry#970 |
Also needs #4752 to fix the unit tests. |
We'll detect and use the custom protocol IPC on Linux if available when tauri-apps/wry#969 lands. On older webkit2gtk, we'll need to stick with the current approach (JSON :( ) |
This reverts commit da2d00b.
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: chip <chip@chip.sh>
…nto feat/ipc-custom-protocol
Co-authored-by: chip <chip@chip.sh>
we use this as a raw function instead of calling it directly
Having lurked in this thread since the PR was first made I'm quite delighted to see this merged! I have been using the alpha releases for a while now and wonder how I would go about using this new feature together with the new v2 api plugins? Naively switching over the tauri and tauri-build dependencies to use the dev branch of course creates version conflicts with the fs plugin that I use. From where should I pull in the plugins? |
The v2 branch of plugins-workspace repo https://github.com/tauri-apps/plugins-workspace/tree/v2 or from the published crates on crates.io |
On MacOS this breaks IPC using Remote Domains. Safari blocks the requests to localhost from other domains. |
I want to know how to use this new IPC?i update to v2,but the file transder between js and rust is also slow in Windows OS, Here is my [build-dependencies]
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
tauri = { version = "2.0.0-beta.13", features = ["custom-protocol"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = "0.4.31"
tokio = { version = "1.20", features = ["macros", "rt-multi-thread"] }
tauri-plugin-dialog = "2.0.0-beta.3"
tauri-plugin-http = "2.0.0-beta.3"
tauri-plugin-fs = "2.0.0-beta.3"
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"] this is my rust code: #[tauri::command]
async fn append_chunk_to_file(
window: Window,
path: String,
chunk: Vec<u8>,
end: bool,
) -> Result<(), String> {
let current_time = Local::now().time();
println!("enter rust time: {}", current_time);
println!("start{:?}", Instant::now()); //收到函数时间Instant { t: 644913.1384745s }
tokio::spawn(async move {
let mut file = OpenOptions::new()
.create(true)
.append(true)
.open(&path)
.map_err(|e| e.to_string())
.unwrap();
file.write_all(&chunk).map_err(|e| e.to_string()).unwrap();
if end {
window.emit("insert", Payload { message: path }).unwrap();
}
});
let instant = Instant::now();
println!("end{:?}", instant); //结束函数时间Instant { t: 644913.1386845s }
let current_time = Local::now().time();
println!("return time: {}", current_time);
Ok(())
} i use it in js:
It took 8 seconds to transfer a 23MB image using the above code(most time take in se and de),but @lucasfernog say A command returning a 150MB file now takes less than 60ms to resolve. Previously: almost 50 seconds. |
closes #4875
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information