-
-
Notifications
You must be signed in to change notification settings - Fork 864
Description
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:
- The
BottomSheet
does the initial rendering pass, which sets up a lot of variables and calls theOnSnapPointsChange
handler with new result[-999]
and previous valuenull
. This pass exits early becauseisLayoutCalculated
isfalse
. - The
BottomSheet
gets rendered a second time, after theanimatedContainerHeight
is set, but beforeanimatedContentHeight
and/oranimatedHandleHeight
. SinceenableDynamicSizing
is false, this pass returns a final value foranimatedSnapPoints
. 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 becauseisLayoutCalculated
is stillfalse
, due to not yet havinganimatedContentHeight
and/oranimatedHandleHeight
. - The
BottomSheet
is rendered a third time, but now bothanimatedContentHeight
andanimatedHandleHeight
have been computed.OnSnapPointsChange
is called yet again with result[100]
and previous value[100]
. Since they are the same, andisAnimatedOnMount
istrue
(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