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

[newarch][android] Sentry.nativeCrash no longer crashes RN #4446

Open
lovegaoshi opened this issue Jan 14, 2025 · 3 comments
Open

[newarch][android] Sentry.nativeCrash no longer crashes RN #4446

lovegaoshi opened this issue Jan 14, 2025 · 3 comments

Comments

@lovegaoshi
Copy link

lovegaoshi commented Jan 14, 2025

What React Native libraries do you use?

RN New Architecture

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.5.0

How does your development environment look like?

not relevant

Sentry.init()

not relevant

Steps to Reproduce

hi! i'm not sure if this actually belongs to the RN tracker (felt more so), probably will cross post;

I actually use Sentry.nativeCrash as a way to force my app to restart to apply some settings. With the old arch it works wonderfully. With the new arch RN seems to catch it instead into softException, the app lingers but displays an empty canvas. If I have a service attached, it will keep functioning for however long the native part works. I wonder if this just means Sentry.nativeCrash should be deprecated? TIA!

Expected Result

native crash, app exits

Actual Result

instead I'm left with a blank screen with the app still lingering, since RN caught this exception.

logcat trace:

Unhandled SoftException
com.facebook.react.bridge.ReactNoCrashSoftException: raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "TEST - Sentry Client Crash (only works in release mode)")
	at com.facebook.react.runtime.ReactHostImpl.I1(SourceFile:48)
	at com.facebook.react.runtime.ReactHostImpl.y0(SourceFile:6)
	at com.facebook.react.runtime.ReactHostImpl.V0(SourceFile:26)
	at com.facebook.react.runtime.ReactHostImpl.Z(SourceFile:1)
	at com.facebook.react.runtime.V.call(SourceFile:1)
	at D5.d$b.run(SourceFile:5)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: TEST - Sentry Client Crash (only works in release mode)
	at io.sentry.react.n.u(SourceFile:5)
	at io.sentry.react.RNSentryModule.crash(SourceFile:3)
	at com.facebook.jni.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:1)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(SourceFile:36)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.b(SourceFile:1)
	at com.facebook.react.bridge.queue.b.run(SourceFile:1)
	at java.lang.Thread.run(Thread.java:1012) 
@krystofwoldrich
Copy link
Member

Hi @lovegaoshi,
thank you for the message,

Sentry.nativeCrash() should still crash the app, we are not planing deprecation of the method.

We will investigate this further.

What version of RN are you using?

@lovegaoshi
Copy link
Author

lovegaoshi commented Jan 15, 2025 via email

@lovegaoshi
Copy link
Author

heres the reproducer - its directly adapted from my own app, but everything in App.tsx (the entry point) are removed, with a call to Sentry.nativeCrash left. the app should immediately crash as opened.

new arch log:

2025-01-15 09:35:51.791 12205-12240 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.handleHostException(message = "TEST - Sentry Client Crash (only works in release mode)")
2025-01-15 09:35:51.792 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask()
2025-01-15 09:35:51.792 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "TEST - Sentry Client Crash (only works in release mode)")
2025-01-15 09:35:51.792 12205-12238 unknown:ReactHost       com.noxplay.noxplayer                E  Unhandled SoftException
                                                                                                    com.facebook.react.bridge.ReactNoCrashSoftException: raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "TEST - Sentry Client Crash (only works in release mode)")
                                                                                                    	at com.facebook.react.runtime.ReactHostImpl.raiseSoftException(ReactHostImpl.java:942)
                                                                                                    	at com.facebook.react.runtime.ReactHostImpl.getOrCreateDestroyTask(ReactHostImpl.java:1575)
                                                                                                    	at com.facebook.react.runtime.ReactHostImpl.lambda$destroy$7(ReactHostImpl.java:541)
                                                                                                    	at com.facebook.react.runtime.ReactHostImpl.$r8$lambda$uso21_D6dCZdcf-JomVD56kdG4c(Unknown Source:0)
                                                                                                    	at com.facebook.react.runtime.ReactHostImpl$$ExternalSyntheticLambda37.call(D8$$SyntheticClass:0)
                                                                                                    	at com.facebook.react.runtime.internal.bolts.Task$2.run(Task.java:240)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.lang.RuntimeException: TEST - Sentry Client Crash (only works in release mode)
                                                                                                    	at io.sentry.react.RNSentryModuleImpl.crash(RNSentryModuleImpl.java:392)
                                                                                                    	at io.sentry.react.RNSentryModule.crash(RNSentryModule.java:47)
                                                                                                    	at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                    	at android.os.Looper.loop(Looper.java:317)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012) 
