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

[Android] Native crash on React Native 0.65-rc3 / reanimated 2.3 alpha 2 #2256

Closed
beetlebum opened this issue Aug 4, 2021 · 30 comments · Fixed by #2389
Closed

[Android] Native crash on React Native 0.65-rc3 / reanimated 2.3 alpha 2 #2256

beetlebum opened this issue Aug 4, 2021 · 30 comments · Fixed by #2389

Comments

@beetlebum
Copy link

beetlebum commented Aug 4, 2021

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.

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

Issue validator

The issue is invalid!

  • Section expected behavior seems to be empty(for label 🐞 bug)
  • Section required but not found: package versions(for label 🐞 bug)

@hannojg
Copy link
Contributor

hannojg commented Aug 5, 2021

Seems similar to #2098

@hmust92
Copy link

hmust92 commented Aug 7, 2021

I am also running into this issue on android with the [email protected] 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 [email protected], 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

@sertony
Copy link

sertony commented Aug 19, 2021

I’ll copy the link to another issue with my logs about this crash: #2290 (comment)

@sertony
Copy link

sertony commented Aug 19, 2021

Apparently my crash is connected to interpolateColor method and it seems to be introduced in the following commit: 5d2cf0f#diff-7d21e3d74f24354efa89336b8bf8f70b6a9361923678365bd8219753da3f53c4R693

@mrbrentkelly
Copy link
Contributor

Getting the same issue, after upgrading to RN 0.65.1 (and reanimated 2.3.0-alpha.2) my Android app crashes on launch ( iOS works fine)...

2021-08-30 17:27:18.721 23993-24059/com.kintopo.android.local E/libc++abi: terminating with uncaught exception of type std::runtime_error: Unable to retrieve jni environment. Is the thread attached?
    
    --------- beginning of crash
2021-08-30 17:27:18.721 23993-24059/com.kintopo.android.local A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24059 (hades), pid 23993 (o.android.local)

I have a horizontal progress bar component that appears to be the culprit. When I comment it out the app launches fine...

import React, { useEffect } from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import Animated, {
  cancelAnimation,
  useAnimatedStyle,
  useSharedValue,
  withRepeat,
  withTiming,
} from 'react-native-reanimated';

const { width } = Dimensions.get('screen');

const HEIGHT = 4;
const PROGRESS_WIDTH = width / 2;
const DURATION = 1000;

const styles = StyleSheet.create({
  container: {
    width,
    height: HEIGHT,
  },
  progress: {
    width: PROGRESS_WIDTH,
    height: HEIGHT,
    backgroundColor: Color.accent,
  },
});

function ProgressBar({ visible }: { visible: boolean }): React.ReactElement {
  const translateX = useSharedValue(-PROGRESS_WIDTH);
  const animationAllowed = useSharedValue(true);

  useEffect(() => {
    animationAllowed.value = visible;
  }, [visible, animationAllowed]);

  useEffect(() => {
    if (visible) {
      translateX.value = -PROGRESS_WIDTH;

      translateX.value = withRepeat(
        withTiming(
          width,
          {
            duration: DURATION,
          },
          () => {
            if (!animationAllowed.value) {
              cancelAnimation(translateX);
            }
          }
        ),
        -1
      );
    }
  }, [translateX, visible, animationAllowed]);

  const animatedProgressStyle = useAnimatedStyle(() => ({
    transform: [{ translateX: translateX.value }],
  }));

  return (
    <View style={styles.container}>
      <Animated.View style={[styles.progress, animatedProgressStyle]} />
    </View>
  );
}

@mrbrentkelly
Copy link
Contributor

mrbrentkelly commented Aug 30, 2021

Seems to be the useAnimatedStyle that the crash occurs on. So perhaps my issue will be fixed by #2040 (#2257)?

@andreialecu
Copy link
Contributor

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.

@mrbrentkelly
Copy link
Contributor

mrbrentkelly commented Aug 30, 2021

So I managed to workaround my issue by delaying when I add my ProgressBar component to the root component tree. Now I add it to the tree when I want to use it for the first time, as opposed to it existing in the tree during app launch.

Before

function MyRootComponent() {
  return (
    <SomeProvider>
      <SomeComponent />
      {/* 
      ProgressBar is hidden on launch but Reanimated2 
      code still executes i.e. useAnimatedStyle() which
      causes the app to crash on Android
      */}
      <ProgressBar />
    </SomeProvider>
  );
}

After

function MyRootComponent() {
  return (
    <SomeProvider>
      <SomeComponent />
      {/* 
      Don't add ProgressBar to the component tree until the first time it's needed.
      App no longer crashes and progress bar appears to animate correctly again.
      */}
      {progressBarVisibleAtLeastOnce && <ProgressBar />}
    </SomeProvider>
  );
}

Having a component that uses Reanimated2 in my component tree during app launch did work prior to the RN 0.65 / Reanimated 2.3.0-alpha2 upgrade, so it does appear that there's some regression related to Reanimated2 and app launch perhaps? Specifically with useAnimatedStyle in my case.


Update: This workaround doesn't actually fix the issue 100% and I'm noticing that my app will still crash intermittently as I'm using it with the same "Unable to retrieve jni environment" error...

@KoreanThinker
Copy link

@piaskowyk when will 2.2.1 be release?

@vitto-moz
Copy link

@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 :)

@OsapBender
Copy link

OsapBender commented Sep 1, 2021

@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 :)

I can't rollback from RN 0.65.1 because I cannot install proguard-annotations-1.14.1.pom. I can't install it because facebook has removed this package. As a result, I have version 0.65.1, but it is not supported by the reanimated one. So I would like to receive the patch as soon as possible. v2 alpha breaks ios and android

