software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.99k stars 1.3k forks source link

App crashes with EXC_CRASH (SIGABRT) when reloading on iOS #3895

Open ansh opened 1 year ago

ansh commented 1 year ago

Description

A video of the crash happening https://user-images.githubusercontent.com/8207733/210131053-51c7ff0a-d9ee-4b10-80a0-1f10c0e273b7.mp4

The error I get after the crash

CleanShot 2022-12-31 at 14 23 42@2x CleanShot 2022-12-31 at 14 24 00@2x

Full error text: https://textbin.net/apakzpco91

I have tried 3.0.0-rc.9 and rc.8 and they kind of reduce the probability of issue but they do not fix it. Also, they introduce another bug shown below. So basically, they just make the crash non-deterministic.

CleanShot 2022-12-31 at 14 02 12@2x

Steps to reproduce

  1. Use npx create-expo-app to create a new Expo app
  2. Install reanimated + expo-dev-client
  3. Build using EAS or npx expo prebuild + npx expo run:ios
  4. Open the app
  5. Press the "R" key rapidly in quick succession on the keyboard a couple of times
  6. You will most definitely experience a crash

Snack or a link to a repository

https://github.com/ansh/reanimated-reload-crash

Reanimated version

2.12.0

React Native version

0.70.5

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

ansh commented 1 year ago

@EvanBacon It's weird that this crash only happens when I use expo-dev-client and not when I use Expo Go with the same versions of everything (repro provided above). Tagging you in case you know something about this.

sangameshsomawar commented 1 year ago

@ansh did you get any solution? I am getting same error.

xanderdeseyn commented 1 year ago

We are seeing the same issue here. Anyone found a solution?

sangameshsomawar commented 1 year ago

It got resolved after running watchman watch-del-all and yarn start --reset-cache

xanderdeseyn commented 1 year ago

Doesn't seem to fix it in our case

Norfeldt commented 1 year ago

It got resolved after running watchman watch-del-all and yarn start --reset-cache

that did not work for me either.. 😢

I have narrowed it down to be because I'm doing some runOnJS(feedback)({ skipPlatform: ['web'] }) to trigger haptic feedback. It worked a while for me to convert the gesture to do .runOnJS(true)

const feedback = (options?: { skipPlatform?: (typeof Platform.OS)[] }) => {
    if (options?.skipPlatform?.includes(Platform.OS)) return
    try {
      throttleFeedback()
    } catch (error) {
      Sentry.Native.captureMessage('failed JS thread (haptic) feedback on Chart', 'warning')
    }
  }
  const panGesture = Gesture.Pan()
    .runOnJS(true) // https://docs.swmansion.com/react-native-gesture-handler/docs/2.3.0/api/gestures/pan-gesture/#runonjsvalue-boolean
    .onBegin((event) => {
      scrollX.value = event.absoluteX
      labelViewOpacity.value = 1
      pointDate.value = processedData[index.value].date
      pointValue.value = processedData[index.value].value
      feedback({ skipPlatform: ['web'] })
    })

but now that does not seem to work any more. 🤷‍♂️

Norfeldt commented 1 year ago

I have solved it by not calling it in development mode by a conditional barrel export

import { hapticFeedback as feedbackDevelopment } from './index.development' // just a () => {}
import { hapticFeedback as feedbackProduction } from './index.production'

const hapticFeedback = __DEV__ ? feedbackDevelopment : feedbackProduction

export { hapticFeedback }
xanderdeseyn commented 1 year ago

We are not using runOnJS anywhere in our codebase but are still experiencing this issue.

ansh commented 1 year ago

@Norfeldt Sorry, I do not understand. You solved it by not calling what in development mode? What was your version of reanimated? What were the steps you took?

Norfeldt commented 1 year ago

@ansh is this the information you need?

const panGesture = Gesture.Pan()
    .runOnJS(true)
    .minDistance((Layout.window.width - 2 * Layout.safeHorizontalPadding) / 200)
    .onBegin((event) => {
      scrollX.value = event.absoluteX
      labelViewOpacity.value = 1
      pointDate.value = processedData[index.value].date
      pointValue.value = processedData[index.value].value
      hapticFeedback({ skipPlatform: ['web'] })
    })
    .onUpdate((event) => {
      scrollX.value = event.absoluteX
      // can't use useDerivedValue since it does not have access to own values (lastTwoIndexes.value[1])
      lastTwoIndexes.value = [lastTwoIndexes.value[1] ?? 0, index.value]
      if (lastTwoIndexes.value[0] !== lastTwoIndexes.value[1]) {
        pointDate.value = pData.value[index.value].date
        pointValue.value = processedData[index.value].value
        hapticFeedback({ skipPlatform: ['android'] }) // android haptic feedback vibration is too much
        Platform.select({
          web: forceUpdate,
        })
      }
    })
    .onFinalize(() => {
      labelViewOpacity.value = 0
      hapticFeedback({ skipPlatform: ['web'] })
    })

package.json

    "expo": "^47.0.12",
    "expo-dev-client": "~2.0.1",
    "react-native-gesture-handler": "~2.8.0",
    "react-native-reanimated": "~2.12.0",

I have attempted to make a snack once, but that was not able to reproduce the error that was causing it to crash.

carneiror commented 1 year ago

Same error with latest versions:

"react-native-gesture-handler": "2.9.0",
"react-native-reanimated": "3.2.0",
timoisalive commented 1 year ago

I've also been experiencing this for some time and wonder if there are any updates on the topic?

NadeemKhanFh commented 1 year ago

having same issue as well.

kyle-ssg commented 12 months ago

This seems to be happening with CodePush updates too in case anyone tracks down this issue.

Edit: Updating to v3 of reanimated fixes my issue.

marcinknara-saige commented 11 months ago

Received the same error with a different stack trace. Beta app fails on startup, although the splash screen does popup ever so briefly.