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

Windows native config and logging #577

Merged
merged 22 commits into from
Mar 4, 2022
Merged

Windows native config and logging #577

merged 22 commits into from
Mar 4, 2022

Conversation

vaind
Copy link
Collaborator

@vaind vaind commented Feb 22, 2022

#skip-changelog

@bruno-garcia
Copy link
Member

Good news?

image

@vaind vaind force-pushed the feat/windows-tests branch 2 times, most recently from fe806ea to ab39fe6 Compare February 25, 2022 16:04
@vaind vaind marked this pull request as ready for review February 25, 2022 17:36
@vaind vaind force-pushed the feat/windows-tests branch 2 times, most recently from 2bec123 to af294f4 Compare February 28, 2022 13:09
Directory.Build.targets Outdated Show resolved Hide resolved
samples/unity-of-bugs/Assets/Scripts/SmokeTester.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNative.cs Outdated Show resolved Hide resolved
@@ -29,6 +30,40 @@ public static void Init(SentryUnityOptions options)
sentry_options_set_release(cOptions, options.Release);
}

if (options.Environment is not null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it not possible to add the init code in the main function of the Windows executable instead of initializing here?
This approach is different than Android and iOS and would require further clarification on the docs. i.e:

In order to provide native crash support, the Sentry SDK for Unity includes platform-specific (that is, Native) SDKs, such as Android, Apple, and Native.

By default, we initialize the native SDKs before the Unity engine itself. That means it also runs before the C# layer that relies on BeforeSceneLoad RuntimeInitializeOnLoadMethodAttribute to get initialized. This allows us to capture bugs/crashes of the engine itself, any native plugin, and anything written in C#. The setup for the native SDKs happens during build time, which is why we rely on the options being set in the Sentry editor configuration window and saved to Assets/Resources/Sentry/SentryOptions.asset. To provide a way to modify options programmatically, we've added ScriptableOptionsConfiguration to the Options Config tab in the Sentry editor window.

From: https://docs.sentry.io/platforms/unity/configuration/options/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, that would be the next PR

src/Sentry.Unity.Native/SentryNativeBridge.cs Outdated Show resolved Hide resolved
@vaind
Copy link
Collaborator Author

vaind commented Mar 1, 2022

@bruno-garcia @bitsandfoxes please have a/another look. Finally, the crash test passes, hopefully it stays so (I've rerun the workflow to be sure)

@vaind vaind mentioned this pull request Mar 1, 2022
11 tasks
}

public static void SmokeTest()
public static void InitSentry(SentryUnityOptions options, bool requireNative = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I can follow the purpose of requireNative? Could you elaborate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the call sites, there are two: one from SmokeTest() which is plain .net and doesn't require native to be configured. The other is from the crash that does require the native part.
Basically, this was originally meant to be able to run the smoke test (.net) also on Linux/Mac, but that was removed in the end so is actually not necessary per se, but may still come in handy.

Copy link
Contributor

@bitsandfoxes bitsandfoxes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing!

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the C# files and have a couple notes

samples/unity-of-bugs/Assets/Scripts/SmokeTester.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Outdated Show resolved Hide resolved
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

samples/unity-of-bugs/Assets/Scripts/SmokeTester.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Native/SentryNativeBridge.cs Show resolved Hide resolved
@bruno-garcia
Copy link
Member

@vaind looks ready to merge?

@bruno-garcia bruno-garcia changed the title Standalone crash test Windows native config and logging Mar 4, 2022
@bruno-garcia
Copy link
Member

Renamed the PR to clarify what user-facing value it adds. Smoke testing was the strategy used to validate/test the feature so removing from the title as it's a tech detail

@vaind
Copy link
Collaborator Author

vaind commented Mar 4, 2022

@vaind looks ready to merge?

Not sure if you've noticed but I've changed the crash test to use a python server instead of a powershell one. Seems to have helped. I guess I can remove the ps1 server script?

edit: done so in the latest commit.

@bruno-garcia
Copy link
Member

@vaind looks ready to merge?

Not sure if you've noticed but I've changed the crash test to use a python server instead of a powershell one. Seems to have helped. I guess I can remove the ps1 server script?

edit: done so in the latest commit.

I didn't notice. I was hoping we could stick to a single scripting language in the repo and since there's a lot of pwsh that would be the one but if that solved the problem lets go with it. HttpListener is an old bit, we can give it a stab later with a newer approach in pwsh. Or move all the way to python eventually

@vaind
Copy link
Collaborator Author

vaind commented Mar 4, 2022

I was hoping we could stick to a single scripting language

yes, me too. that's why I've tried powershell but doesn't seem to be a very good option. Seems OK to me to have a single python script for this - it's quite simple and limited in scope.

@vaind vaind merged commit 98a105e into main Mar 4, 2022
@vaind vaind deleted the feat/windows-tests branch March 4, 2022 17:08
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

Successfully merging this pull request may close these issues.

3 participants