proof

@andreialecu
Copy link
Contributor

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)

@andreialecu
Copy link
Contributor

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)

@sertony
Copy link

sertony commented Sep 3, 2021

Well, with 2.3.0-alpha.3 we also still face the crash with the same error message :(

Btw, the error message becomes readable once hermes is disabled.
Here is a log from my device:

09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.RuntimeException: Attempted to assign to readonly property.
09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582] _f@/Users/SerTony/ReactWorkspace/UIKit/node_modules/react-native-reanimated/src/reanimated2/Colors.ts (772:32):1:376
09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582]   at void com.swmansion.reanimated.Scheduler.triggerUI() (Scheduler.java:-2)

Again, the crash happens when we try to interpolateColor.

@andreialecu
Copy link
Contributor

Again, the crash happens when we try to interpolateColor.

We're not using interpolateColor at all here for what it's worth.

I just tried switching to JSC and the error is the same:

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)

It also seems to be the same error originally mentioned in #2098, however that report is on 2.2.0 and we were not getting this error on 2.2.0.

@mikehardy
Copy link
Contributor

@OsapBender you can always roll back

progaurd-annotations is still available, it's just on jcenter(), re-add jcenter to your list of possible maven repositories

https://mvnrepository.com/artifact/com.facebook.yoga/proguard-annotations?repo=jcenter

@piaskowyk piaskowyk added the Crash label Sep 3, 2021
andreialecu added a commit to andreialecu/rnctv-react-native-bare-test that referenced this issue Sep 3, 2021
@andreialecu
Copy link
Contributor

andreialecu commented Sep 3, 2021

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)

@alexco2
Copy link

alexco2 commented Sep 3, 2021

Well, with 2.3.0-alpha.3 we also still face the crash with the same error message :(

Btw, the error message becomes readable once hermes is disabled.
Here is a log from my device:

09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.RuntimeException: Attempted to assign to readonly property.
09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582] _f@/Users/SerTony/ReactWorkspace/UIKit/node_modules/react-native-reanimated/src/reanimated2/Colors.ts (772:32):1:376
09-03 15:04:26.356 14674 14674 F tonlabs.uikit: runtime.cc:582]   at void com.swmansion.reanimated.Scheduler.triggerUI() (Scheduler.java:-2)

Again, the crash happens when we try to interpolateColor.

Same for me regarding the color interpolation.
#2246 (comment)

@siduytruong-us
Copy link

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

@andreialecu andreialecu mentioned this issue Sep 5, 2021
3 tasks
@piaskowyk
Copy link
Member

Did someone have this problem on react native 0.64 or another version older than 0.65?

@andreialecu
Copy link
Contributor

@piaskowyk I also remember that everything seemed to work fine on 0.64 while creating the repro in #2256 (comment).

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

@hmust92
Copy link

hmust92 commented Sep 7, 2021

Did someone have this problem on react native 0.64 or another version older than 0.65?

@piaskowyk Yes, the app built successfully but crashed immediately on android on any react native version older than 0.65.0. This is with reanimated 2.3 alpha 2.

@piaskowyk
Copy link
Member

piaskowyk commented Sep 8, 2021

This issue is probably related to this Hermes's issue: facebook/hermes#590

@mikehardy
Copy link
Contributor

That issue indicates that Hermes 0.8.1 fixes the issue? And react-native 0.65 uses Hermes 0.8.1: facebook/react-native@e53745e

So, may be related but only conceptually if 0.8.1 was supposed to "fix" it ?

@piaskowyk
Copy link
Member

I have just prepared PR with a short description of the problem here: #2389

@andreialecu
Copy link
Contributor

Interesting, that seems like a different error than the one reported in #2256 (comment)

Been getting both in this project. Not sure if we should open a new issue.

@piaskowyk
Copy link
Member

@andreialecu Yes, your case looks like a different problem. Could you open a new issue?

@andreialecu
Copy link
Contributor

@piaskowyk It's the same error as in the stack trace in #2098 and #2213 (if you expand the Stack trace in each issue, they're collapsed by default)

I thought they were the same issue originally. Because our app on 2.3.0-alpha.2 crashes randomly with either JNI GetObjectRefType called with pending exception or Unable to retrieve jni environment.

If 2.2.1 (once released) does not crash with JNI GetObjectRefType called with pending exception then it can be isolated further to something in 2.3.x.

I'll test it as soon as it is released and open a new issue once I have more info.

Szymon20000 pushed a commit that referenced this issue Sep 9, 2021
Authors: @Szymon20000 @piaskowyk 
After changes in Hermes's garbage collector - the host object destructor can be called from another thread than JNI is assigned. We need to change the way of calling JNI in destructors to avoid calling a function on a null object.
We should make it like Hermes: https://github.com/facebook/hermes/blob/6e5868763b08eb80f4164a926abb92fa5c71117f/lib/Platform/Intl/PlatformIntlAndroid.cpp#L319

Related issue: facebook/hermes#590

Fixes #2256
@andreialecu
Copy link
Contributor

Just an update here. I built 2.2.1 manually and started testing it and all the crashes seem to be gone.

If anyone else wants to test 2.2.1 before it's officially released, I attached a zip of it in #2360 (comment)

The JNI GetObjectRefType called with pending exception which was happening *even with JSC on 2.3.0-alpha.2 does not occur on 2.2.1. That means it may be a regression in 2.3.0. I'll help test alpha 4 when it comes along to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.