sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

ANR during Sentry Event Processing

Open ZeeshanShabbir opened this issue 1 year ago • 1 comments

Gradle Version

8.10.2

AGP Version

8.6.1

Code Minifier/Optimizer

Dexguard

Version

4.11.0

Sentry SDK Version

7.14.0

Steps to Reproduce

We’ve received reports indicating that an ANR has been triggered, and the root cause appears to be related to the Sentry Android plugin. The ANR occurs during file access in the external storage while processing events in Sentry.

Could you please investigate this issue further?

"main" tid=1 Native #00 pc 0x00000000000ecf88 /apex/com.android.runtime/lib64/bionic/libc.so (__faccessat+8) getsentry/sentry-android-gradle-plugin#1 pc 0x0000000000024338 /apex/com.android.art/lib64/libjavacore.so (Linux_access+76) at libcore.io.Linux.access (Native method) at libcore.io.ForwardingOs.access (ForwardingOs.java:128) at libcore.io.BlockGuardOs.access (BlockGuardOs.java:76) at libcore.io.ForwardingOs.access (ForwardingOs.java:128) at android.app.ActivityThread$AndroidOs.access (ActivityThread.java:8535) at java.io.UnixFileSystem.checkAccess (UnixFileSystem.java:332) at java.io.File.exists (File.java:829) at android.app.ContextImpl.ensureExternalDirsExistOrFilter (ContextImpl.java:3619) at android.app.ContextImpl.getExternalFilesDirs (ContextImpl.java:883) at android.app.ContextImpl.getExternalFilesDir (ContextImpl.java:872) at android.content.ContextWrapper.getExternalFilesDir (ContextWrapper.java:317) at io.sentry.android.core.DefaultAndroidEventProcessor.mergeOS (DefaultAndroidEventProcessor.java:196) at io.sentry.SentryBaseEvent.getContexts (SentryBaseEvent.java:177) at io.sentry.protocol.Contexts.toContextType (Contexts.java:97) at io.sentry.android.core.DefaultAndroidEventProcessor.mergeOS (DefaultAndroidEventProcessor.java:196) at io.sentry.protocol.Contexts.setOperatingSystem (Contexts.java:141) at io.sentry.protocol.Contexts.toContextType (Contexts.java:97) at io.sentry.android.core.DefaultAndroidEventProcessor.process (DefaultAndroidEventProcessor.java:75) at io.sentry.SentryClient.processEvent (SentryClient.java:449) at io.sentry.SentryClient.captureEvent (SentryClient.java:142) at io.sentry.Hub.captureEventInternal (Hub.java:120) at io.sentry.Hub.captureEvent (Hub.java:90) at io.sentry.Sentry.captureEvent (Sentry.java:527) at io.sentry.HubAdapter.captureEvent (HubAdapter.java:30) at io.sentry.IHub$-CC.$default$captureEvent (IHub.java:40) at io.sentry.android.timber.SentryTimberTree.captureEvent (SentryTimberTree.kt:272) at io.sentry.android.timber.SentryTimberTree.logWithSentry (SentryTimberTree.kt:240) at io.sentry.android.timber.SentryTimberTree.e (SentryTimberTree.kt:146) at timber.log.Timber$Forest.e (Timber.kt:342)

Expected Result

Sentry should work without creating the ANR

Actual Result

Sentry is causing the ANR and impacting the app's performance

ZeeshanShabbir avatar Oct 09 '24 08:10 ZeeshanShabbir

The Sentry Android Plugin is a Gradle Build Plugin, I hope you're not shipping that within your app 😅 In any case this sounds like something we should have a look at, thanks for reporting!

markushi avatar Oct 09 '24 08:10 markushi

Quick update: 7.16.0 is out now, featuring some more improvements around ANRs and SDK init performance. It won't fix the specific issue above, but a few others which had a bigger impact in our testing.

markushi avatar Oct 24 '24 05:10 markushi

Hi, do we happen to have any update on this issue? We are still receiving reports for this ANR we are using version 7.18.0

"main" tid=1 Native
  #00  pc 0x00000000000dc058  /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+8)
  #01  pc 0x0000000000095cc8  /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
  #02  pc 0x00000000000530b4  /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver+292)
  #03  pc 0x0000000000054328  /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse+120)
  #04  pc 0x0000000000054034  /system/lib64/libbinder.so (android::IPCThreadState::transact+224)
  #05  pc 0x000000000004bb28  /system/lib64/libbinder.so (android::BpBinder::transact+240)
  #06  pc 0x000000000016aa94  /system/lib64/libandroid_runtime.so (android_os_BinderProxy_transact+156)
  at android.os.BinderProxy.transactNative (Native method)
  at android.os.BinderProxy.transact (BinderProxy.java:629)
  at android.os.storage.IStorageManager$Stub$Proxy.mkdirs (IStorageManager.java:1929)
  at android.os.storage.StorageManager.mkdirs (StorageManager.java:1368)
  at android.app.ContextImpl.ensureExternalDirsExistOrFilter (ContextImpl.java:3290)
  at android.app.ContextImpl.getExternalFilesDirs (ContextImpl.java:835)
  at android.app.ContextImpl.getExternalFilesDir (ContextImpl.java:824)
  at android.content.ContextWrapper.getExternalFilesDir (ContextWrapper.java:291)
  at io.sentry.android.core.DefaultAndroidEventProcessor.mergeOS (DefaultAndroidEventProcessor.java:198)
  at io.sentry.android.core.DeviceInfoUtil.getOperatingSystem (DeviceInfoUtil.java:195)
  at io.sentry.protocol.Contexts.toContextType (Contexts.java:97)
  at io.sentry.android.core.DefaultAndroidEventProcessor.process (DefaultAndroidEventProcessor.java:77)
  at io.sentry.SentryClient.processEvent (SentryClient.java:447)
  at io.sentry.SentryClient.captureEvent (SentryClient.java:140)
  at io.sentry.Hub.captureEventInternal (Hub.java:120)
  at io.sentry.Hub.captureEvent (Hub.java:90)
  at io.sentry.Sentry.captureEvent (Sentry.java:543)
  at io.sentry.HubAdapter.captureEvent (HubAdapter.java:30)
  at io.sentry.IHub.captureEvent (IHub.java:40)
  at io.sentry.android.timber.SentryTimberTree.captureEvent (SentryTimberTree.kt:272)
  at io.sentry.android.timber.SentryTimberTree.logWithSentry (SentryTimberTree.kt:240)
  at io.sentry.android.timber.SentryTimberTree.e (SentryTimberTree.kt:136)
  at timber.log.Timber$Forest.e (Timber.kt:337)

ZeeshanShabbir avatar Dec 09 '24 08:12 ZeeshanShabbir

Hey @ZeeshanShabbir thanks for reporting again, we don't have any updates yet as we focused on other more frequently reported issues, but we'll investigate this soon and update here

kahest avatar Dec 11 '24 10:12 kahest

@ZeeshanShabbir we've reduced IPC calls by quite a bit in 8.1.0 (and 7.21.0), could you update to those versions and monitor if it has improved the ANR situation?

romtsn avatar Feb 12 '25 17:02 romtsn

Closing now, as we shipped many ANR related improvements over the past months. If you're still experiencing issues, don't hold back and open a new issue!

markushi avatar Mar 04 '25 13:03 markushi