2025-01-15 09:35:51.792 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Starting React Native destruction
2025-01-15 09:35:51.792 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Move ReactHost to onHostDestroy()
2025-01-15 09:35:51.793 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactContext.onHostPause()
2025-01-15 09:35:51.793 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactContext.onHostDestroy()
2025-01-15 09:35:51.799 12205-12205 unknown:ReactNative     com.noxplay.noxplayer                E  Tried to remove non-existent frame callback
2025-01-15 09:35:51.799 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Stopping all React Native surfaces
2025-01-15 09:35:51.800 12205-12238 unknown:Su...ingManager com.noxplay.noxplayer                E  Stopping surface [11]
2025-01-15 09:35:51.800 12205-12205 unknown:Su...ingManager com.noxplay.noxplayer                E  Surface [11] was stopped on SurfaceMountingManager.
2025-01-15 09:35:51.808 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Destroying MemoryPressureRouter
2025-01-15 09:35:51.808 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Resetting ReactContext ref
2025-01-15 09:35:51.808 12205-12205 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Destroying ReactContext
2025-01-15 09:35:51.815 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Resetting ReactInstance ptr
2025-01-15 09:35:51.819 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Destroying ReactInstance
2025-01-15 09:35:51.825 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                E  Tried to remove non-existent frame callback
2025-01-15 09:35:51.831 12205-12238 ReactNativeJNI          com.noxplay.noxplayer                W  Scheduler::~Scheduler() was called (address: 0x7c391b7a9130).
2025-01-15 09:35:51.832 12205-12238 ReactNativeJNI          com.noxplay.noxplayer                W  UIManagerBinding::~UIManagerBinding() was called (address: 0x7c391b7aa7a8).
2025-01-15 09:35:51.835 12205-12238 ReactNativeJNI          com.noxplay.noxplayer                W  UIManager::~UIManager() was called (address: 0x7c3aeb7a15d0).
2025-01-15 09:35:51.836 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.839 12205-12238 unknown:ReactNative     com.noxplay.noxplayer                W  Tried to enqueue runnable on already finished thread: 'v_native... dropping Runnable.
2025-01-15 09:35:51.846 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Resetting createReactInstance task ref
2025-01-15 09:35:51.846 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Resetting start task ref
2025-01-15 09:35:51.846 12205-12238 unknown:BridgelessReact com.noxplay.noxplayer                W  ReactHost{0}.getOrCreateDestroyTask(): Resetting destroy task ref
2025-01-15 09:35:56.099 12205-12321 ProfileInstaller        com.noxplay.noxplayer                D  Installing profile for com.noxplay.noxplayer

(process is never stopped this way)

old arch log:

2025-01-15 09:42:42.244  4142-4259  unknown:Vi...rtyUpdater com.noxplay.noxplayer                W  Could not find generated setter for class com.reactnativecommunity.webview.RNCWebViewManager
--------- beginning of crash
2025-01-15 09:42:42.450  4142-4259  AndroidRuntime          com.noxplay.noxplayer                E  FATAL EXCEPTION: mqt_native_modules
                                                                                                    Process: com.noxplay.noxplayer, PID: 4142
                                                                                                    java.lang.RuntimeException: TEST - Sentry Client Crash (only works in release mode)
                                                                                                    	at io.sentry.react.RNSentryModuleImpl.crash(RNSentryModuleImpl.java:392)
                                                                                                    	at io.sentry.react.RNSentryModule.crash(RNSentryModule.java:47)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
                                                                                                    	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:146)
                                                                                                    	at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                    	at android.os.Looper.loop(Looper.java:317)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
2025-01-15 09:42:42.486  4142-4259  Process                 com.noxplay.noxplayer                I  Sending signal. PID: 4142 SIG: 9
---------------------------- PROCESS ENDED (4142) for package com.noxplay.noxplayer ----------------------------

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 15, 2025
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