Repository navigation
Description
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
When I start my app on Maui.iOS, I get an Exception error from Sentry.
2024-10-04 20:35:37.251 ExpiryDateScanner.iOS[1520:378218] Info: Envelope queued up: ''
Debug: Created directory for installation ID file (/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA).
Debug: Resolved installation ID '4fff81ed-63d1-41a4-809b-22abb303548d'.
Info: Started new session (SID: 03e879f3c47b477ea0179ad05feecff9; DID: 4fff81ed-63d1-41a4-809b-22abb303548d).
Debug: Storing file /var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA/1728041737_684__1114545838.envelope.
Debug: Persisting session (SID: '03e879f3c47b477ea0179ad05feecff9') to a file.
Debug: Creating persistence directory for session file at '/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA'.
2024-10-04 20:35:37.253 ExpiryDateScanner.iOS[1520:378218] Debug: Created directory for installation ID file (/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA).
2024-10-04 20:35:37.255 ExpiryDateScanner.iOS[1520:378218] Debug: Resolved installation ID '4fff81ed-63d1-41a4-809b-22abb303548d'.
2024-10-04 20:35:37.256 ExpiryDateScanner.iOS[1520:378218] Info: Started new session (SID: 03e879f3c47b477ea0179ad05feecff9; DID: 4fff81ed-63d1-41a4-809b-22abb303548d).
2024-10-04 20:35:37.257 ExpiryDateScanner.iOS[1520:378259] Debug: Storing file /var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA/1728041737_684__1114545838.envelope.
2024-10-04 20:35:37.258 ExpiryDateScanner.iOS[1520:378218] Debug: Persisting session (SID: '03e879f3c47b477ea0179ad05feecff9') to a file.
2024-10-04 20:35:37.258 ExpiryDateScanner.iOS[1520:378218] Debug: Creating persistence directory for session file at '/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA'.
Debug: Persisted session to a file '/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA/.session'.
Debug: Envelope handed off to transport (event ID: ''). 1 items in queue.
2024-10-04 20:35:37.271 ExpiryDateScanner.iOS[1520:378218] Debug: Persisted session to a file '/var/mobile/Containers/Data/Application/F2E510BB-A8AA-4283-9F53-B5191AA45840/Library/Caches/Sentry/4D9C78D8B2C334529A61CC489DAB4D5ED749FBFA/.session'.
2024-10-04 20:35:37.273 ExpiryDateScanner.iOS[1520:378259] Debug: Envelope handed off to transport (event ID: ''). 1 items in queue.
2024-10-04 20:35:37.282 ExpiryDateScanner.iOS[1520:378218] Error: Failed to persist session on the file system.
System.ObjectDisposedException: Cannot access a closed file.
at System.IO.FileStream.Flush(Boolean flushToDisk)
at System.IO.FileStream.Flush()
at System.Text.Json.Utf8JsonWriter.Flush()
2024-10-04 20:35:37.282 ExpiryDateScanner.iOS[1520:378218] at System.Text.Json.Utf8JsonWriter.Dispose()
at Sentry.GlobalSessionManager.PersistSession(SessionUpdate update, Nullable1 pauseTimestamp) Error: Failed to persist session on the file system. System.ObjectDisposedException: Cannot access a closed file. at System.IO.FileStream.Flush(Boolean flushToDisk) at System.IO.FileStream.Flush() at System.Text.Json.Utf8JsonWriter.Flush() at System.Text.Json.Utf8JsonWriter.Dispose() at Sentry.GlobalSessionManager.PersistSession(SessionUpdate update, Nullable1 pauseTimestamp)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsNo status
Activity
getsantry commentedon Oct 4, 2024
Assigning to @getsentry/support for routing ⏲️
jamescrosswell commentedon Oct 6, 2024
@pulmuone which version of the Sentry.Maui NuGet package are you referencing in your project?
jamescrosswell commentedon Oct 11, 2024
@pulmuone this should be fixed in the 4.12.1 release. Let us know if you still have issues after upgrading to that version though.
BillyMartin1964 commentedon Mar 29, 2026
I think this might be back. I've had to disable auto tracking to avoid a crash. I thought a try catch would work, but doesn't:
System.IO.FileNotFoundException thrown] System.Private.CoreLib.dll!Interop.ThrowExceptionForIoErrno(Interop.ErrorInfo errorInfo, string path, bool isDirError) System.Private.CoreLib.dll!Interop.CheckIo(Interop.Error error, string path, bool isDirError) System.Private.CoreLib.dll!Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string path, Interop.Sys.OpenFlags flags, int mode, bool failForSymlink, out bool wasSymlink, System.Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, System.Exception> createOpenException) System.Private.CoreLib.dll!Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string fullPath, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode openPermissions, out long fileLength, out System.IO.UnixFileMode filePermissions, bool failForSymlink, out bool wasSymlink, System.Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, System.Exception> createOpenException) System.Private.CoreLib.dll!Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string fullPath, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode? unixCreateMode, System.Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, System.Exception> createOpenException) System.Private.CoreLib.dll!System.IO.Strategies.OSFileStreamStrategy.OSFileStreamStrategy(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode? unixCreateMode) System.Private.CoreLib.dll!System.IO.Strategies.UnixFileStreamStrategy.UnixFileStreamStrategy(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode? unixCreateMode) System.Private.CoreLib.dll!System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode? unixCreateMode) System.Private.CoreLib.dll!System.IO.Strategies.FileStreamHelpers.ChooseStrategy(System.IO.FileStream fileStream, string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, long preallocationSize, System.IO.UnixFileMode? unixCreateMode) System.Private.CoreLib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, long preallocationSize) System.Private.CoreLib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options) System.Private.CoreLib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, bool useAsync) System.Private.CoreLib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) System.Private.CoreLib.dll!System.IO.File.OpenRead(string path) Sentry.dll!Sentry.Internal.FileSystemBase.OpenFileForReading(string path) Sentry.dll!Sentry.Internal.Json.Load<Sentry.PersistedSessionUpdate>(Sentry.Internal.IFileSystem fileSystem, string filePath, System.Func<System.Text.Json.JsonElement, Sentry.PersistedSessionUpdate> factory) Sentry.dll!Sentry.GlobalSessionManager..ctor.AnonymousMethod__11_0(string filePath) Sentry.dll!Sentry.GlobalSessionManager.TryRecoverPersistedSession() Sentry.dll!Sentry.Internal.Hub.StartSession() Sentry.dll!Sentry.Integrations.AutoSessionTrackingIntegration.Register(Sentry.IHub hub, Sentry.SentryOptions options) Sentry.dll!Sentry.Internal.Hub.Hub(Sentry.SentryOptions options, Sentry.ISentryClient client, Sentry.ISessionManager sessionManager, Sentry.Infrastructure.ISystemClock clock, Sentry.Internal.IInternalScopeManager scopeManager, Sentry.Internal.RandomValuesFactory randomValuesFactory, Sentry.Internal.IReplaySession replaySession, Sentry.Internal.ISampleRandHelper sampleRandHelper, Sentry.Internal.BackpressureMonitor backpressureMonitor) Sentry.dll!Sentry.SentrySdk.InitHub(Sentry.SentryOptions options) Sentry.dll!Sentry.SentrySdk.Init(Sentry.SentryOptions options) Sentry.Maui.dll!Sentry.Maui.Internal.SentryMauiInitializer.Initialize(System.IServiceProvider services) Microsoft.Maui.dll!Microsoft.Maui.MauiContextExtensions.InitializeAppServices(Microsoft.Maui.Hosting.MauiApp mauiApp) Line 83 at //src/Core/src/MauiContextExtensions.cs(83) Microsoft.Maui.dll!Microsoft.Maui.Hosting.MauiAppBuilder.Build() Line 198 at //src/Core/src/Hosting/MauiAppBuilder.cs(198) CodeLogicMaster.dll!CodeLogicMaster.MauiProgram.CreateMauiApp() Line 131 at D:\AppsInStores\Maui\CodeLogicMaster\CodeLogicMaster\MauiProgram.cs(131) CodeLogicMaster.dll!CodeLogicMaster.Platforms.Android.MainApplication.CreateMauiApp() Line 14 at D:\AppsInStores\Maui\CodeLogicMaster\CodeLogicMaster\Platforms\Android\MainApplication.cs(14) Microsoft.Maui.dll!Microsoft.Maui.MauiApplication.OnCreate() Line 36 at /_/src/Core/src/Platform/Android/MauiApplication.cs(36) Mono.Android.dll!Android.App.Application.n_OnCreate(nint jnienv, nint native__this)BillyMartin1964 commentedon Mar 29, 2026
I've had to do this to get it to run:
#if ANDROID
options.Environment = "Android";
var cacheDir = Android.App.Application.Context.CacheDir?.AbsolutePath;
if (!string.IsNullOrEmpty(cacheDir))
{
var sentryDir = Path.Combine(cacheDir, "Sentry");
Directory.CreateDirectory(sentryDir);
options.CacheDirectoryPath = cacheDir;
}
else
{
options.AutoSessionTracking = false;
}
#endif
jamescrosswell commentedon Mar 29, 2026
Quite a lot has changed since v4 so I've opened a new issue to track this possible regression. I'll lock this issue down so we can keep all further discussions in one place. Follow ups on :