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

iOS crash when starting to drag #748

Open
rousseau634 opened this issue Dec 20, 2024 · 6 comments
Open

iOS crash when starting to drag #748

rousseau634 opened this issue Dec 20, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@rousseau634
Copy link

rousseau634 commented Dec 20, 2024

I got this crash

libc++abi: terminating due to uncaught exception of type folly::ConversionError: Loss of precision during arithmetic conversion: (long long) 99.46


    <Carousel
      data={data}
      height={100}
      pagingEnabled={true}
      snapEnabled={true}
      width={Constants.DeviceWidth - 2 * 24}
      style={{
        marginTop: 24,
        alignItems: 'center',
        justifyContent: 'center',
        width: '100%',
        height: 160
      }}
      mode={'vertical-stack'}
      modeConfig={{
        snapDirection: 'left',
        stackInterval: 10
      }}
      customConfig={() => ({ type: 'positive', viewCount: 1 })}
      renderItem={InsightCarouselCell}
    />

Versions (please complete the following information):

  • react: 18.3.1

  • react-native: 0.76.0

  • react-native-reanimated: 3.16.1

  • react-native-reanimated-carousel: 4.0.0-canary.22

  • react-native-gesture-handler: 2.21.2

  • Device: iPhone16 Pro

  • OS: iOS18.1

@rousseau634 rousseau634 added the bug Something isn't working label Dec 20, 2024
Copy link

dosubot bot commented Dec 20, 2024

Hey @rousseau634, I'm here to help you with your bug! I'm a bot designed to assist with bug fixes, answer questions, and guide you on your journey to becoming a contributor. Let's tackle this issue together!

The crash you're experiencing is due to a folly::ConversionError, which indicates a loss of precision during an arithmetic conversion. This type of error can occur when a value is being converted to a type that cannot accurately represent it, such as converting a floating-point number to an integer.

In the context of react-native-reanimated-carousel, this might be related to how drag events are handled, particularly in the arithmetic operations that calculate translations and velocities during gestures. The onGestureUpdate and onGestureEnd functions in the ScrollViewGesture component perform several arithmetic operations that could potentially lead to precision issues if not handled correctly [1].

To address this issue, you might want to:

  1. Check if there are any recent updates or patches for the react-native-reanimated-carousel that address precision issues, especially in the version you are using (4.0.0-canary.22).
  2. Review the code handling drag events to ensure that all arithmetic operations involving conversions are correctly managed, possibly by using functions that handle precision more robustly.
  3. Consider logging the values involved in these operations to identify where the precision loss might be occurring.

If the issue persists, you may need to look into the specific arithmetic operations in your implementation or the library's code to ensure they are not causing precision errors.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@satnamSandhu2001
Copy link

satnamSandhu2001 commented Dec 21, 2024

Same issue in android also

"react-native-reanimated" : "^3.16.6"
"react-native-reanimated-carousel" : "^3.5.1"

@chinhfyb12
Copy link

same issue in expo also. I realized this bug was related to updating panOffset value in onGestureStart function which is implemented in ScrollViewGesture.tsx.

"react-native-reanimated": "~3.16.1"
"react-native-reanimated-carousel": "4.0.0-canary.19"

@satnamSandhu2001
Copy link

Only happens when using "mode"

@luimont
Copy link

luimont commented Dec 23, 2024

Same issue with:

  • "react": "18.3.1",
  • "react-native": "0.76.5",
  • "react-native-reanimated": "^3.16.1",
  • "react-native-reanimated-carousel": "^3.5.1",
  • "react-native-gesture-handler": "~2.20.2",

I was solve the issue with the next changes:

Replace the zIndex variable in node_modules/react-native-reanimated-carousel/src/layouts/parallax.ts
with this:

const zIndex = Math.round(interpolate(value, [-1, 0, 1], [0, size, 0]));

image

REFERENCE: #712 (comment)

@mustafasenturk
Copy link

Loss of precision during arithmetic conversion: (long long)

works, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants