tauri-apps/wry

Reloading webview crashes in an edge case [macOS]

morajabi opened this issue · 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

Did you register any custom protocol by register_uri_scheme_protocol or register_asynchronous_uri_scheme_protocol?

Since it crash at

let () = msg_send![task, didReceiveResponse: response];
.. I'm suspecting the response is not exist, but I can't reproduce it either :\

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://.