react-native-reanimated: [Android] Native crash on React Native 0.65-rc3 / reanimated 2.3 alpha 2

Description

The application ends up crashing after a few seconds of use with an issue seemingly originated in libreanimated.so:

react-native-reanimated@^2.3.0-alpha.2: react-native@^0.65.0-rc.3

The logs are from a simulator but it also happens on device. Please do let me know if I can provide you with any more debug info.

The crash:

tombstoned: received crash request for pid 16158
crash_dump64: performing dump of process 15998 (target tid = 16158)
DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys'
DEBUG   : Revision: '0'
DEBUG   : ABI: 'x86_64'
DEBUG   : Timestamp: 2021-08-04 16:45:05+0100
DEBUG   : pid: 15998, tid: 16158, name: hades  >>> com.getpaired.app <<<
DEBUG   : uid: 10160
DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
DEBUG   : Abort message: 'terminating with uncaught exception of type std::runtime_error: Unable to retrieve jni environment. Is the thread attached?'
DEBUG   :     rax 0000000000000000  rbx 0000000000003e7e  rcx 000077e3ffd1d2a8  rdx 0000000000000006
DEBUG   :     r8  0000000000000000  r9  0000000000000000  r10 000077e10f8f9fd0  r11 0000000000000246
DEBUG   :     r12 000077e10f8fa1c0  r13 0000003000000008  r14 000077e10f8f9fc8  r15 0000000000003f1e
DEBUG   :     rdi 0000000000003e7e  rsi 0000000000003f1e
DEBUG   :     rbp 000077e10f8fa660  rsp 000077e10f8f9fb8  rip 000077e3ffd1d2a8
DEBUG   : backtrace:
DEBUG   :       #00 pc 000000000005a2a8  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+24) (BuildId: 3707c39fc397eeaa328142d90b50a973)
DEBUG   :       #01 pc 000000000005d212  /apex/com.android.runtime/lib64/bionic/libc.so (abort+194) (BuildId: 3707c39fc397eeaa328142d90b50a973)
DEBUG   :       #02 pc 00000000000a729b  /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64/libc++_shared.so (BuildId: 013d16f5e2afb684dc5c7ebda3499fd97205ac47)
DEBUG   :       #03 pc 00000000000a745d  /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64/libc++_shared.so (BuildId: 013d16f5e2afb684dc5c7ebda3499fd97205ac47)
DEBUG   :       #04 pc 00000000000bd4d2  /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64/libc++_shared.so (BuildId: 013d16f5e2afb684dc5c7ebda3499fd97205ac47)
DEBUG   :       #05 pc 00000000000bd468  /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64/libc++_shared.so (std::terminate()+40) (BuildId: 013d16f5e2afb684dc5c7ebda3499fd97205ac47)
DEBUG   :       #06 pc 00000000000d1b5e  /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64/libreanimated.so (BuildId: 62098f20cee9b154bcc6f0be2e58717a622f9f32)

Previous logs from application launch: 15998 15998 W m.getpaired.ap: Unexpected CPU variant for X86 using defaults: x86_64

D SoLoader: init start
D SoLoader: adding system library source: /vendor/lib64
D SoLoader: adding system library source: /system/lib64
D SoLoader: adding application source: com.facebook.soloader.DirectorySoSource[root = /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64 flags = 0]
D SoLoader: adding backup source from : com.facebook.soloader.ApkSoSource[root = /data/data/com.getpaired.app/lib-main flags = 1]
D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /data/app/~~lmq3je1BbxNWbJtPz5Bjig==/com.getpaired.app-inlOIcjHWLG8qEZZwKEhfg==/lib/x86_64 flags = 0]
D SoLoader: Preparing SO source: com.facebook.soloader.ApkSoSource[root = /data/data/com.getpaired.app/lib-main flags = 1]
V fb-UnpackingSoSource: locked dso store /data/user/0/com.getpaired.app/lib-main
V fb-UnpackingSoSource: deps mismatch on deps store: regenerating
V fb-UnpackingSoSource: so store dirty: regenerating
08-04 16:42:14.620 15998 15998 D ApkSoSource: not allowing consideration of lib/x86_64/libreanimated.so: deferring to libdir

