react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

[Bug]: Bottom sheet doesn't render with `enableDynamicSizing: false` if content or handle height take too long to compute

Open simon-abbott opened this issue 5 months ago • 8 comments

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS

What happened?

There is a race condition with the initial render when using enableDynamicSizing = false. It is possible for the following series of events to occur:

  1. The BottomSheet does the initial rendering pass, which sets up a lot of variables and calls the OnSnapPointsChange handler with new result [-999] and previous value null. This pass exits early because isLayoutCalculated is false.
  2. The BottomSheet gets rendered a second time, after the animatedContainerHeight is set, but before animatedContentHeight and/or animatedHandleHeight. Since enableDynamicSizing is false, this pass returns a final value for animatedSnapPoints. Since the snap points changed, OnSnapPointsChange is called again, this time with a final value for "result" (let's call it [100]), and a previous value of [-999]). This pass again exits early because isLayoutCalculated is still false, due to not yet having animatedContentHeight and/or animatedHandleHeight.
  3. The BottomSheet is rendered a third time, but now both animatedContentHeight and animatedHandleHeight have been computed. OnSnapPointsChange is called yet again with result [100] and previous value [100]. Since they are the same, and isAnimatedOnMount is true (as it has been since the first render), it exits early again.

This means that the initial call to evaluatePosition() is never actually run, and so the bottom sheet just sits in limbo and never finishes rendering.

Reproduction steps

Unfortunately due to this being a race condition I have had a really hard time making a minimal reproduction. I can reproduce it fairly reliably locally, so I am happy to help test out any fixes, but I have not been able to reduce it to something small, especially not one that works in Snack.

(default link included anyway because otherwise the issue gets autoclosed with no way for me to appeal it)

Reproduction sample

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

Relevant log output


simon-abbott avatar Aug 01 '25 17:08 simon-abbott

same issue here

geroale avatar Aug 11 '25 13:08 geroale

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 11 '25 09:09 github-actions[bot]

Still an issue.

simon-abbott avatar Sep 11 '25 14:09 simon-abbott

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 13 '25 09:10 github-actions[bot]

This is still an issue.

simon-abbott avatar Oct 14 '25 02:10 simon-abbott

Experiencing the same issue.

jpm-nz avatar Oct 22 '25 22:10 jpm-nz

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 22 '25 09:11 github-actions[bot]

Not fixed, don't close. @gorhom please either fix issues faster or get rid of the stale bot.

simon-abbott avatar Nov 25 '25 19:11 simon-abbott