react-native-reanimated: Flickering appears in 3.6.0 that is not present in 3.5.4

Description

Flickering is introduced in 3.6.0, iOS, that wasn’t present in earlier versions. I’m using interpolation to control height for a div above the one shown on the video in comments section. while expanding the view (thus the animated height), it starts flickering from version 3.6.0.

here is the code i’m using:

  const stepsHeight = useAnimatedStyle(() => {
    const height = interpolate(
      animatedPosition.value,
      [0, maxDP - midDP, maxDP],
      [
        maxDP -
          midDP,
        0,
        0,
      ],
      Extrapolation.CLAMP,
    );
    return { height };
  });


      <Animated.View style={stepsHeight} />

i've tried IDENTITY, EXTEND and none as well, nothing seems to help but downgrading to 3.5.4

my RN version is 0.72.10

### Steps to reproduce

1. animate height with interpolation
2. observe flicker when height is expanded

Flicker while expanding (version 3.6.0 and above)

https://github.com/software-mansion/react-native-reanimated/assets/34944192/9096c1da-b2f0-472f-a686-869538043a88

No flicker while expanding (version 3.5.4)
https://github.com/software-mansion/react-native-reanimated/assets/34944192/90f72f91-cc28-4a56-99bd-f72df09c1662



### Snack or a link to a repository

https://snack.expo.dev/RC7Hq5kJ_955Xxi0i-qI3
### Reanimated version

3.6.0

### React Native version

0.72.1

### Platforms

iOS

### JavaScript runtime

None

### Workflow

React Native

### Architecture

Paper (Old Architecture)

### Build type

Release app & dev bundle

### Device

iOS simulator

### Device model

iPhone 12 pro and iPhone 15 pro

### Acknowledgements

Yes

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 5
  • Comments: 42 (8 by maintainers)

Most upvoted comments

This is clearly visible when you try to animate height/width and transform at the same time. Seems like layout animation can’t keep up with the transform. And I meet this only in release mode ios v3.5.4

https://github.com/user-attachments/assets/8ab9e877-c68e-4e68-85a9-0088e0939387

v3.6.0 - v3.14.0

https://github.com/user-attachments/assets/0f1faf85-7c2e-484f-bf3a-d1ac5b2e3573

ok, i got it

try this code, and try it on a real device

import { View, Text, useWindowDimensions } from 'react-native';
import Animated, {
  useAnimatedStyle,
  interpolate,
  useSharedValue,
  Extrapolation,
} from 'react-native-reanimated';
import BottomSheet from '@gorhom/bottom-sheet';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

export default function App() {
  const animatedPosition = useSharedValue(0);
  const maxDP = useWindowDimensions().height;

  const midDP = maxDP / 2;
  const stepsHeight = useAnimatedStyle(() => {
    const height = interpolate(
      animatedPosition.value,
      [0, maxDP - midDP, maxDP],
      [maxDP - midDP, 0, 0],
      Extrapolation.CLAMP,
    );
    return { height, backgroundColor: 'blue' };
  });

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <BottomSheet
        animatedPosition={animatedPosition}
        index={0}
        enablePanDownToClose
        snapPoints={['50%', '100%']}>
        <Animated.View style={stepsHeight} />
        <View style={{ height: 300 }}>
          <Text>Should be sticky</Text>
        </View>
      </BottomSheet>
    </GestureHandlerRootView>
  );
}

@gorhom/bottom-sheet this lib also uses reanimated, v2 but according to your docs there are no breaking changes, so i guess that should be alright

just expand it fully and go back to the middle and you’ll notice the stutter. i can confirm that this stuttering is not present in

v3.5.4

https://github.com/software-mansion/react-native-reanimated/assets/34944192/70de5d6c-fb10-4360-b1b2-fda365270ecb

~3.10.1 (with expo)

https://github.com/software-mansion/react-native-reanimated/assets/34944192/0eeaa841-2b56-435c-885c-7fe4ca6f85ce

hey @bartlomiejbloniarz , how is it going? are there any good news? 😃

Adding enableStallTracking: false option to ReactNativeTracing in Sentry.init fixed the issue for me

I don’t know if it’s related or not, but we had a similar bug in Production mode, but only on build from expo eas, and only on some devices (It was affecting iPhone 15, 15 pro, 12 mini, but not iPhone 11 pro). Switching to Github actions with Fastlane resolved it for us, which is something beyond my comprehension.

Edit: After more research the bug was not coming from eas compilaton but from our sentry integration.

Hey, currently, we have a lot of work related to the new React Native architecture, and we are running out of capacity to handle this issue right now. We do intend to fix it, but at this moment, I can’t provide any time estimation for its resolution 😕

@lichstam Have you found a fix yet? Im having the same issue when animating with, height and transforming

nop, i’m relying on @bartlomiejbloniarz here 😃

Hey @lichstam, meanwhile, would you like to see if this patch changes anything? reanimated_3.13.0_styles.patch It is meant for 3.13.0 though. It has already been shown to fix at least couple of stutters in animations. Even though the problem occured somwhere between 3.8 and 3.9, there is no harm in trying it as well

Hi! I searched through PRs that were merged in this release. It seems that the offending PR is Fix race-condition during render. This was an important bug-fix so we need some time to properly address it.

hey, i’m trying to recreate an example but with no luck. i will try more tomorrow.

the gist is that there is one component that expands from not visible (0 in height) to the amount of the fully expanded modal. this way, the first component that you see in the video stays fixed in place. but for some reason there is this stuttering in the newer versions of reanimated