-
-
Notifications
You must be signed in to change notification settings - Fork 329
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][v4.0.0-canary.17] Carousel crashes the app #712
Comments
Hey @Bekaxp! I'm here to help you with any issues you're experiencing. I can assist you in solving bugs, answering questions, and becoming a contributor. A similar issue regarding a "Loss of precision during arithmetic conversion" error has been reported and resolved. The suggested solution involves ensuring that arithmetic operations involving floating-point numbers are correctly handled before casting to a long. You can use const value = 388.7273063659668;
const longValue = Math.round(value); // Use Math.round to avoid precision loss Additionally, ensure your module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
}; Make sure your project is using compatible versions of the dependencies: "dependencies": {
"react": "18.3.1",
"react-native": "0.76.1",
"react-native-reanimated": "3.16.1",
"react-native-reanimated-carousel": "4.0.0-canary.17",
"react-native-gesture-handler": "2.20.2"
} These steps should help resolve the issue and ensure compatibility [1]. |
Thank you but as you can see in my simple example I am not doing any conversions of any sort. I guess this is done internally in the lib to calculate the positioning? Cheers |
Hi there! |
I upgraded to 4.0.0~canary-17 and no issue was found. previous const parallelX = (value: number) => {
'worklet';
const zIndex = interpolate(value, [-1, 0, 1], [10, 20, 30]);
const scale = interpolate(value, [-2, -1, 0, 1, 2], [0.7, 0.8, 1, 0.8, 0.7]);
const opacity = interpolate(value, [-0.75, 0, 1], [0, 1, 0]);
const translateX = interpolate(value, [-1, 0, 1], [-PAGE_WIDTH * 0.5, 0, PAGE_WIDTH]);
return {
transform: [{ translateX }, { scale }],
zIndex,
opacity,
};
}; new const parallelX = (value: number) => {
'worklet';
const zIndex = Math.round(interpolate(value, [-1, 0, 1], [10, 20, 30]));
const scale = interpolate(value, [-1, 0, 1], [0.8, 1, 0.8]);
const opacity = interpolate(value, [-1, 0, 1], [0, 1, 0]);
const translateX = Math.round(interpolate(value, [-1, 0, 1], [-PAGE_WIDTH * 0.3, 0, PAGE_WIDTH * 0.3]));
return {
transform: [{ translateX }, { scale }] as const,
zIndex,
opacity,
};
}; Trying to add Math.*** |
@Yusang-park Did you test it on Android? I don't have any custom animation:
|
Have a look at the discussion in #715 . There is also a PR open to fix this. I tried with the patch from @thibaultcapelli and it worked. So I will happily wait for the PR to be merged and a new canary version to be released 👍 . Thanks. |
Describe the bug
On Android when the user tries to scroll the carousel the app crashes and closes itself. Inspecting with Android Studio gives this error (top of the error stack):
Maybe is even a bug with the
react-native-reanimated
, but I tried several versions and I always get the same results.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The Android app should not crash and the Carousel should scroll.
Versions (please complete the following information):
Smartphone (please complete the following information):
Additional context
react-native-reanimated-carousel
The text was updated successfully, but these errors were encountered: