sentry-tauri icon indicating copy to clipboard operation
sentry-tauri copied to clipboard

Plugin causing another instance to launch on macOS

Open jeffgardnerdev opened this issue 2 years ago • 10 comments

I am using the sentry-tauri plugin and my code follows the example in examples/basic-app. The plugin appears to be working properly during development with no issues, but when running tauri build and opening the resulting binary on macOS, a second instance of the app starts a few seconds after opening the app. I have narrowed the issue down to this plugin--when I comment out the .plugin(sentry_tauri::plugin()) line from the Tauri builder in main() and rebuild, the issue is gone. Any ideas?

jeffgardnerdev avatar Aug 21 '23 21:08 jeffgardnerdev

Correction: it's actually not commenting the .plugin(sentry_tauri::plugin()) line that fixes it, this one is the only one that needs to be commented: let _guard = sentry_tauri::minidump::init(&client);

I am using: sentry-tauri = "0.2" rust-version = "1.67.1" tauri = "1.4.1" tauri-build = "1.4.0"

jeffgardnerdev avatar Aug 21 '23 22:08 jeffgardnerdev

Running into exactly the same issue. Removing the _guard line fixes the double launch. The plugin is still catching errors and publishing them to sentry. Is there a security or performance impact when removing the guard?

hellno avatar Aug 22 '23 07:08 hellno

@timfish do you have any insights on this? 😊

hellno avatar Sep 02 '23 14:09 hellno

Sorry this dropped out of my notifications and got forgotten. I'll take a look!

timfish avatar Sep 02 '23 23:09 timfish

Minidump support is via sentry-rust-minidump:

sentry_rust_minidump::init starts the current executable again with an argument that causes it to start in crash reporter mode. In this mode it waits for minidump notification from the main app process and handles writing and sending of the minidump file as an attachment to Sentry.

I guess the extra instance is something to do with that not working correctly.

If I start the app via the internal executable (ie. ./tauri-test-app.app/Contents/MacOS/tauri-test-app) I don't get the duplicate instance so I guess it's something to do with how macOS starts app bundles.

timfish avatar Sep 03 '23 11:09 timfish

Thanks @timfish! For now I've removed the _guard line and it seems to still publish to sentry, can you comment on the implications of that line being missing?

jeffgardnerdev avatar Sep 05 '23 15:09 jeffgardnerdev

That line enables minidump support which is for native crashes that are not Rust panics. This will cover crashes caused by non-Rust native code or unsafe Rust that causes segmentation faults.

timfish avatar Sep 05 '23 15:09 timfish

FYI I had commented out that _guard line and haven't been too worried about it, but today I had an issue in my app that was causing crashes and nothing was getting reported to sentry. I noticed that when I uncommented the _guard line, the crash did get sent to sentry. The crash was caused by a Rust panic. Is this what you would expect? I was under the impression that it would still report but it doesn't seem to.

jeffgardnerdev avatar Sep 07 '23 20:09 jeffgardnerdev

Update: the reason the Rust panic wasn't getting reported was because I was doing this: let _ = sentry::init(( ... instead of this: let _client = sentry::init(( ...

When I update the variable name to _client the Rust panic is reported, but not the native crash. When I update the variable name to client uncomment the _guard line both the Rust panic and the native crash are reported as two separate events.

jeffgardnerdev avatar Sep 07 '23 21:09 jeffgardnerdev

Yep one of the few foot-guns with rust that has caught me out a few times. If you name a variable _ it will be dropped immediately!

timfish avatar Sep 07 '23 22:09 timfish