Skip to content

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

@simon-abbott

Description

@simon-abbott

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions