getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
209 stars 52 forks source link

IL2CPP build preprocess overrides all IL2CPP arguments #965

Closed michalpypek closed 2 years ago

michalpypek commented 2 years ago

Environment

How do you use Sentry? Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?) not relevant Which version of the SDK? 0.22 How did you install the package? (Git-URL, Assetstore) git-url, not relevant Which version of Unity? 2021.3.9f1, not relevant Is this happening in Unity (editor) or on a player like Android, iOS, Windows? any il2cpp build

Steps to Reproduce

The IL2CPP build preprocessor: https://github.com/getsentry/sentry-unity/blob/main/src/Sentry.Unity.Editor/Il2CppOption.cs Overrides all additional IL2CPP arguments. A project like the one my company is making requires the default --maximum-recursive-generic-depth=7 to be increased. Sentry's preprocess overrides it with it's own line. Please change it to add the arguments you need and override everything:

Something like:

public void OnPreprocessBuild(BuildReport report)
        {
            var arguments = PlayerSettings.GetAdditionalIl2CppArgs() + " --emit-source-mapping";
            Debug.Log($"Setting additional IL2CPP arguments = '{arguments}' for platform {report.summary.platform}");
            PlayerSettings.SetAdditionalIl2CppArgs(arguments);
        }

This can be worked around by adding a preprocessor that runs after Sentry's, but it's not exactly straightforward to find this issue.

Any logs or screenshots

09-08 20:47:44.662: E/Unity(22299): NotSupportedException: IL2CPP encountered a managed type which it cannot convert ahead-of-time. The type uses generic or array types which are nested beyond the maximum depth which can be converted.   Consider increasing the --maximum-recursive-generic-depth=7 argument
bitsandfoxes commented 2 years ago

Hey @michalpypek. Thanks for raising this and it makes sense to me. Will fix it.