Expected behavior

Actual behavior & steps to reproduce

Can’t reproduce it deterministically, it always happens after a few seconds.

Snack or minimal code example

I hope the above stack traces can help narrow down the issue, we have a very complex app with heavy use of reanimated.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 32
  • Comments: 30 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I am also running into this issue on android with the react-native-reanimated@2.3.0-alpha.2 release.

Description

The application crashes immediately when running on android in the simplest use case.

Expected behavior

The application does not crash.

Actual behavior & steps to reproduce

Create a bare react native project. Install react-native-reanimated@2.3.0-alpha.2, follow the instructions for the android setup and then build the app. The app builds successfully on android studio but crashes immediately when trying to run it.

If I downgrade the version of react-native-reanimated to 2.2.0 in the same project it starts working again.

This problem ONLY exists on android. On iOS version 2.3.0-alpha.2 works fine.

Snack or minimal code example

https://github.com/hmust92/AwesomeProject

git clone https://github.com/hmust92/AwesomeProject

npm install

npm start

build with android studio (or run npm run android)

Package versions

  • React Native: 0.64.2
  • React Native Reanimated:2.3.0-alpha.2

Affected platforms

  • Android
  • iOS
  • Web

It seems that 2.3.0-alpha.3 has just been released, but I’m getting the same crash on Android.

There does seem to be a difference, it crashes a bit later. With alpha.2 it was crashing instantly. But with alpha.3 I can interact with the app a bit before it crashes.

signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'terminating with uncaught exception of type std::runtime_error: Unable to retrieve jni environment. Is the thread attached?'
    x0  0000000000000000  x1  000000000000741f  x2  0000000000000006  x3  000000703c858e50
    x4  fefefefefefefeff  x5  fefefefefefefeff  x6  fefefefefefefeff  x7  7f7f7f7f7f7f7f7f
    x8  00000000000000f0  x9  e141945ad3c060c7  x10 0000000000000000  x11 ffffffc0fffffbdf
    x12 0000000000000001  x13 0000054acec8d75a  x14 0032f644493fbe00  x15 0000000029aaaaab
    x16 000000733aeccc80  x17 000000733aeae3f0  x18 00000070240cc000  x19 0000000000007343
    x20 000000000000741f  x21 00000000ffffffff  x22 ffffff80ffffffc8  x23 000000703c8590a0
    x24 000000703c858f80  x25 000000703c858fc0  x26 0000000000000022  x27 0000000000000001
    x28 0000000000000670  x29 000000703c858ed0
    lr  000000733ae61e20  sp  000000703c858e30  pc  000000733ae61e4c  pst 0000000000001000
backtrace:
      #00 pc 000000000004de4c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ac8f7173c886715a2f2fec67246e21da)
      #01 pc 00000000000a01bc  /data/app/~~SEOKB12EXe-KGn4-AvZ9Iw==/poker.lets.android-pnZabrWOMlEiA11JIZ2UGA==/lib/arm64/libc++_shared.so (BuildId: 6de1c39a010a6596b5bb6546e6fe55445b037c1b)
      #02 pc 00000000000a03b0  /data/app/~~SEOKB12EXe-KGn4-AvZ9Iw==/poker.lets.android-pnZabrWOMlEiA11JIZ2UGA==/lib/arm64/libc++_shared.so (BuildId: 6de1c39a010a6596b5bb6546e6fe55445b037c1b)
      #03 pc 00000000000b4208  /data/app/~~SEOKB12EXe-KGn4-AvZ9Iw==/poker.lets.android-pnZabrWOMlEiA11JIZ2UGA==/lib/arm64/libc++_shared.so (BuildId: 6de1c39a010a6596b5bb6546e6fe55445b037c1b)
      #04 pc 00000000000b41a0  /data/app/~~SEOKB12EXe-KGn4-AvZ9Iw==/poker.lets.android-pnZabrWOMlEiA11JIZ2UGA==/lib/arm64/libc++_shared.so (std::terminate()+36) (BuildId: 6de1c39a010a6596b5bb6546e6fe55445b037c1b)
      #05 pc 00000000000d1544  /data/app/~~SEOKB12EXe-KGn4-AvZ9Iw==/poker.lets.android-pnZabrWOMlEiA11JIZ2UGA==/lib/arm64/libreanimated.so (BuildId: cc781b612ce4d32ce71ab169b388f207be7658bc)

