Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry replay Native Crash if a foreground service is running #4241

Open
WadiiChamakhi opened this issue Nov 7, 2024 · 0 comments
Open

Sentry replay Native Crash if a foreground service is running #4241

WadiiChamakhi opened this issue Nov 7, 2024 · 0 comments

Comments

@WadiiChamakhi
Copy link

What React Native libraries do you use?

React Native without Frameworks, React Navigation, Hermes

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.1.0

How does your development environment look like?

System:
OS: macOS 15.1
CPU: (12) arm64 Apple M3 Pro
Memory: 133.08 MB / 18.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.14.0
path: /usr/local/bin/node
Yarn: Not Found
npm:
version: 10.7.0
path: /usr/local/bin/npm
Watchman:
version: 2024.09.16.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK: Not Found
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: /undefined
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react: 18.3.1
react-native: 0.75.3
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: false

Sentry.init()

Sentry.init({
dsn: SENTRY_DNS,
tracesSampleRate: 1.0,
debug: isDebug(),
environment: getEnvironment(),
tracesSampleRate: 1.0,
_experiments: {
profilesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
},
enableAppStartTracking: true,
enableNativeFramesTracking: true,
enableStallTracking: true,
enableUserInteractionTracing: true,
integrations: [
this.reactNavigationIntegration,
Sentry.mobileReplayIntegration({
maskAllText: false,
maskAllImages: false,
maskAllVectors: false,
}),
],
})

Steps to Reproduce

The bug occurs after updating sentry from 5.31.1 to 6.1.0.
Nothing has changed in the native code for the bug to occur.

Two conditions must be true for the bug to occur:

  • A foreground service must be running.
  • The values replaysSessionSampleRate and replaysOnErrorSampleRate , must be different from 0.
    if one of these conditions is not true, the bug will not occur.

here's how the bug occurs.
-When I open the app for the first time, everything works fine, and when I put the app in the background, everything works.
-I close the app and the service remains active.
-I open the app a second time,
-As soon as I set the app to background, it crashes instantly.

==> to recap, with no service running in background, the app doesn't crash, and when replaysSessionSampleRate and replaysOnErrorSampleRate are equal to 0, the app doesn't crash.

Expected Result

Sentry Replay is no longer functional, so this version should be patched as soon as possible, otherwise it will be lost in v6.

A big thank you to our friend @vooban-work for his post #4234 , which helped me diagnose the problem.

Actual Result

FATAL EXCEPTION: main
Process: com.freebees.terminal, PID: 12006
java.lang.RuntimeException: Unable to stop activity {XXXXXX.MainActivity}: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4624)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4594)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4669)
at android.app.servertransaction.StopActivityItem.execute(StopActivityItem.java:41)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.get(ArrayList.java:437)
at android.view.WindowManagerGlobal.setStoppedState(WindowManagerGlobal.java:643)
at android.app.Activity.performStop(Activity.java:8012)
at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4616)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4594) 
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4669) 
at android.app.servertransaction.StopActivityItem.execute(StopActivityItem.java:41) 
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Product Owner
Status: Needs Discussion
Development

No branches or pull requests

2 participants