getsentry / sentry-unity

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

Application crashes on Nintendo Switch at start #1861

Open mora-hugo opened 3 days ago

mora-hugo commented 3 days ago

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which version of the SDK? 2.2.2

How did you install the package? (Git-URL, Assetstore) Git URL

Which version of Unity? 2022.3.22f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows? Nintendo Switch

Steps to Reproduce

I tried integrating the Sentry Unity package into my Unity project. It works well in most cases, but it doesn't work on Nintendo Switch. The application crashes every time it launches on the Switch. A similar issue was supposed to be fixed (#1804), but I'm still experiencing the problem.

We also created a new empty project with the latest version of Sentry, and we're experiencing the same issue.

Expected Result

The game should launch correctly without crashing.

Actual Result

The game crashes every time it launches on Nintendo Switch.

Any logs or screenshots

I have attempted to put this options in my runtime or in my build configuration :


options.CacheDirectoryPath = null;
options.TracesSampleRate = 0.0f;
options.AutoSessionTracking = false;
options.DisableFileWrite = true;

I tried to disable Sentry via the editor window (unchecked the "Enable Sentry" checkbox) but the problem persist.

There is the retrieved crash dump from the Switch.

    nnSdk.nss!nn::diag::detail::VAbortImpl (0x50E0A1B5E0)   Unknown
    nnSdk.nss!nn::diag::detail::AbortImpl (0x50E0A1B694)    Unknown
    nnSdk.nss!nn::fs::CreateDirectory (0x50E0A352C8)    Unknown
    GameAssembly.nss!LocalFileSystemSwitch::CreateAsDir(FileEntryData& data) Line 611 (0x50D135A528)    C++
    GameAssembly.nss!CreateDirectory(core::basic_string_ref<char> pathName) Line 240 (0x50D106F3F8) C++
    GameAssembly.nss!CreateDirectoryRecursive(core::basic_string_ref<char> pathName) Line 227 (0x50D1075384)    C++
    GameAssembly.nss!GetPersistentDataPathApplicationSpecific() Line 230 (0x50D0A39AFC) C++
    GameAssembly.nss!Application_Get_Custom_PropPersistentDataPath() Line 13306 (0x50D0D8FB5C)  C++
>   GameAssembly.nss!ApplicationAdapter_get_PersistentDataPath_m92572A6540B53DD6839F39A78CA70CEE4D14AEE6(ApplicationAdapter_t0E038AD4E1337C07D9FB164225C2198309883E15* __this, const MethodInfo* method) Line 37546 (0x50D6CD563C)  C++
    GameAssembly.nss!ScriptableSentryUnityOptions_ToSentryUnityOptions_mB55F70DDF836A8378AB0A04EC58DB64D7206FF38(ScriptableSentryUnityOptions_t42C32DD4F7FE9DCB347EE5EC2E490857B3046700* __this, bool ___0_isBuilding, Il2CppObject* ___1_unityInfo, Il2CppObject* ___2_application, const MethodInfo* method) Line 21922 (0x50D6C9A548)    C++
    GameAssembly.nss!ScriptableSentryUnityOptions_LoadSentryUnityOptions_m384D6FCE79B3D084F7B5210D97DD7D9BFC7F8522(Il2CppObject* ___0_unityInfo, const MethodInfo* method) Line 21553 (0x50D6C991F0)    C++
    GameAssembly.nss!SentryInitialization_Init_m8AB1090DE1B27028A913FB4655549B1C2C43B201(const MethodInfo* method) Line 1117 (0x50D5ABB674) C++
    GameAssembly.nss!il2cpp::vm::Runtime::InvokeWithThrow(const MethodInfo* method, void* obj, void** params) Line 608 (0x50D06C1628)   C++
    GameAssembly.nss!il2cpp::vm::Runtime::Invoke(const MethodInfo* method, void* obj, void** params, Il2CppException** exc) Line 594 (0x50D06C1578) C++
    GameAssembly.nss!scripting_method_invoke(ScriptingMethodPtr method, ScriptingObjectPtr object, ScriptingArguments& arguments, ScriptingExceptionPtr* exception, bool convertArgs) Line 290 (0x50D128FAC0)   C++
    GameAssembly.nss!ScriptingInvocation::Invoke(ScriptingExceptionPtr* exception, bool convertArguments) Line 298 (0x50D129973C)   C++
    GameAssembly.nss!RuntimeInitializeOnLoadManager::Execute(const RuntimeInitializeOnLoadCall& runtimeInitializeOnLoadCall) Line 253 (0x50D0D2A594)    C++
    GameAssembly.nss!RuntimeInitializeOnLoadManager::ExecuteInitializeOnLoad(RuntimeInitializeLoadType loadType) Line 238 (0x50D0D2A4E0)    C++
    GameAssembly.nss!CallbackArray::Invoke() Line 331 (0x50D0834E6C)    C++
    GameAssembly.nss!PlayerInitEngineGraphics(bool batchmode) Line 560 (0x50D0D56740)   C++
    GameAssembly.nss!nnMain() Line 888 (0x50D134EFD4)   C++

Despite these efforts, the issue persists. For now, I have to completely remove Sentry from my project to prevent the crash. I'm not sure of the exact cause of the problem and would appreciate any assistance.

Also open to test fixes with proper instructions.

bruno-garcia commented 2 days ago

Thanks for raising this. I see you have all the right settings so this shouldn't be happening.

Looks like it comes from here: https://github.com/getsentry/sentry-unity/blob/e1ada0b6be4de65af89c2e74427fb4ee19521119/src/Sentry.Unity/Integrations/IApplication.cs#L50C41-L50C71

Which is Unity's API to get a path to persist files.

Some background: we added DisableFileWrite to make sure the SDK didn't do any file I/O that relates to writing, in particular because of Switch, using .NET's file APIs. But our understanding is that Unity's Application.persistentDataPath is only giving a path, and not using .NET's file I/O APIs under the hood and was working fine.

Related changes were:

We have a Switch devkit at the office we'll be running some tests. I can't see a way around this without us making changes to the SDK. Since it doesn't seem possible to allow you to replace IApplication in any way.

mora-hugo commented 2 days ago

Thank you a lot for your response and the information provided.

We'll keep an eye on your coming tests.

bruno-garcia commented 2 days ago

Thank you for being so patient. We'll get to it as soon as we can. Unfortunately some folks are off so we won't be able to tackle this in the next few days but a fix is coming!