DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
116 stars 41 forks source link

Fatal error not captured by Datadog #620

Closed hankwz closed 3 months ago

hankwz commented 6 months ago

Describe the bug

Our app implemented a QR code scanner from react-native-vision-camera, but we encountered a crash on Android after scanning a QR code. It showed as a Fatal error in Logcat, Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x727f27aee2 in tid 9938 (pool-26-thread-), pid 8232 (.eventapp.local) However, when we checked Datadog RUM, we were not seeing any error being logged. We would like to know why it was not able to capture the crash.

Here is the details of the log in Logcat,

ReactNativeJS           <...>.eventapp.local      D  DATADOG: Tracking info log "Android data access auditing API has been called by android:camera"
ReactNativeJS           <...>.eventapp.local      D  DATADOG: Starting RUM Resource #1708702826730/GET 
<...>.eventapp.local    <...>.eventapp.local      I  Android data access auditing API has been called by android:camera
ReactNativeJS           <...>.eventapp.local      D  DATADOG: Starting RUM Resource #1708702826744/POST 
CameraSession           <...>.eventapp.local      I  PreviewView Surface destroyed! Surface(name=null)/@0x95a91fd
CameraSession           <...>.eventapp.local      I  Destroying Preview Output...
CameraSession           <...>.eventapp.local      I  Updating CameraSession Configuration...
CameraSession           <...>.eventapp.local      I  Configuring Session for Camera #0...
SurfaceOutput           <...>.eventapp.local      I  Closing BarcodeScanner..
CameraSession           <...>.eventapp.local      I  Adding 1280 x 720 CodeScanner Output in Format #35...
CreateCaptureSession    <...>.eventapp.local      I  Camera 0: Creating Capture Session #1005... Hardware Level: 3} | Outputs: [android.hardware.camera2.params.OutputConfiguration@50d5dc8]
CreateCaptureSession    <...>.eventapp.local      I  Using new API (>=28)
BufferQueueProducer     <...>.eventapp.local      E  [ImageReader-1280x720f23m2-8232-4](id:20280000000d,api:4,p:1566,c:8232) dequeueBuffer: BufferQueue has been abandoned
libc                    <...>.eventapp.local      A  Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x727f27aee2 in tid 9938 (pool-26-thread-), pid 8232 (.eventapp.local)
BufferQueueProducer     <...>.eventapp.local      E  [ImageReader-1280x720f23m2-8232-4](id:20280000000d,api:4,p:1566,c:8232) queueBuffer: BufferQueue has been abandoned
---------------------------- PROCESS STARTED (10175) for package <...>.eventapp.local ----------------------------
CreateCaptureSession    <...>.eventapp.local      I  Camera 0: Capture Session #1005 configured!
CameraSession           <...>.eventapp.local      I  Successfully configured Session with 1 outputs for Camera #0!
CameraSession           <...>.eventapp.local      W  Preview Output is null, aborting...
CameraSession           <...>.eventapp.local      I  Successfully updated CameraSession Configuration! isActive: true
CreateCaptureSession    <...>.eventapp.local      I  Camera 0: Capture Session #1004 closed!
CameraView              <...>.eventapp.local      I  Updating CameraSession...
CameraSession           <...>.eventapp.local      I  Updating CameraSession Configuration...
CameraSession           <...>.eventapp.local      I  Successfully updated CameraSession Configuration! isActive: false
OpenGLRenderer          <...>.eventapp.local      I  Davey! duration=982ms; Flags=0, FrameTimelineVsyncId=100486934, IntendedVsync=2373660216001376, Vsync=2373660216001376, InputEventId=0, HandleInputStart=2373660216573772, AnimationStart=2373660216579240, PerformTraversalsStart=2373661175233971, DrawStart=2373661188910743, FrameDeadline=2373660236668042, FrameInterval=2373660216551063, FrameStartTime=16666666, SyncQueued=2373661190432306, SyncStart=2373661190761316, IssueDrawCommandsStart=2373661193223973, SwapBuffers=2373661195016786, FrameCompleted=2373661199272046, DequeueBufferDuration=34791, QueueBufferDuration=482812, GpuCompleted=2373661199272046, SwapBuffersCompleted=2373661195932984, DisplayPresentTime=0, 
DEBUG                   crash_dump64                         A  Cmdline: <...>.eventapp.local
DEBUG                   crash_dump64                         A  pid: 8232, tid: 9938, name: pool-26-thread-  >>> <...>.eventapp.local <<<
---------------------------- PROCESS ENDED (8232) for package <...>.eventapp.local ----------------------------
---------------------------- PROCESS ENDED (10175) for package <...>.eventapp.local ----------------------------

Reproduction steps

  1. Setup Datadog SDK
  2. Generate a fatal error
  3. Check Datadog RUM when the fatal error happens

SDK logs

No response

Expected behavior

Fatal error is being captured by Datadog and logged in RUM

Affected SDK versions

1.8.0

Latest working SDK version

n/a

Did you confirm if the latest SDK version fixes the bug?

No

Integration Methods

NPM

React Native Version

0.71.13

Package.json Contents

"react-native": "0.71.13", "@react-navigation/native": "6.1.6", "@react-navigation/native-stack": "6.9.12", "@react-navigation/stack": "6.3.16", "@datadog/mobile-react-native": "^1.8.0", "@datadog/mobile-react-navigation": "^1.8.0", "react-native-vision-camera": "3.6.4",

iOS Setup

No response

Android Setup

No response

Device Information

Google Pixel 3 XL Android 12.0

Other relevant information

No response

louiszawadzki commented 6 months ago

Hi @hankwz, thanks for reaching out!

Are you running the app in release mode? In debug mode React Native can catch native crashes and prevent the error from being thrown.

If so, would you have a sample app or code snippet making the app crash so we can better help troubleshoot?

Thanks a lot!

hankwz commented 6 months ago

Hi @louiszawadzki This is a sample project with QR scanner I've created from the example of dd-sdk-reactnative. https://github.com/hankwz/dd-react-native-camera

After scanning a QR code for a few times, the app crashes. But Datadog doesn't seem to capture the crash. Please note that I am not able to re-create the exact same fatal error in this sample app as the one in the issue description above,

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x727f27aee2 in tid 9938 (pool-26-thread-), pid 8232 (.eventapp.local)

Screenshot_20240227-110757

louiszawadzki commented 6 months ago

Hi @hankwz, thanks for adding more details!

I am able to reproduce the issue. This is an Android NDK crash and we currently don't have an option to catch NDK crashes for React Native.

It's currently high in our backlog as we are working towards catching all crashes, I will let you know as soon as it is available!

hankwz commented 6 months ago

Thanks @louiszawadzki. Please keep me posted.

marco-saia-datadog commented 3 months ago

Hey @hankwz! I wanted to reach out to inform you that since v2.2.0 we have made several improvements on crash reports, and NDK crashes are now correctly reported. If you haven't already, I suggest updating the SDK to the latest v2.3.3 and verify if it solves your problem.

I will close this issue for now, but feel free to reach out again if you encounter any other issues on your end!