react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

App crashes randomly - only Android 12 and mostly Samsung devices

Open ilyagru opened this issue 3 years ago • 12 comments

Description

I'm opening an issue here for one which is reported to the React Native team. Could you take a look please? Maybe it is related? I think the react-native-reanimated team might have some fresh ideas on how to resolve it.

  • https://github.com/facebook/react-native/issues/33375 App crashes randomly - only Android12 #33375

Expected behavior

No crash.

Actual behavior & steps to reproduce

To reproduce you need at least:

  1. Android 12
  2. Samsung device
  3. React Native 0.68.2

Crashes as https://github.com/facebook/react-native/issues/33375#issuecomment-1139618328

Please see the whole thread for more logs and info.

Snack or minimal code example

For example, here is a reproduction https://github.com/facebook/react-native/issues/33375#issuecomment-1059844263 https://github.com/jefersonvinicius/react-native-crashing-example

Package versions

This information is also available in the thread.

name version
react-native 0.68.2
react-native-reanimated ^2.8.0
NodeJS
Xcode
Java
Gradle
expo

Affected platforms

  • [x] Android
  • [ ] iOS
  • [ ] Web

ilyagru avatar Jun 13 '22 07:06 ilyagru

We are having this issue as well, except we're on React Native 0.64.3. Only seeing it on Samsung devices on Android 12.

jarredt avatar Jun 13 '22 19:06 jarredt

Wondering if https://github.com/software-mansion/react-native-reanimated/issues/3080 is related.

jarredt avatar Jun 13 '22 19:06 jarredt

Yes @jarredt it seems occuring only on Samsungs with Android 12. #3080 might be related. It looks like many people who updating their devices to Android 12 and start experience the crash, even in different React Native apps. Any ideas for a workaround?

ilyagru avatar Jun 14 '22 07:06 ilyagru

Nope, spent several days on it and it seemed to be tied to our introduction of reanimated to our app, so we ultimately removed reanimated and went in a different direction.

jarredt avatar Jun 14 '22 12:06 jarredt

expo: 45.0.0 react-native: 0.68.2 react-native-reanimated: 2.8.0

I too noticed this issue cropping up amongst Android 12/Samsung devices once we upgraded to Expo SDK 45.

Our app makes use of React Navigation 6 and react-native-reanimated is a dependency so I cannot remove it.

I created a minimal Expo test app to evaluate and it is if in fact the addition of this package that causes it to crash on Android 12/Samsung devices. If I remove it, the crashing stops.

#3080 does seem to be related.

https://github.com/facebook/react-native/issues/33375 appears to be the root issue/cause. Some comments suggest RN 0.69.0 will address but it would be good to have some confirmation from RN devs + react-native-reanimated devs on Samsung devices.

Below is the code I used for my test. Take out reanimated and it should stop crashing on these devices.

{
  "name": "expo-demo",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/stack": "^6.2.1",
    "expo": "~45.0.0",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "expo-updates": "~0.13.2",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-reanimated": "~2.8.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}
// App.js

import * as SplashScreen from 'expo-splash-screen';
import React, { useEffect, useState } from 'react';
import RootNavigator from './src/navigation/RootNavigator';

export default function App() {
  const [appIsReady, setAppIsReady] = useState(false);

  useEffect(() => {
    async function initApp () {
      try {
        await SplashScreen.preventAutoHideAsync();
      } catch (e) {
        console.log(e);
      } finally {
        setAppIsReady(true);
      }
    }

    initApp();
  }, []);

  if (!appIsReady) {
    return null;
  }

  return (
    <RootNavigator />
  );
}

// RootNavigator.js

import * as SplashScreen from 'expo-splash-screen';
import React, { useEffect, useState } from 'react';
import RootNavigator from './src/navigation/RootNavigator';

export default function App() {
  const [appIsReady, setAppIsReady] = useState(false);

  useEffect(() => {
    async function initApp () {
      try {
        await SplashScreen.preventAutoHideAsync();
      } catch (e) {
        console.log(e);
      } finally {
        setAppIsReady(true);
      }
    }

    initApp();
  }, []);

  if (!appIsReady) {
    return null;
  }

  return (
    <RootNavigator />
  );
}

webdevmario avatar Jun 18 '22 18:06 webdevmario

Hi! Any update on this one? RN 0.69.1 hasn't resolved this issue. And since there is a repro, could anyone from maintainers please take a look?