This issue is probably related to this Hermes’s issue: https://github.com/facebook/hermes/issues/590

Just got a different stacktrace for an android crash on 2.3.0-alpha.3 if this helps:

signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.RuntimeException: java.lang.AssertionError: Illegal type provided
  at void com.swmansion.reanimated.AndroidErrorHandler.raise(java.lang.String) (AndroidErrorHandler.java:6)
  at void com.swmansion.reanimated.Scheduler.triggerUI() (Scheduler.java:-2)
  at void com.swmansion.reanimated.Scheduler$1.run() (Scheduler.java:23)
  at void com.swmansion.reanimated.Scheduler$2.runGuarded() (Scheduler.java:41)
  at void com.facebook.react.bridge.GuardedRunnable.run() (GuardedRunnable.java:31)
  at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:938)
  at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
  at void android.os.Looper.loop() (Looper.java:223)
  at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7656)
  at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
  at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:592)
  at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:947)

    in call to GetObjectRefType
    from void com.swmansion.reanimated.Scheduler.triggerUI()'
    x0  0000000000000000  x1  000000000000789c  x2  0000000000000006  x3  0000007ff12e6d10
    x4  fefefefefefefeff  x5  fefefefefefefeff  x6  fefefefefefefeff  x7  7f7f7f7f7f7f7f7f
    x8  00000000000000f0  x9  e141945ad3c060c7  x10 0000000000000000  x11 ffffffc0fffffbdf
    x12 0000000000000001  x13 0000000000000602  x14 ff00000000000000  x15 ffffffffffffffff
    x16 000000733aeccc80  x17 000000733aeae3f0  x18 000000733c184000  x19 000000000000789c
    x20 000000000000789c  x21 00000000ffffffff  x22 000000000000000b  x23 000000000000000b
    x24 00000070a6161007  x25 0000000000000001  x26 00000070a6177f5c  x27 00000070a677d000
    x28 b4000070c67a8990  x29 0000007ff12e6d90
    lr  000000733ae61e20  sp  0000007ff12e6cf0  pc  000000733ae61e4c  pst 0000000000001000
