meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.37k stars 2.29k forks source link

memory leak bug plz #797

Open jhui134 opened 3 years ago

jhui134 commented 3 years ago

Is this a bug report, a feature request, or a question?

bug report!

Have you followed the required steps before opening a bug report?

(Check the step you've followed - put an x character between the square brackets ([]).)

Have you made sure that it wasn't a React Native bug?

(Write your answer here.) yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

both platforms android 9.0 ios 14.2

Is the bug reproductible in a production environment (not a debug one)?

no

Environment

hello

memory leak occurs ParallaxImage in both platforms and It does not occur if you annotate ParallaxImage....

my code

class MainLikeCafe extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            activeSlide: 0,
            likeCafeArr: [],
        };
    }

    onSlideBanner = (index) => {
        this.setState({
            activeSlide: index,
        });
    };
    renderItem = ({ item, index }, parallaxProps) => {
        return (
            <View style={{ flex: 1 }}>
                <View style={{ height: 300 }}>
                    <ParallaxImage
                        source={item.url ? { uri: item.url } : require('@/Assets/Images/Home/banner01.png')}
                        // source={{ uri: item.url }}
                        containerStyle={{ height: 300, borderRadius: 8 }}
                        style={{ resizeMode: 'cover' }}
                        parallaxFactor={0.3}
                        {...parallaxProps}
                    />
                </View>
            </View>
        );
    };
    render() {
        let likeCafeArr = [];
        if (this.props.mainList && this.props.mainList.data.likeCafe) {
            likeCafeArr = this.props.mainList.data.likeCafe;

        }

        return (
            <View style={{ marginTop: 60, paddingLeft: 20 }}>

                <View style={{ marginTop: 20 }}>
                    <View style={{ height: 347 }}>
                        <Carousel
                            ref={(ref) => {
                                this.carouselRef = ref;
                            }}
                            layout={'default'}
                            data={likeCafeArr}
                            renderItem={this.renderItem}
                            sliderWidth={width}
                            sliderHeight={341}
                            itemWidth={width * 0.6}
                            inactiveSlideScale={0.7}
                            activeSlideAlignment={'start'}
                            firstItem={this.state.activeSlide}
                            hasParallaxImages={true}
                            removeClippedSubviews={true}
                            onSnapToItem={(index) => this.onSlideBanner(index)}
                        />
                    </View>
                </View>
            </View>
        );
    }
}

스크린샷 2021-01-06 오후 12 44 44

gXiaofei commented 3 years ago

I also met

dohooo commented 3 years ago

Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2