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

Plugin causing another instance to launch on macOS #6

Open
jeffgardnerdev opened this issue Aug 21, 2023 · 10 comments
Open

Plugin causing another instance to launch on macOS #6

jeffgardnerdev opened this issue Aug 21, 2023 · 10 comments
Assignees

Comments

@jeffgardnerdev
Copy link

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
Copy link
Author

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"

@hellno
Copy link

hellno commented Aug 22, 2023

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
Copy link

hellno commented Sep 2, 2023

@timfish do you have any insights on this? 😊

@timfish
Copy link
Owner

timfish commented Sep 2, 2023

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

@timfish
Copy link
Owner

timfish commented Sep 3, 2023

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 timfish self-assigned this Sep 3, 2023
@jeffgardnerdev
Copy link
Author

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?

@timfish
Copy link
Owner

timfish commented Sep 5, 2023

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.

@jeffgardnerdev
Copy link
Author

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
Copy link
Author

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.

@timfish
Copy link
Owner

timfish commented Sep 7, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants