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

useAnimatedProps with FlatList has crash for Android ! #2573

Closed
1 of 3 tasks
pioner92 opened this issue Oct 25, 2021 · 3 comments
Closed
1 of 3 tasks

useAnimatedProps with FlatList has crash for Android ! #2573

pioner92 opened this issue Oct 25, 2021 · 3 comments
Labels
Bug bug-bash-jan22 Issues visited during Bug Bash Jan 2022 Close when stale This issue is going to be closed when there is no activity for a while 🏠 Reanimated 2

Comments

@pioner92
Copy link

Description

I am using useAnimatedProps for contentOffset:{ x:0, y:animatedValue.value } for FlatList , and get error for Android , IOS working good !

Expected behavior

The FlatList changes its y-offset

Actual behavior & steps to reproduce

The application exits with an error

    --------- beginning of crash
2021-10-25 11:17:10.329 19795-19795/com.pizza A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 19795 (com.pizza), pid 19795 (com.pizza)
2021-10-25 11:17:09.689 19795-19795/com.pizza E/unknown:FabricViewStateManager: setState called without a StateWrapper

Snack or minimal code example

const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);

...


 const scrollOffsetValue = useSharedValue({key: '', value: 0});
 const scrollValue = useSharedValue(0);


  const onScrollVerticalList = useAnimatedScrollHandler<{y: number}>({
    onScroll: e => {
      scrollValue.value = e.contentOffset.y;
    },
  });

 const onEndScroll = useCallback(key => {
    scrollOffsetValue.value = {
      key,
      value: Math.min(Math.max(scrollValue.value, 0), HEADER_HEIGHT),
    };
  }, []);

const renderItem = ({ routeKey, scrollOffsetValue, onEndScroll, onScrollVerticalList }) => {

  ...

  const animatedProps = useAnimatedProps(() => {
    if (scrollOffsetValue.value.key !== routeKey) {
      return {
        contentOffset: {
          x: 0,
          y: scrollOffsetValue.value.value,
        },
      };
    }
    return {};
  });

  return (
    <View style={UIStyles.flex}>
      <AnimatedFlatList
        bounces={false}
        style={styles.listStyle}
        onScroll={onScroll}
        animatedProps={animatedProps}
        onScrollEndDrag={onEndScrollHandler}
        onMomentumScrollEnd={onEndScrollHandler}
        ref={listRef}
        showsVerticalScrollIndicator={false}
        keyExtractor={keyExtractorVerticalList}
        contentContainerStyle={contentContainerStyle_}
        initialNumToRender={7}
        maxToRenderPerBatch={7}
        windowSize={5}
        scrollEventThrottle={16}
        data={productIds}
        renderItem={renderItem}
      />
    </View>
  );
};
}

Package versions

  • React Native: 0.64.0
  • React Native Reanimated: 2.3.0-beta.2
  • NodeJS: v16.9.1
  • Xcode: 12.5
  • Java & Gradle: 1.8.0_281 & 4.1.0

Affected platforms

  • Android
  • iOS
  • Web
@github-actions
Copy link

Issue validator

The issue is valid!

@pioner92 pioner92 changed the title useAnimatedProps with FlatList have crash for Android ! useAnimatedProps with FlatList has crash for Android ! Oct 25, 2021
@tomekzaw
Copy link
Member

Hello @pioner92! It looks like you're running your app with Fabric enabled (based on FabricViewStateManager in the logs you have provided). Unfortunately, Reanimated 2 does not support Fabric yet, but we're actively working on it so please stay tuned 😄

@kmagiera
Copy link
Member

@pioner92 can you confirm if @tomekzaw's comment has helped in resolving the problem?

@kmagiera kmagiera added bug-bash-jan22 Issues visited during Bug Bash Jan 2022 Close when stale This issue is going to be closed when there is no activity for a while labels Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug bug-bash-jan22 Issues visited during Bug Bash Jan 2022 Close when stale This issue is going to be closed when there is no activity for a while 🏠 Reanimated 2
Projects
None yet
Development

No branches or pull requests

3 participants