Description
What React Native libraries do you use?
React Navigation
Are you using sentry.io or on-premise?
sentry.io (SaS)
@sentry/react-native SDK Version
6.13.1
How does your development environment look like?
We’re experiencing Application Not Responding (ANR) errors on Android devices due to the Sentry session replay functionality blocking the main thread during the onStop() lifecycle callback. This occurs when an activity transitions to the stopped state, typically when the user navigates away from the app or it’s sent to the background.
The root cause is identified as a synchronous, potentially blocking operation within the ReplayIntegration.pause() method, executed on the main thread during the onStop() callback. This prevents the system from processing other events, leading to ANRs.
Play Store backtrace:
pid: 0, tid: 5317 >>> com.[REDACTED].mobile <<<
backtrace:
#00 pc 0x0000000000688f40 /apex/com.android.art/lib64/libart.so (art::ArtMethod::GetDeclaringClassDescriptor()+28)
#01 pc 0x000000000094fc18 /apex/com.android.art/lib64/libart.so (art::TraceWriter::GetMethodInfoLine(art::ArtMethod*)+60)
#02 pc 0x000000000094f338 /apex/com.android.art/lib64/libart.so (art::TraceWriter::DumpMethodList(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+116)
#03 pc 0x000000000094e7c0 /apex/com.android.art/lib64/libart.so (art::TraceWriter::FinishTracing(int, bool)+1880)
#04 pc 0x000000000063dd2c /apex/com.android.art/lib64/libart.so (art::Trace::StopTracing(bool)+828)
#05 pc 0x000000000037aa98 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+104)
#06 pc 0x0000000000780108 /apex/com.android.art/lib64/libart.so (nterp_helper+152)
#07 pc 0x00000000001d0178 /system/framework/framework.jar (android.os.Debug.stopMethodTracing)
#08 pc 0x00000000007800a4 /apex/com.android.art/lib64/libart.so (nterp_helper+52)
#09 pc 0x00000000002d1634 /data/app/~~0EIqXAgfa_kWuQFVdDJcHg==/com.[REDACTED].mobile-PpGTrsQl3V4VUfql_5Unng==/base.apk (io.sentry.android.core.AndroidProfiler.endAndCollect+64)
#10 pc 0x0000000000780fc4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
#11 pc 0x00000000002d1b54 /data/app/~~0EIqXAgfa_kWuQFVdDJcHg==/com.[REDACTED].mobile-PpGTrsQl3V4VUfql_5Unng==/base.apk (io.sentry.android.core.AndroidProfiler.lambda$start$0$io-sentry-android-core-AndroidProfiler+4)
#12 pc 0x0000000000780fc4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
#13 pc 0x00000000002d1488 /data/app/~~0EIqXAgfa_kWuQFVdDJcHg==/com.[REDACTED].mobile-PpGTrsQl3V4VUfql_5Unng==/base.apk (io.sentry.android.core.AndroidProfiler$$ExternalSyntheticLambda0.run+4)
#14 pc 0x000000000052567c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.Executors$RunnableAdapter.call+60)
#15 pc 0x00000000005b38c4 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.FutureTask.run+164)
#16 pc 0x0000000000633b20 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run+128)
#17 pc 0x00000000005fe0a4 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+724)
#18 pc 0x00000000005fb9d8 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+56)
#19 pc 0x00000000004d51e0 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.lang.Thread.run+64)
#20 pc 0x0000000000368774 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
#21 pc 0x0000000000353f04 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+132)
#22 pc 0x0000000000947a48 /apex/com.android.art/lib64/libart.so (art::detail::ShortyTraits<(char)86>::Type art::ArtMethod::InvokeInstance<(char)86>(art::Thread*, art::ObjPtr<art::mirror::Object>, art::detail::ShortyTraits<>::Type...)+60)
#23 pc 0x000000000061afcc /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1344)
#24 pc 0x000000000061aa7c /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallbackWithUffdGc(void*)+8)
#25 pc 0x00000000000c9fb0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#26 pc 0x000000000005dd90 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
Seer’s analysis:
Analysis using the Seer AI tool confirms this: the ReplayIntegration library’s pause() method performs a time-consuming operation (likely disk I/O or network related) directly on the main thread, causing the blockage.
Seer suggests the following solution, which we’ve partially validated: creating a custom LifecycleObserver that executes ReplayIntegration.pause() on a background thread using coroutines.

Workaround:
No effective workaround has been identified beyond disabling session replay (undesirable due to loss of valuable diagnostic data).
⬇ Place the `npx react-native@latest info` output here. ⬇
System:
OS: macOS 15.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 175.59 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.8.0
path: ~/.nvm/versions/node/v20.8.0/bin/node
Yarn: Not Found
npm:
version: 10.1.0
path: ~/.nvm/versions/node/v20.8.0/bin/npm
Watchman:
version: 2024.08.26.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.0
- iOS 18.0
- macOS 15.0
- tvOS 18.0
- visionOS 2.0
- watchOS 11.0
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: 16.0/16A242d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Sentry.init()
Sentry.init({
dsn: Config.SENTRY_DSN,
release: Config.APP_VERSION_NAME,
dist: Config.APP_VERSION_CODE,
sendDefaultPii: true,
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
integrations: [
Sentry.mobileReplayIntegration({
maskAllText: false,
maskAllImages: false,
maskAllVectors: false,
}),
Sentry.appStartIntegration(),
Sentry.reactNativeTracingIntegration(),
this.navigationIntegration,
featureFlagsIntegration(),
],
enableAutoSessionTracking: true,
sessionTrackingIntervalMillis: 1000,
enableCaptureFailedRequests: true,
enableUserInteractionTracing: true,
attachScreenshot: true,
})
Steps to Reproduce
While consistent reproduction steps are difficult to define due to the nature of ANRs, the issue generally occurs when navigating away from an active screen within the app and then observing a significant delay or ANR. We’ve observed this across multiple devices and Android versions.
Expected Result
The app should transition smoothly to the background without experiencing ANRs during the session replay pause process.
Actual Result
The app experiences ANRs, resulting in a poor user experience and potentially app crashes.
Metadata
Metadata
Assignees
Type
Projects
Status