react-native-bottom-sheet: [Bug]: Laggy and doesn't fully open with new architecture

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS

What happened?

I just switched from expo 50 / RN 0.74 / old architecture to expo 52 / RN 0.76 / new architecture. The library upgrade went without problems but when I switched to the new architecture, most bottom sheets are laggy or don’t fully open the first time I mount them on iOS simulator (I haven’t tested on a real device yet).

First video is with expo 52 and old architecture, second and third videos are with expo 52 and new architecture. The event sheets are dynamically sized, and the location ones have fixed snap points.

I’m wondering if other people are experiencing similar issues? I’ve looked at a bunch of threads and some comments hint at similar problems with Fabric, but I haven’t found one that fit exactly this case.

https://github.com/user-attachments/assets/edeefd01-73aa-4fb3-9baa-874a5b6affce

https://github.com/user-attachments/assets/3a345692-a752-4cd5-819e-0427f8281a30

https://github.com/user-attachments/assets/91e29956-52ec-40f8-8703-29dcdf38ccbf

Reproduction steps

At this point I don’t know how to properly repro, I just added newArchEnabled: true to app.config.ts, rebuilt and the issue appeared. I’ve tried switching again and the problem disappears on the old arch + rebuild.

I’ve also tried removing Sentry in case it was the problem but it does not seem to make a difference. Other potentially conflicting libraries: nativewind, tanstack query with useQuery hooks in the bottom sheets (wrapped through trpc).

I added a straight link to the snack template with this lib and RNR bumped to the latest version and expo switched to 52. It looks janky to me but honestly with snack it’s impossible to tell.

Reproduction sample

https://snack.expo.dev/@alexdb/bottom-sheet---issue-reproduction-template

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 63
  • Comments: 35 (1 by maintainers)

Most upvoted comments

@gorhom Why you closed this issue? It lages with new arch for both iOS and Android. There are no specific examples, you can just turn off and turn on the new arch. You will see the difference.

I was able to fix the lag by specifying a custom backdropComponent prop. I copied most of the default BottomSheetBackdrop besides some unnecessary code for my purposes, and specifically removed the flex: 1 line here which caused me a lot of lag. I instead use StyleSheet.absoluteFill in the containerStyle return array.

@garrettwesley thank you, this might make finding the root cause easier! For what it’s worth, I already use a custom backdrop component everywhere:

const AnimatedPressable = Animated.createAnimatedComponent(Pressable);

const CustomBackdrop = ({ style }: BottomSheetBackdropProps) => {
  const { close } = useBottomSheet();
  return (
    <AnimatedPressable
      onPress={() => close()}
      entering={FadeIn.duration(50)}
      exiting={FadeOut.duration(20)}
      style={[style, { backgroundColor: "rgba(0, 0, 0, 0.4)" }]}
    />
  );
};

and this is my base modal (so adding the custom backdrop and top inset, I handle bottom inset through bottom padding in the scrollables and/or footer):

export const BottomSheetModal = forwardRef<
  NBottomSheetModal,
  BottomSheetModalProps
>(({ ...props }, ref) => {
  const insets = useSafeAreaInsets();
  return (
    <NBottomSheetModal
      ref={ref}
      backdropComponent={CustomBackdrop}
      topInset={insets.top}
      {...props}
    />
  );
});

Everyone that’s commenting “same”, please add a thumbs up on the first comment, it makes life easier for everyone 😃

Actually, it’s not only this library that lags. Almost any pop-up modal in the new architecture and expo 52 experiences significant lag. For example:

Also, in many places my layout broke. Unfortunately, this makes the new architecture not very usable right now.

@gorhom Could you please explain why it was ‘closed this as completed’? Is it because the animation lag issue is not related to this library? Could it be caused by the new RN architecture or the Reanimated library? This is a serious issue that has affected so many users, yet it was marked as ‘closed this as completed’ without any response.

Actually, under the new architecture, not only the @gorhom/bottom-sheet but also animations in other parts feel a bit laggy in debug mode— it’s just that the @gorhom/bottom-sheet stutter is more noticeable. Things are much better in release mode.

Edit: These is a new arc animation performance issue: Animation is 20x slower in New Architecture

I noticed that whenever these animations happen, there seems to be a warning appearing. I couldn’t figure out the cause, could this warning be related to the lag?

console.js:614 [Reanimated] Reading from value during component render. Please ensure that you don’t access the value property nor use get method of a shared value while React is rendering a component. If you don’t want to see this message, you can disable the strict mode. Refer to: https://docs.swmansion.com/react-native-reanimated/docs/debugging/logger-configuration for more details.

same issue here, it’s laggy if using the new architecture

I am, too. I can confirm that removing the custom backdrop, or creating a new custom backdrop component, fixed the issue for me.

Using this custom backdrop (copied form Bluesky’s social-app) seems to fix the issue:

import React, { useMemo } from 'react';
import { TouchableWithoutFeedback } from 'react-native';
import Animated, {
  Extrapolation,
  interpolate,
  useAnimatedStyle
} from 'react-native-reanimated';
import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';

/**
 * This is a custom backdrop that seems to have less lag when used vs. rendering a default backdrop.
 * Copied from Bluesky's custom backdrop in their social-app repo.
 */
export function createCustomBackdrop(
  onClose?: (() => void) | undefined
): React.FC<BottomSheetBackdropProps> {
  const CustomBackdrop = ({
    animatedIndex,
    style
  }: BottomSheetBackdropProps) => {
    // animated variables
    const opacity = useAnimatedStyle(() => ({
      opacity: interpolate(
        animatedIndex.value, // current snap index
        [-1, 0], // input range
        [0, 0.5], // output range
        Extrapolation.CLAMP
      )
    }));

    const containerStyle = useMemo(
      () => [style, { backgroundColor: '#000' }, opacity],
      [style, opacity]
    );

    return (
      <TouchableWithoutFeedback
        onPress={onClose}
        accessibilityLabel="Close bottom drawer"
        accessibilityHint=""
        onAccessibilityEscape={() => {
          if (onClose !== undefined) {
            onClose();
          }
        }}
      >
        <Animated.View style={containerStyle} />
      </TouchableWithoutFeedback>
    );
  };
  return CustomBackdrop;
}

Still having this issue on the latest version

Same issue here, laggy with expo v52 and new architecture.

Same here at least for the lag part even though it seem like other animations in reanimated also have the same aggresive jitter at the end of the animation.

Hey @gorhom, I can see it’s been marked as completed, do you need a reproducible example or has the issue been fixed?

Can confim that by removing the backdropComponent, the lagging stops.

Can confirm serious jittering after upgrading to the new architecture. Downgrading until I have time after work hours to provide a repro.

Still having this issue on the latest version

@iam047 just remove the custom backdrop or create a new custom backdrop component.

The same issue with Bottom Sheet Modal

I was quickly repeating opening closing BottomSheetModal on Android and the app would be unresponsive.

“react-native”: “0.76.2”, “@gorhom/bottom-sheet”: “^5.0.6”, “react-native-gesture-handler”: “^2.21.2”, “react-native-reanimated”: “^3.16.2”,