Open bitsandfoxes opened 5 days ago
Going with solution 2. It's been like that for some time so there's no need to hack something together. Let's introduce a new options i.e. DisableFileWrite
and route all writing to disk through our FileSystem
.
Todo: Make sure reading from disk actually works on those restricted platforms.
Problem
Writing to disk on restricted platforms - i.e. Nintento Switch - causes the game to crash: https://github.com/getsentry/sentry-unity/issues/1804
What's happening
We're fetching the
installationId
lazily https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/SentryOptions.cs#L1184and during event enrichment that
installationId
gets resolved https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/Internal/Enricher.cs#L83and this causes the InstallationIdHelper to attempt to create a persistent
installationId
on disk https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/Internal/InstallationIdHelper.cs#L30-L33 https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/Internal/InstallationIdHelper.cs#L48-L56Solutions
Change the accessor for(Hacky) https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/SentryOptions.cs#L45InstallationId
frominternal
topublic
. That way the Unity SDK can overwrite the lazy initialization during options construction.CacheDirectoryPath
. With theCacheDirectoryPath
set tonull
we skip all operations writing to disk. We've already gotFileSystem
in place. https://github.com/getsentry/sentry-dotnet/blob/9ad2caa0c1e21296a90242c06e564d079a59020f/src/Sentry/Internal/FileSystem.cs#L19 We could replace all instances of the SDK directly callingDirectory.Create
forFile.Write
going throughFileSystem
and make that adhere to the options.