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] WebviewWindowBuilder.data_store_identifier crashes #12843

Open
Simon-Laux opened this issue Feb 28, 2025 · 6 comments · May be fixed by #12900
Open

[bug] WebviewWindowBuilder.data_store_identifier crashes #12843

Simon-Laux opened this issue Feb 28, 2025 · 6 comments · May be fixed by #12900
Assignees
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@Simon-Laux
Copy link
Contributor

Describe the bug

thread 'main' panicked at /Users/bb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/objc2-foundation-0.3.0/src/uuid.rs:26:5:
invalid message send to -[__NSConcreteUUID initWithUUIDBytes:]: expected argument at index 0 to have type code '*', but found '[16C]'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

likely a bug in wry, I'll investigate it soon.

Reproduction

WebviewWindowBuilder::new(
 &app,
 "my_window_label", 
 WebviewUrl::External(Url::from_str("about:blank").unwrap())
).data_store_identifier([0; 16]).build()?;

you need to be on macOS as this feature is apple/WKWebview specific.

Expected behavior

no crash

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.3.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.85.0 (4d91de4e4 2025-02-17)
    ✔ cargo: 1.85.0 (d73d2caf9 2024-12-31)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.12.2
    - pnpm: 9.15.4
    - yarn: 1.22.22
    - npm: 10.5.0
    - bun: 1.1.34
    - deno: deno 2.1.10

[-] Packages
    - tauri 🦀: git+https://github.com/Simon-Laux/tauri?branch=deltachat-branch#2fb1cb92da946c14a559b552eceafd0ec53c632f (2.2.5)
    - tauri-build 🦀: git+https://github.com/Simon-Laux/tauri?branch=deltachat-branch#2fb1cb92da946c14a559b552eceafd0ec53c632f (2.0.5)
    - wry 🦀: git+https://github.com/Simon-Laux/wry?branch=deltachat-branch#3b11eb79fada8ce94c37c134765045226b5377a2 (0.50.0)
    - tao 🦀: 0.32.2
    - tauri-cli 🦀: 2.2.7
    - @tauri-apps/api : 2.2.0 (outdated, latest: 2.3.0)
    - @tauri-apps/cli : 2.0.5 (outdated, latest: 2.3.0)

(rest is not relevant, also my branch here is basically dev branch at 955832e56b487e0307b50041d6507e218dc1bce4 with some unrelated changes (merged in 2 of my prs))

Stack trace


Additional context

No response

@Simon-Laux Simon-Laux added status: needs triage This issue needs to triage, applied to new issues type: bug labels Feb 28, 2025
@FabianLars FabianLars assigned FabianLars and unassigned FabianLars Feb 28, 2025
@Simon-Laux
Copy link
Contributor Author

So this could be an issue that's new with macOS 15? Or I need a better example?
I'll make one reproducible example with only wry directly later.

@FabianLars
Copy link
Member

i don't think it's about the macos version. either it never worked or it's related to the objc2 (the objective-c rust bindings) updates 🤔

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Feb 28, 2025

New example based with wry:

use tao::{
    event::{Event, WindowEvent},
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};
use wry::{
    WebViewBuilder,
};

#[cfg(target_os = "macos")]
fn main() -> wry::Result<()> {
    use wry::WebViewBuilderExtDarwin;

    let event_loop = EventLoop::new();
    let window = WindowBuilder::new().build(&event_loop).unwrap();

    let builder = WebViewBuilder::new()
        .with_data_store_identifier([0; 16])
        // tell the webview to load the custom protocol
        .with_url("about:blank");

    let _w = builder.build(&window)?;

    event_loop.run(move |event, _, control_flow| {
        *control_flow = ControlFlow::Wait;

        if let Event::WindowEvent {
            event: WindowEvent::CloseRequested,
            ..
        } = event
        {
            *control_flow = ControlFlow::Exit
        }
    });
}
thread 'main' panicked at /Users/bb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/objc2-foundation-0.3.0/src/uuid.rs:26:5:
invalid message send to -[__NSConcreteUUID initWithUUIDBytes:]: expected argument at index 0 to have type code '*', but found '[16C]'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Feb 28, 2025

documentation of NSUUID::from_bytes says:

Thus, to use this method, you must currently disable encoding verification using the "disable-encoding-assertions" Cargo feature in objc2.

so I enabled the feature, but then I got a crash with even less information:

fatal runtime error: Rust cannot catch foreign exceptions
zsh: abort      cargo run

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Mar 1, 2025

use objc2::MainThreadMarker;
use objc2_foundation::NSUUID;
use objc2_web_kit::WKWebsiteDataStore;

fn main() {
    let mtm = MainThreadMarker::new().unwrap();
    let bytes = NSUUID::new().as_bytes();
    println!("{bytes:?}");
    let identifier = NSUUID::from_bytes(bytes);
    unsafe {
        WKWebsiteDataStore::dataStoreForIdentifier(&identifier, mtm);
    }
}

works, when "disable-encoding-assertions" feature is added to objc2. So looks like that feature is just missing in wry and that my [0u8;16] uuid was invalid.

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Mar 1, 2025

I'll make a pr soon, I'll combine it with adding two missing apis (get all data store ids, delete data store by id) that I need.
So you may assign me to this issue, if that works without giving me gh permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants