-
-
Notifications
You must be signed in to change notification settings - Fork 456
Description
Integration
sentry-android
Build System
Gradle
AGP Version
8.5.2
Proguard
Enabled
Version
7.11.0
Steps to Reproduce
What happened
SentryAndroid.init(application)
is causing ANRs because of heavy operations on the main thread.
Both issues are caused by io.sentry.Sentry.init(Sentry.java:166)
stacktrace:
at java.lang.Runtime.nativeLoad(Native Method)
at java.lang.Runtime.nativeLoad(Runtime.java:1121)
at java.lang.Runtime.loadLibrary0(Runtime.java:1075)
at java.lang.Runtime.loadLibrary0(Runtime.java:998)
at java.lang.System.loadLibrary(System.java:1661)
at io.sentry.android.ndk.SentryNdk.<clinit>(SentryNdk.java:19)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at io.sentry.android.core.LoadClass.loadClass(LoadClass.java:21)
at io.sentry.android.core.AndroidOptionsInitializer.installDefaultIntegrations(AndroidOptionsInitializer.java:257)
at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:117)
at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
at io.sentry.Sentry.init(Sentry.java:166)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:90)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:73)
The second ANR is caused by io.sentry.android.core.AndroidOptionsInitializer.getCacheDir(AndroidOptionsInitializer.java:362)
stacktrace:
at android.app.ContextImpl.getCacheDir(ContextImpl.java:872)
at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:332)
at io.sentry.android.core.AndroidOptionsInitializer.getCacheDir(AndroidOptionsInitializer.java:362)
at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:110)
at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:111)
at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
at io.sentry.Sentry.init(Sentry.java:166)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:90)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:73)
How to reproduce
If you enable StrictMode for your SDK you'll get warnings triggered by these functions: io.sentry.android.core.AndroidOptionsInitializer.readDefaultOptionValues(AndroidOptionsInitializer.java:336)
, io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:112)
android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1679)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8469)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:313)
at java.io.File.exists(File.java:813)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:791)
at android.app.ContextImpl.ensurePrivateCacheDirExists(ContextImpl.java:787)
at android.app.ContextImpl.getCacheDir(ContextImpl.java:898)
at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:328)
at io.sentry.android.core.AndroidOptionsInitializer.getCacheDir(AndroidOptionsInitializer.java:362)
at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:110)
at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:111)
at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
at io.sentry.Sentry.init(Sentry.java:166)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:90)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:73)
android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1679)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8469)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:313)
at java.io.File.exists(File.java:813)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:791)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:782)
at android.app.ContextImpl.getFilesDir(ContextImpl.java:827)
at android.content.ContextWrapper.getFilesDir(ContextWrapper.java:288)
at io.sentry.android.core.Installation.id(Installation.java:34)
at io.sentry.android.core.AndroidOptionsInitializer.readDefaultOptionValues(AndroidOptionsInitializer.java:336)
at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:112)
at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:111)
at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
at io.sentry.Sentry.init(Sentry.java:166)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:90)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:73)
Severity
This issue increases ANR rate of the app getting it closer to the Google's threshold, therefore making it harder to justify using Sentry in our codebase. Can you please consider removing disk read/write or other heavy operations off the main thread and use StrictMode to test your SDK before releasing it?
Expected Result
No disk read/write or other heavy operations on main thread.
Actual Result
ANRs caused by heavy operations on main thread.
┆Issue is synchronized with this Jira Improvement by Unito
Metadata
Metadata
Assignees
Labels
Projects
Status
Status