sentry-java
sentry-java copied to clipboard
DiskReadViolation when calling Sentry.captureException()
Integration
sentry-android
Build System
Gradle
AGP Version
7.2.1
Proguard
Enabled
Version
6.3.0
Steps to Reproduce
I do not have a sample project on hand for the repro. But the project I am working on reports Strict Mode violations as non-fatal errors and we are seeing the following non-fatal error stack trace when calling Sentry.captureException:
android.os.strictmode.DiskReadViolation: null
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1659)
at libcore.io.BlockGuardOs.statvfs(BlockGuardOs.java:425)
at libcore.io.ForwardingOs.statvfs(ForwardingOs.java:859)
at android.system.Os.statvfs(Os.java:924)
at android.os.StatFs.doStat(StatFs.java:51)
at android.os.StatFs.<init>(StatFs.java:43)
at io.sentry.SentryClient.processEvent(SourceFile:292)
at io.sentry.SentryClient.captureEvent(SourceFile:114)
at io.sentry.Hub.captureExceptionInternal(SourceFile:226)
at io.sentry.Hub.captureException(SourceFile:193)
at io.sentry.IHub.captureException
at io.sentry.Sentry.captureException
Our project is configured with detectDiskReads enabled. The assumption was that Sentry.captureException() can be called from any thread including the main thread.
Expected Result
Sentry.captureException() should not trigger a DiskReadViolation when called on the main thread.
Actual Result
Sentry.captureException() triggers a DiskReadViolation when called on the main thread.
The SDK process events on the calling thread, that means EventProcessors and BeforeSend callback also runs on the calling thread. We then queue the event for submission on a background thread. Some of the event data requires disk I/O so to completely avoid this disk read violation, we'd need to go through the SDK and rip any context data added that relies on it.
Is this causing any issues, like noticiable slowdowns for any sort? It hasn't been a problem other than raising this event if that flag is enabled.
The work around for now is to disable detectDiskReads if Sentry is enabled since doing that by itself isn't a problem
Similar to https://github.com/getsentry/sentry-java/issues/909
Closing due to inactivity, please feel free to reopen if you have anything to share.