tauri: [bug] [alpha.21] [mac] Segfaults on calls to listen from .app file

Describe the bug

If listen from @tauri-apps/api/event is called from production binary (.app file) it consistently segfault on MacOS 12.6. This is a new regression, not present in previous alpha releases.

Reproduction

yarn create tauri-app --alpha

Add this to App.tsx:

import { listen } from '@tauri-apps/api/event';
import { useEffect } from 'react';

function App()

useEffect(() => {
  listen('any-event', () => {});
}. []);

yarn tauri build

And then open the generated .app file.

Expected behavior

listen allows to listen to tauri events

Full tauri info output

[✔] Environment
    - OS: Mac OS 12.6.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.72.1 (d5c2e9c34 2023-09-13)
    ✔ cargo: 1.72.1 (103a7ff2e 2023-08-15)
    ✔ rustup: 1.26.0 (2023-04-05)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 18.19.0
    - yarn: 1.22.19
    - npm: 10.2.3

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.20
    - tauri-build [RUST]: 2.0.0-alpha.13
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.24.0
    - @tauri-apps/api [NPM]: 2.0.0-alpha.14
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.20

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               mac-icon [79433]
Path:                  /Users/USER/*/mac-icon.app/Contents/MacOS/mac-icon
Identifier:            icon.mac.tauri
Version:               0.0.0 (20240119.203617)
Code Type:             X86-64 (Native)
Parent Process:        zsh [77371]
Responsible:           Terminal [44798]
User ID:               502

Date/Time:             2024-01-19 14:43:25.9471 -0600
OS Version:            macOS 12.6 (21G115)
Report Version:        12
Anonymous UUID:        9CD6BFD0-291F-1687-1518-E40179CA391F


Time Awake Since Boot: 22000000 seconds

System Integrity Protection: disabled

Crashed Thread:        0  main  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [79433]

VM Region Info: 0 is not in any region.  Bytes before following region: 4301783040
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      100680000-100cc4000    [ 6416K] r-x/r-x SM=COW  ...acOS/mac-icon

Thread 0 Crashed:: main Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib               	    0x7ff80b00c592 lookUpImpOrForward + 60
1   libobjc.A.dylib               	    0x7ff80b00bf9b _objc_msgSend_uncached + 75
2   WebKit                        	    0x7ff90fb51698 -[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:] + 117
3   WebKit                        	    0x7ff90fb50be7 -[WKWebView evaluateJavaScript:completionHandler:] + 100
4   mac-icon                      	       0x1009e5927 objc_exception::try_no_ret::try_objc_execute_closure::h229e5ff0e7a86d9e + 103
5   mac-icon                      	       0x100a7ddf2 RustObjCExceptionTryCatch + 18
6   mac-icon                      	       0x1009e6142 objc_exception::try::ha8c28b1ce4d5b0e8 + 114
7   mac-icon                      	       0x1009e3a8c objc::message::platform::send_unverified::hb723dd21dcab4552 + 108
8   mac-icon                      	       0x1009dd7bf wry::wkwebview::InnerWebView::eval::h4eda88edaea374e5 + 1103
9   mac-icon                      	       0x1009eb1c1 wry::WebView::evaluate_script::h87a0738e821d4264 + 17
10  mac-icon                      	       0x1007e2f5e tauri_runtime_wry::handle_user_message::hed559859a457a826 + 3406
11  mac-icon                      	       0x1007e203e tauri_runtime_wry::send_user_message::h9a923e69a9801323 + 158
12  mac-icon                      	       0x1006efc62 tauri::window::Window$LT$R$GT$::listen_js::hba76b40c5990a2dc + 658
13  mac-icon                      	       0x1007a92d3 tauri::event::plugin::init::_$u7b$$u7b$closure$u7d$$u7d$::hdd47c6b7002d441e + 1379
14  mac-icon                      	       0x1007ae359 _$LT$tauri..plugin..TauriPlugin$LT$R$C$C$GT$$u20$as$u20$tauri..plugin..Plugin$LT$R$GT$$GT$::extend_api::h0ddc7a65dd1e2aa9 + 57
15  mac-icon                      	       0x1007aa558 tauri::plugin::PluginStore$LT$R$GT$::extend_api::h356c962ece1d8929 + 152
16  mac-icon                      	       0x100778930 tauri::manager::AppManager$LT$R$GT$::extend_api::h3a9b47345fe7f485 + 192
17  mac-icon                      	       0x1006ed3aa tauri::window::Window$LT$R$GT$::on_message::h4ba881b85e297282 + 4922
18  mac-icon                      	       0x1006eba69 tauri::ipc::protocol::get::_$u7b$$u7b$closure$u7d$$u7d$::h2da9f37d5cbef5bf + 3545
19  mac-icon                      	       0x1007d25ca tauri::manager::window::WindowManager$LT$R$GT$::prepare_pending_window::_$u7b$$u7b$closure$u7d$$u7d$::h13b9f731d912b9b6 + 74
20  mac-icon                      	       0x10086bf9d tauri_runtime_wry::create_webview::_$u7b$$u7b$closure$u7d$$u7d$::h223c7771ed0ddd85 + 157
21  mac-icon                      	       0x1009db163 wry::wkwebview::InnerWebView::new_ns_view::start_task::ha80376615b74ba3f + 5795
22  WebKit                        	    0x7ff90fc45f69 WebKit::WebURLSchemeHandlerCocoa::platformStartTask(WebKit::WebPageProxy&, WebKit::WebURLSchemeTask&) + 79
23  WebKit                        	    0x7ff90fdebec3 WebKit::WebURLSchemeHandler::startTask(WebKit::WebPageProxy&, WebKit::WebProcessProxy&, WTF::ObjectIdentifier<WebCore::PageIdentifierType>, WebKit::URLSchemeTaskParameters&&, WTF::CompletionHandler<void (WebCore::ResourceResponse const&, WebCore::ResourceError const&, WTF::Vector<unsigned char, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&)>&&) + 1613
24  WebKit                        	    0x7ff90fdeb840 WebKit::WebPageProxy::startURLSchemeTaskShared(WTF::Ref<WebKit::WebProcessProxy, WTF::RawPtrTraits<WebKit::WebProcessProxy> >&&, WTF::ObjectIdentifier<WebCore::PageIdentifierType>, WebKit::URLSchemeTaskParameters&&) + 122
25  WebKit                        	    0x7ff90fdeb7a7 WebKit::WebPageProxy::startURLSchemeTask(WebKit::URLSchemeTaskParameters&&) + 39
26  WebKit                        	    0x7ff91014058d WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 95643
27  WebKit                        	    0x7ff90fbf262d IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 367
28  WebKit                        	    0x7ff90fe01551 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 31
29  WebKit                        	    0x7ff90fbe1605 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 221
30  WebKit                        	    0x7ff90fbe0fb3 IPC::Connection::dispatchIncomingMessages() + 479
31  JavaScriptCore                	    0x7ff823b0b4df WTF::RunLoop::performWork() + 431
32  JavaScriptCore                	    0x7ff823b0bfca WTF::RunLoop::performWork(void*) + 26
33  CoreFoundation                	    0x7ff80b23f17b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
34  CoreFoundation                	    0x7ff80b23f0e3 __CFRunLoopDoSource0 + 180
35  CoreFoundation                	    0x7ff80b23ee5d __CFRunLoopDoSources0 + 242
36  CoreFoundation                	    0x7ff80b23d878 __CFRunLoopRun + 892
37  CoreFoundation                	    0x7ff80b23ce3c CFRunLoopRunSpecific + 562
38  HIToolbox                     	    0x7ff813eec5e6 RunCurrentEventLoopInMode + 292
39  HIToolbox                     	    0x7ff813eec34a ReceiveNextEventCommon + 594
40  HIToolbox                     	    0x7ff813eec0e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
41  AppKit                        	    0x7ff80dc76fad 0x7ff80dc38000 + 257965
42  AppKit                        	    0x7ff80dc7566a 0x7ff80dc38000 + 251498
43  AppKit                        	    0x7ff80dc67d19 0x7ff80dc38000 + 195865
44  mac-icon                      	       0x1007aff79 objc_exception::try_no_ret::try_objc_execute_closure::hbb8be2f373ce1ed9 + 41
45  mac-icon                      	       0x100a7ddf2 RustObjCExceptionTryCatch + 18
46  mac-icon                      	       0x10084fafd objc::message::platform::send_unverified::hb7c8309c4654c38f + 109
47  mac-icon                      	       0x100823f67 tao::platform_impl::platform::event_loop::EventLoop$LT$T$GT$::run::hf464bcb4ce63fb4d + 487
48  mac-icon                      	       0x10080095f _$LT$tauri_runtime_wry..Wry$LT$T$GT$$u20$as$u20$tauri_runtime..Runtime$LT$T$GT$$GT$::run::h35ac1eddd4aa8b94 + 239
49  mac-icon                      	       0x100898135 mac_icon::main::h9577ab582d143a1d + 13829
50  mac-icon                      	       0x1007b0166 std::sys_common::backtrace::__rust_begin_short_backtrace::h17c1e011f91d277f + 6
51  mac-icon                      	       0x100881c5c std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h2d0c0c02f0726713 + 12
52  mac-icon                      	       0x100b0fdaa std::rt::lang_start_internal::h4f6dde0e5153fc54 + 778
53  mac-icon                      	       0x100898d8c main + 44
54  dyld                          	       0x107d9a52e start + 462

Additional context

yarn tauri dev works fine, the behavior is only present in the fully compiled .app file.

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Dependency has not been updated yet. It should be included in the next release.

https://github.com/tauri-apps/tauri/pull/8795

This is still present in beta.2

@pewsheen Nice, I can confirm this also works on intel macs. Thanks a lot for providing an example.

@krzykro2 @Gofive For curious, are you using an Intel X86-64 Mac?

yes

@krzykro2 @Gofive For curious, are you using an Intel X86-64 Mac?

I believe I reproduced the problem on both.