[bug] unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
Opened this issue · 0 comments
louis030195 commented
Describe the bug
tauri app crashes with:
thread 'main' panicked at core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
when i call this command:
#[tauri::command]
pub async fn open_pipe_window(
app_handle: tauri::AppHandle<tauri::Wry>,
port: u16,
title: String,
) -> Result<(), String> {
// Close existing window if it exists
if let Some(existing_window) = app_handle.get_webview_window(&title) {
if let Err(e) = existing_window.destroy() {
error!("failed to destroy existing window: {}", e);
}
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
}
let window = match tauri::WebviewWindowBuilder::new(
&app_handle,
&title,
tauri::WebviewUrl::External(format!("http://localhost:{}", port).parse().unwrap()),
)
.title(title)
.inner_size(1200.0, 850.0)
.always_on_top(true)
.visible_on_all_workspaces(true)
.build()
{
Ok(window) => window,
Err(e) => {
error!("failed to create window: {}", e);
return Err(format!("failed to create window: {}", e));
}
};
// Only try to manipulate window if creation succeeded
if let Err(e) = window.set_focus() {
error!("failed to set window focus: {}", e);
}
if let Err(e) = window.show() {
error!("failed to show window: {}", e);
}
#[cfg(target_os = "macos")]
if let Err(e) = app_handle.set_activation_policy(tauri::ActivationPolicy::Accessory) {
error!("failed to set activation policy: {}", e);
}
Ok(())
}
note that this is non deterministic :/
most of the time it works, 5-10% of the time it crashes :(
Reproduction
n/a
Expected behavior
No response
Full tauri info
output
(base) louisbeaumont@MacBook-Pro-2:~/Documents/screenpipe/screenpipe-app-tauri$ bun tauri info
$ tauri info
WARNING: Only one package manager should be used, but found bun and npm.
Please remove unused package manager lock files, will use bun for now!
[✔] Environment
- OS: Mac OS 15.1.0 arm64 (X64)
✔ Xcode Command Line Tools: installed
✔ rustc: 1.83.0 (90b35a623 2024-11-26)
✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 20.9.0
- pnpm: 9.14.4
- yarn: 1.22.19
- npm: 10.1.0
- bun: 1.1.38
- deno: deno 2.0.2
[-] Packages
- tauri 🦀: 2.1.1
- tauri-build 🦀: 2.0.3
- wry 🦀: 0.47.2
- tao 🦀: 0.30.8
- tauri-cli 🦀: 1.6.2
- @tauri-apps/api : 2.1.1
- @tauri-apps/cli : 2.1.0
[-] Plugins
- tauri-plugin-store 🦀: 2.2.0
- @tauri-apps/plugin-store : 2.2.0
- tauri-plugin-deep-link 🦀: 2.2.0
- @tauri-apps/plugin-deep-link : 2.2.0
- tauri-plugin-autostart 🦀: 2.0.0
- @tauri-apps/plugin-autostart : not installed!
- tauri-plugin-os 🦀: 2.0.0
- @tauri-apps/plugin-os : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-fs 🦀: 2.0.0
- @tauri-apps/plugin-fs : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-notification 🦀: 2.0.0
- @tauri-apps/plugin-notification : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-updater 🦀: 2.0.1
- @tauri-apps/plugin-updater : 2.0.0 (outdated, latest: 2.3.0)
- tauri-plugin-dialog 🦀: 2.0.0
- @tauri-apps/plugin-dialog : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-http 🦀: 2.0.0
- @tauri-apps/plugin-http : 2.2.0
- tauri-plugin-shell 🦀: 2.0.0
- @tauri-apps/plugin-shell : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-global-shortcut 🦀: 2.0.0
- @tauri-apps/plugin-global-shortcut : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-cli 🦀: 2.0.0
- @tauri-apps/plugin-cli : 2.0.0 (outdated, latest: 2.2.0)
- tauri-plugin-single-instance 🦀: 2.0.0
- @tauri-apps/plugin-single-instance : not installed!
- tauri-plugin-process 🦀: 2.0.0
- @tauri-apps/plugin-process : 2.0.0 (outdated, latest: 2.2.0)
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../out
- devUrl: http://localhost:3000/
- framework: React (Next.js)
- bundler: Webpack
Stack trace
No response
Additional context
my users run a bunch of nextjs apps that i embed in tauri webviews that's why the localhost thing