getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.56k stars 331 forks source link

Mobile Replay crashes on SDK init in Release mode on Android devices #3990

Closed LucianGalea closed 1 month ago

LucianGalea commented 1 month ago

OS:

Platform:

SDK:

SDK version: 5.27.0

react-native version: 0.73.2

Are you using Expo?

Are you using sentry.io or on-premise?

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...',

  _experiments: {
    replaysSessionSampleRate: 1.0,
    replaysOnErrorSampleRate: 1.0,
  },

  integrations: [
    Sentry.mobileReplayIntegration({
      maskAllText: false,
      maskAllImages: false,
      maskAllVectors: false,
    }),
  ],
});

I have the following issue:

On React Native 0.73.2, replays on Google Pixel Pro 6 don't work. On top of that, reloading the app will freeze it.

Steps to reproduce:

Actual result:

On Google Pixel 6 Pro (Android version 14), no replays will be captured. On top of that, reloading the app will freeze. Killing the app and restarting it fixes the freeze.

NOTE: disabling the replays doesn't fix the freeze, so it's probably not related to that.

Expected result:

Replays should be saved. Reload shouldn't freeze.

franblanco95 commented 1 month ago

I have the same problem on Android.. The app crashes when is downloaded from the playstore. From the emulator works ok.

kahest commented 1 month ago

Thank you both for the report. @franblanco95 do you use Session Replay?

franblanco95 commented 1 month ago

Thank you both for the report. @franblanco95 do you use Session Replay?

Yes i do

manuelabarca commented 1 month ago

I have the same problem on Android.. The app crashes when is downloaded from the playstore. From the emulator works ok.

Same here.

ENV: SDK version: 5.27.0 react-native version: 0.72.12

krystofwoldrich commented 1 month ago

@LucianGalea Thank you for the report and the information, do both Hot Reload and Reload from Metro freeze the app?

krystofwoldrich commented 1 month ago

@manuelabarca and @franblanco95 would you be able to share more information about the crash? Tombstone, stack trace...

Does in work in Release mode on real device? But crashes when downloaded from the store?

manuelabarca commented 1 month ago

@manuelabarca and @franblanco95 would you be able to share more information about the crash? Tombstone, stack trace...

Does in work in Release mode on real device? But crashes when downloaded from the store?

In release mode it is not working, we have tried downloading from appcenter, internal channel in google play and google play production. But in emulator it works and does not give any error messages.

Sentry capture, title: abort. Image

LucianGalea commented 1 month ago

@krystofwoldrich

@LucianGalea Thank you for the report and the information, do both Hot Reload and Reload from Metro freeze the app?

Hot reload works maybe half of the time (it's difficult to establish a pattern) Reload from Metro always freezes the app - the only way to proceed is to kill it and restart.

manuelabarca commented 1 month ago

Env:

I have shared the bug report via google play console to you as the library provider. This is from google play console:

io.sentry.android.replay.ReplayCache.persistSegmentValues java.io.FileNotFoundException

Exception java.lang.RuntimeException: Could not invoke RNSentry.initNativeSdk
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:383)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:1012)
Caused by java.lang.reflect.InvocationTargetException:
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
Caused by java.io.FileNotFoundException:
  at libcore.io.IoBridge.open (IoBridge.java:574)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:236)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:186)
  at kotlin.io.FilesKt__FileReadWriteKt.writeBytes (FileReadWrite.kt:108)
  at kotlin.io.FilesKt__FileReadWriteKt.writeText (FileReadWrite.kt:134)
  at kotlin.io.FilesKt__FileReadWriteKt.writeText$default (FileReadWrite.kt:134)
  at io.sentry.android.replay.ReplayCache.persistSegmentValues (ReplayCache.kt:281)
  at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$3$3.invoke (BaseCaptureStrategy.kt:371)
  at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$3$3.invoke (BaseCaptureStrategy.kt:351)
  at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$3.runInBackground (BaseCaptureStrategy.kt:338)
  at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$3.setValue (BaseCaptureStrategy.kt:351)
  at io.sentry.android.replay.capture.BaseCaptureStrategy.setReplayType (BaseCaptureStrategy.kt:90)
  at io.sentry.android.replay.capture.BaseCaptureStrategy.start (BaseCaptureStrategy.kt:113)
  at io.sentry.android.replay.capture.SessionCaptureStrategy.start (SessionCaptureStrategy.kt:36)
  at io.sentry.android.replay.capture.CaptureStrategy$DefaultImpls.start$default (CaptureStrategy.kt:29)
  at io.sentry.android.replay.ReplayIntegration.start (ReplayIntegration.kt:156)
  at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:180)
  at io.sentry.android.core.SentryAndroid.init (SentryAndroid.java:77)
  at io.sentry.react.RNSentryModuleImpl.initNativeSdk (RNSentryModuleImpl.java:183)
  at io.sentry.react.RNSentryModule.initNativeSdk (RNSentryModule.java:43)
Caused by android.system.ErrnoException: open failed: ENOENT (No such file or directory)
  at libcore.io.Linux.open
  at libcore.io.ForwardingOs.open (ForwardingOs.java:563)
  at libcore.io.BlockGuardOs.open (BlockGuardOs.java:274)
  at libcore.io.ForwardingOs.open (ForwardingOs.java:563)
  at android.app.ActivityThread$AndroidOs.open (ActivityThread.java:8624)
  at libcore.io.IoBridge.open (IoBridge.java:560)
krystofwoldrich commented 1 month ago

@manuelabarca Thank you for the stack traces.

@romtsn It looks like the replay integration crashes during init on a file creation.

mattlewer commented 1 month ago

I'm also experiencing a crash after upgrading and implementing the session replay, for me it occurs when the user records a video and then accepts it, returning to the app.

We're using react-native-image-picker, which I believe starts its own activity. Would this be the same issue or should I open another?

romtsn commented 1 month ago

@mattlewer what's the stacktrace of the crash?

mattlewer commented 1 month ago

@romtsn

TimeoutException android.view.Surface.finalize() timed out after 60 seconds

android.view.Surface in nHwuiDestroy android.view.Surface in access$500 at line 50 android.view.Surface$HwuiContext in destroy at line 915 android.view.Surface in release at line 236 android.view.Surface in finalize at line 218 java.lang.Daemons$FinalizerDaemon in doFinalize at line 250 java.lang.Daemons$FinalizerDaemon in runInternal at line 237 java.lang.Daemons$Daemon in run at line 103 java.lang.Thread in run at line 764

romtsn commented 1 month ago

@mattlewer probably it's not the same issue, so I'd suggest opening a new one, and provide details like what devices does this affect, what android versions, a link to your project in sentry, etc. Thank you!