wry icon indicating copy to clipboard operation
wry copied to clipboard

Reloading webview crashes in an edge case [macOS]

Open morajabi opened this issue 1 year ago • 2 comments

Describe the bug I have a custom menu item to reload webview contents (in tauri). It uses following code:

window.with_webview(|webview| {
          #[cfg(target_os = "macos")]
          unsafe {
            let () = msg_send![webview.inner(), reload];
          }
        });

This worked fine until ~last month which started to cause a panic with this message: CleanShot 2024-01-21 at 13 20 46@2x

Steps To Reproduce I tried doing the same thing in custom_protocol example, but I can't reproduce this. Can you guide me through debugging what might cause this based on the stack trace, I'd be happy to help narrow down the issue and provide a Wry example / or move the issue to tauri.

more context: I added this code to wry example to trigger reloads which didn't panic:

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

    match event {
      Event::WindowEvent { window_id, ref event, .. } => match event {
        WindowEvent::Focused(_) => {
          #[cfg(target_os = "macos")]
          unsafe {
            let webview = _webview.webview();
            let () = msg_send![webview, reload];
          };
        }
        _ => {}
      }
      _ => {}
    }

Expected behavior To reload the app without panic.

Screenshots N/A

Platform and Versions (please complete the following information): OS: macOS 14.2.1 (23C71) Rustc: rustc 1.73.0 (cc66ad468 2023-10-03)

Additional context N/A

morajabi avatar Jan 21 '24 10:01 morajabi

Did you register any custom protocol by register_uri_scheme_protocol or register_asynchronous_uri_scheme_protocol?

Since it crash at https://github.com/tauri-apps/wry/blob/52c861bbef00f2762ae837e01b7d36fcb13cd0bc/src/wkwebview/mod.rs#L230 .. I'm suspecting the response is not exist, but I can't reproduce it either :\

pewsheen avatar Jan 24 '24 05:01 pewsheen

Did you register any custom protocol by register_uri_scheme_protocol or register_asynchronous_uri_scheme_protocol?

I haven't, but tauri registers two of them that we use I think: ipc:// and asset://.

morajabi avatar Jan 28 '24 16:01 morajabi