backtrace:
      #00 pc 000000000004de4c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ac8f7173c886715a2f2fec67246e21da)
      #01 pc 000000000055d030  /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2308) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #02 pc 0000000000013978  /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76) (BuildId: 7f81cc97d60164bfae3b52a2cd822f20)
      #03 pc 0000000000012fa4  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+320) (BuildId: 7f81cc97d60164bfae3b52a2cd822f20)
      #04 pc 00000000003851cc  /apex/com.android.art/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+2572) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #05 pc 0000000000385244  /apex/com.android.art/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+108) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #06 pc 0000000000376f28  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+144) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #07 pc 0000000000375a40  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+3108) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #08 pc 00000000003746a0  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+612) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #09 pc 0000000000373d78  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetObjectRefType(_JNIEnv*, _jobject*)+692) (BuildId: b628ec1e4df42966356fcd82bcb1136d)
      #10 pc 0000000000019098  /data/app/~~nzJ9MEXLGxWkpojT1e3-rA==/poker.lets.android-PFTw5ZQxDPGcJ3W0eF4cyQ==/lib/arm64/libfbjni.so (facebook::jni::isObjectRefType(_jobject*, jobjectRefType)+76) (BuildId: 5b9237c4cf8ff477d69b3a6401b060d9b7f17a75)
      #11 pc 0000000000131524  /data/app/~~nzJ9MEXLGxWkpojT1e3-rA==/poker.lets.android-PFTw5ZQxDPGcJ3W0eF4cyQ==/lib/arm64/libreanimated.so (facebook::jni::LocalReferenceAllocator::verifyReference(_jobject*) const+32) (BuildId: cc781b612ce4d32ce71ab169b388f207be7658bc)
      #12 pc 000000000013159c  /data/app/~~nzJ9MEXLGxWkpojT1e3-rA==/poker.lets.android-PFTw5ZQxDPGcJ3W0eF4cyQ==/lib/arm64/libreanimated.so (facebook::jni::LocalReferenceAllocator::deleteReference(_jobject*) const+80) (BuildId: cc781b612ce4d32ce71ab169b388f207be7658bc)
      #13 pc 00000000001314e4  /data/app/~~nzJ9MEXLGxWkpojT1e3-rA==/poker.lets.android-PFTw5ZQxDPGcJ3W0eF4cyQ==/lib/arm64/libreanimated.so (facebook::jni::base_owned_ref<facebook::jni::JString, facebook::jni::LocalReferenceAllocator>::reset(_jstring*)+144) (BuildId: cc781b612ce4d32ce71ab169b388f207be7658bc)
      #14 pc 000000000013142c  /data/app/~~nzJ9MEXLGxWkpojT1e3-rA==/poker.lets.android-PFTw5ZQxDPGcJ3W0eF4cyQ==/lib/arm64/libreanimated.so (facebook::jni::base_owned_ref<facebook::jni::JString, facebook::jni::LocalReferenceAllocator>::reset()+28) (BuildId: cc781b612ce4d32ce71ab169b388f207be7658bc)

I don’t think #2040 is related, that crash was originally reported on 2.1.0 as well, but we weren’t having any crashes up until 2.3.0-alpha.

I believe 2.3.0-alpha.2 is unfortunately completely broken on Android currently.

There seems to be a 2.2.1 version planned which brings RN 0.65 support on the 2.2.0 line. It was initially scheduled for last week, but it seems it got delayed.

The 2.3.0 crash might’ve been introduced by #1879 as per other reports. I’m hoping that 2.2.1 will work properly.

@piaskowyk I also remember that everything seemed to work fine on 0.64 while creating the repro in https://github.com/software-mansion/react-native-reanimated/issues/2256#issuecomment-912539629.

I believe the crash started occurring after updating the project to 0.65 indeed.

I was able to create a repro for this. It seems to be a race condition of some sort because if I delay adding the component that uses reanimated for a bit, the crash doesn’t occur. But if it’s added at app start, it crashes.

This branch shows it: https://github.com/andreialecu/rnctv-react-native-bare-test/tree/bug-androidcrash

Relevant files: https://github.com/andreialecu/rnctv-react-native-bare-test/blob/bug-androidcrash/Crash.tsx And: https://github.com/andreialecu/rnctv-react-native-bare-test/blob/c2afa0f3030d96c9c9530feb75379a30d38b7036/App.tsx#L90

It’s a dirty repro, but I just hacked it together quick based on a real app it occurs in.

(cc @piaskowyk @jmysliv)

@KoreanThinker , hey let’s don’t chase the guys so much. We are all would like to use the latest react-native version with reanimated on board, but let’s try to be patience 😃 Hope we will see 2.2.1 or new alpha soon 😃

Hello guys,

I have changed my hermes to false and it works for me (no crash). I don’t know about hermes but it work.

image

@piaskowyk when will 2.2.1 be release?