ilyagru avatar Jul 13 '22 08:07 ilyagru

@ilyagru Disappointing to read that 0.69.1 does not address. https://github.com/facebook/react-native/issues/33375 has a lot of activity as of late. I noticed this issue says "1 of 3 tasks" complete. Do all 3 need to complete before maintainers start taking a look?

webdevmario avatar Jul 13 '22 12:07 webdevmario

@webdevmario "1 of 3 tasks" means it is not related to tasks but to the affected platforms, it occurs only on Android, hence 1 checkbox is checked.

ilyagru avatar Jul 13 '22 12:07 ilyagru

@ilyagru Ah, I see. Thank you for clarifying. Definitely just Android. 😫

webdevmario avatar Jul 13 '22 13:07 webdevmario

Hi, just wondering if anyone knows of any movement on this issue? I can see in the thread in the react-native repo there has been a bunch of comments and a repro, but no updates or fixes. This is currently affecting quite a lot of our users, is there anything that could be done in the meantime to prevent this error from happening? Keen to help where possible, but not at all a native developer sadly.

RhyG avatar Jul 29 '22 04:07 RhyG

Any updates?

MuhammadRafeh avatar Jul 31 '22 09:07 MuhammadRafeh

could this be related to #3234? we are experiencing the same issue, it seems like it happens when using predefined animations, in my case is FadeInUp

robertwt7 avatar Aug 01 '22 03:08 robertwt7

Having similar issues too, application crashes on android 12, Samsung device, has there been a fix on this?

joviksdev avatar Aug 17 '22 21:08 joviksdev

I also have crash on my release at first time only for Samsung android 12 phone. I need to maintain react-native-reanimated for react-navigation/drawer. So, not fundamental solution,

  1. I used react-native-restart for resetting app first time only.
  2. I used react-native-device-info check Samsung and 12 version

It could be temporary solution. (In my case, after mounting of navigation's drawer, reset needs to be executed. After a few times of test, I chose 2s)

// MainComponent.js 
...
useEffect(() => {
    const checkFirst = async () => {
      const brand = await getBrand();
      const version = await getSystemVersion();
      getItemFromAsync('notFirst').then(notFirst => {
        if (!notFirst && brand === 'samsung' && version === '12') {
          setItemToAsync('notFirst', true);
          setTimeout(() => {
            RNRestart.Restart();
          }, 2000);
        }
      });
    };

    checkFirst();
  }, []);
...

bangdy avatar Aug 29 '22 16:08 bangdy

I solve the issue by changing targetSdkVersion = 31 to argetSdkVersion = 30

vincemavill avatar Nov 08 '22 05:11 vincemavill

maintain react-native-reanimated for react-navigation/drawer. So, not fundamental solution,

How you uploaded the app with targetSdkVersion 30 ? Google play console is asking for target 31 or higher.

vjsingh95 avatar Dec 04 '22 10:12 vjsingh95

right @vjsingh95 if we need to upload the app on the google play console then it must targetSdkVersion = 31.

codal-mpawar avatar Dec 23 '22 11:12 codal-mpawar

Did you find a way to fix this issue ? Thanks

jonathanroze avatar Mar 07 '23 09:03 jonathanroze

I am also experiencing this issue just on samsung devices

grant-solomons avatar Mar 07 '23 10:03 grant-solomons

Please add below line to build gradle file.

implementation 'androidx.work:work-runtime:2.7.1'

vjsingh95 avatar Mar 08 '23 04:03 vjsingh95

Please add below line to build gradle file.

implementation 'androidx.work:work-runtime:2.7.1'

Thanks, I already try this way, an this error is still throw on Android 12!

jonathanroze avatar Mar 08 '23 08:03 jonathanroze

Any solution for this? Notifications working when app in foreground but in background not working in targetsdkversion 31.

lakshminarayana254 avatar Apr 03 '23 08:04 lakshminarayana254

Any solution for this? Notifications working when app in foreground but in background not working in targetsdkversion 31.

you should add POST_NOTIFICATION permission for targetsdkversion-31 android 13

adityabrovitech avatar May 06 '23 14:05 adityabrovitech

Did you find a way to fix this issue ? Thanks

Arise-cn avatar Oct 12 '23 10:10 Arise-cn

Closing since we have limited our support for Reanimated v2 since release of the Reanimated 3, please upgrade

Latropos avatar Dec 15 '23 12:12 Latropos