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 Blinking Issue when swiping #662

Closed
sohuichoi opened this issue Sep 6, 2024 · 3 comments
Closed

Android Blinking Issue when swiping #662

sohuichoi opened this issue Sep 6, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@sohuichoi
Copy link

sohuichoi commented Sep 6, 2024

Describe the bug

At the moment when swiping to right, the data in the render item changes from the current to prior data.
This issue only occurs in the Android.
How can I resolve?

To Reproduce
Steps to reproduce the behavior:
The attached gif file shows the blinking issue.
I set the video speed from 1 to 0.25.
If I revert the card by swiping toward left, it's fine.
but the issue occurs when swiping toward right.
Sep-06-2024 13-12-26

Expected behavior

I hope the animation shows smoothly, not blinking.
Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • react: v18.2.0
  • react-native: v0.73.4
  • react-native-reanimated: v3.15.1
  • react-native-reanimated-carousel: v4.0.0-alpha.12
  • react-native-gesture-handler: v2.16.2

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

the following is adjusted code.

import { colorSystem } from '@/styles/theme';
import React, { memo, useState } from 'react';
import { Text } from 'react-native';
import Animated from 'react-native-reanimated';
import Carousel from 'react-native-reanimated-carousel';
import styled from 'styled-components/native';

const CustomCarousel = ({ screenWidth, data, viewCount }) => {
	return (
		<>
			<Carousel
				style={{
					width: '100%',
					height: '100%',
					alignItems: 'flex-end',
					justifyContent: 'center',
					alignSelf: 'center',
					borderWidth: 1,
					borderColor: 'red',
				}}
				width={screenWidth - 40}
				height={320}
				pagingEnabled={true}
				snapEnabled={false}
				windowSize={2}
				mode='vertical-stack'
				loop={true}
				autoPlay={false}
				autoPlayReverse={false}
				data={data}
				modeConfig={{
					snapDirection: 'right',
					stackInterval: -24,
					opacityInterval: 0.01,
					moveSize: screenWidth,
				}}
				defaultIndex={data.length - 1}
				renderItem={({ item, index }) => <MemoizedItem item={item} index={index} />}
			/>
		</>
	);
};

export default CustomCarousel;
const colors = ['#33FF57', '#a0a8c0', '#3357FF', '#33FF57', '#33FF57'];

const MemoizedItem = memo(
	({ item, index }) => (
		<Test style={{ backgroundColor: colors[index % colors.length] }}>
			<Text
				style={{
					fontSize: 50,
				}}
			>
				{item}
			</Text>
		</Test>
	),
	(prevProps, nextProps) => prevProps.index === nextProps.index
);

const Test = styled(Animated.View)`
	background-color: ${colorSystem.pink[200]};
	width: 100%;
	max-width: 384px;
	height: 320px;
	padding: 24px 20px 0px;
	border-radius: 16px;
	border-width: 1px;
	align-self: center;
`;
@sohuichoi sohuichoi added the bug Something isn't working label Sep 6, 2024
Copy link

dosubot bot commented Sep 6, 2024

Hey @sohuichoi 👋, I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve this issue!

I found some similar issues that might help you resolve the Android blinking issue when swiping right in your react-native-reanimated-carousel:

  1. Image Flickers When Swiping Carousel (Open)

    • Suggested solutions include optimizing image loading, using a cached image component, and avoiding unnecessary re-rendering. Additionally, using the react-native-reanimated-carousel library with custom animations can help reduce flickering [1].
  2. Weird animation issue with Expo SDK 50 (Open)

  3. Carousel disappear on swipe/drag on Expo RN Web (Open)

    • This issue was resolved by ensuring the correct version of dependencies and reinstalling pods after trying different versions [3].

Additionally, there are some relevant bug fixes in the repository that address similar blinking issues:

  • Commit 96c9b75: "fix item blink when scroll active"
  • Commit 063f564: "item blink"

Ensure you are using the latest version of the library where these fixes are included. You can update to the latest version using:

npm install react-native-reanimated-carousel@latest

If the issue persists, consider reviewing the changes made in the mentioned commits to understand the specific fixes applied [4].

By following these suggestions and ensuring you have the latest updates, you should be able to resolve the blinking issue on Android.

To continue talking to Dosu, mention @dosu.

@nmassey
Copy link
Contributor

nmassey commented Sep 6, 2024

hi @sohuichoi -
I've got a patch waiting for review that I hope will resolve this issue. Does this seem to be the same bug?

@sohuichoi
Copy link
Author

Hello @nmassey
Yes That's absolutely the same issue with me!
Thanks to the recommended PR, I could resolve the issue by downgrading the version from 4.0.0-alpha.12 to 3.5.1.

@dohooo dohooo closed this as completed Sep 11, 2024
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

3 participants