Skip to content

Application crashes on Nintendo Switch when reporting an error via Sentry #1804

Closed

Description

@abond-sd

Environment

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

Which version of the SDK?
2.1.3

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

Which version of Unity?
2022.3.37f1

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

Steps to Reproduce

  1. Start the application on Switch
  2. Have Switch report an error via Sentry
  3. --> The application closes

Expected Result

Reporting an error should not terminate the application

Actual Result

Based on previous advice for Sentry on Switch we had already set the following in a SentryBuildTimeOptionsConfiguration class

options.CacheDirectoryPath = null;
options.AutoSessionTracking = false;

It seems like the issue is that even when the above options are set, it still tries to use TryGetPersistentInstallationId which will always crash since files & directories cannot be created on the platform.

The error log that appears in the console when it generates a dump:

Error: nn::fs::CreateDirectory() failed because the operation is unsupported.
Search '2002-6364' on the following Error Code List for more information.
https://developer.nintendo.com/html/online-docs/g1kr9vj6-ja/Packages/Docs/Lists/ErrorCodeList/NintendoSwitch-ErrorCodeList-ja/2002.html
https://developer.nintendo.com/html/online-docs/g1kr9vj6-en/Packages/Docs/lists/NintendoSwitch-ErrorCodeList/2002.html

------------
AbortObserver called: Failed: nnFsResult
  Module: 2
  Description: 6364
  InnerValue: 0x0031b802
Condition: nn::Result::IsSuccess()
Function: CreateDirectory in D:\home\teamcity\work\sdk\Programs\Chris\Sources\Libraries\fs\fsa\fs_UserFileSystem.cpp:58

Any logs or screenshots

SymbolizedSwitchCrash.txt

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 12, 2024
  2. added
    Bug
    on Sep 13, 2024
  3. bitsandfoxes commented on Sep 13, 2024

    @bitsandfoxes
    Contributor

    Sorry to see you run into issues @abond-sd.
    This should work out-of-the-box. We're handling platform-restrictions for unknown platforms (i.e. Switch) here:

    private void HandlePlatformRestrictions(SentryUnityOptions options, IApplication application, ISentryUnityInfo? unityInfo)

    On a side note: Build-Time Configuration is there to allow the configuration of the native SDKs at build time (those options cannot be changed at runtime) We're planning to simplify this and tracking it with #1621
    So if you want to explicitly disable feature on the Switch you'd have to configure those in the RuntimeConfiguration.

  4. bitsandfoxes commented on Sep 13, 2024

    @bitsandfoxes
    Contributor

    Reading through the crashlog it looks like trying to fetch the Installation ID the .NET SDK attempts to create a persistent installation ID. This is definitely a bug then. Thanks for raising this!

  5. bitsandfoxes commented on Sep 13, 2024

    @bitsandfoxes
    Contributor

    Hey @abond-sd, we've identified the root cause and working on a fix in the .NET SDK. Could you confirm for us: Is the SDK allowed to read from disk? I.e. if you were to attach a log file, would that cause a crash too? Is the restriction for the SDK limited to writing to disk?

  6. abond-sd commented on Sep 13, 2024

    @abond-sd
    Author

    Sorry to see you run into issues @abond-sd. This should work out-of-the-box. We're handling platform-restrictions for unknown platforms (i.e. Switch) here:

    sentry-unity/src/Sentry.Unity/ScriptableSentryUnityOptions.cs

    Line 238 in f4e129b

    private void HandlePlatformRestrictions(SentryUnityOptions options, IApplication application, ISentryUnityInfo? unityInfo)
    On a side note: Build-Time Configuration is there to allow the configuration of the native SDKs at build time (those options cannot be changed at runtime) We're planning to simplify this and tracking it with #1621 So if you want to explicitly disable feature on the Switch you'd have to configure those in the RuntimeConfiguration.

    Thanks, I didn't see a way to affect the behavior of the installation id through something like this, unfortunately. The only related option I could see was SentryOptions.CacheDirectoryPath but since Switch isn't permitted disk access anyway, it doesn't help, unfortunately.

    Hey @abond-sd, we've identified the root cause and working on a fix in the .NET SDK. Could you confirm for us: Is the SDK allowed to read from disk? I.e. if you were to attach a log file, would that cause a crash too? Is the restriction for the SDK limited to writing to disk?

    I don't believe the standard .NET directory or file APIs work out of the box on the platform. You generally seem restricted to reading from readonly storage or reading/writing save data via different Switch SDK calls.

  7. ogonzalez-sd commented on Sep 13, 2024

    @ogonzalez-sd

    We added the following to our runtime configuration in a attempt to prevent the generating of installation id. Our understanding was that an installationid is requested when there is a null value for SentryUser.Id. However, the fix pasted here does not prevent the generation (and subsequent saving to disk) of an installation id.

    SentrySdk.ConfigureScope(scope =>
                {
                    scope.User = new SentryUser
                    {
                        // This fixes a crash on consoles because when not set, Sentry would generate an identifier
                        // and try to save that off to a file. But alas, on most consoles, writable directories
                        // are not readily available nor does all of System.IO work properly. Setting this to a
                        // non-null values indicates to Sentry that it does not need to generate and save it's own identifer
                        Id = string.Empty
                    };
                });
    
  8. ogonzalez-sd commented on Sep 13, 2024

    @ogonzalez-sd

    To put a finer detail, whatever string returned by "Environment.SpecialFolder.LocalApplicationData" on Nintendo Switch, is not a writable directory

  9. bitsandfoxes commented on Sep 16, 2024

    @bitsandfoxes
    Contributor

    We're putting a proper fix for this into the underlying .NET SDK to control - and in case of the Switch platform disable out of the box - the file IO operations.

  10. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 16, 2024
  11. abond-sd commented on Sep 16, 2024

    @abond-sd
    Author

    We're putting a proper fix for this into the underlying .NET SDK to control - and in case of the Switch platform disable out of the box - the file IO operations.

    Sounds great, thank you!

  12. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 16, 2024
  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions