[Bug]: Bottom sheet doesn't render with `enableDynamicSizing: false` if content or handle height take too long to compute
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
BottomSheetdoes the initial rendering pass, which sets up a lot of variables and calls theOnSnapPointsChangehandler with new result[-999]and previous valuenull. This pass exits early becauseisLayoutCalculatedisfalse. - The
BottomSheetgets rendered a second time, after theanimatedContainerHeightis set, but beforeanimatedContentHeightand/oranimatedHandleHeight. SinceenableDynamicSizingis false, this pass returns a final value foranimatedSnapPoints. Since the snap points changed,OnSnapPointsChangeis 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 becauseisLayoutCalculatedis stillfalse, due to not yet havinganimatedContentHeightand/oranimatedHandleHeight. - The
BottomSheetis rendered a third time, but now bothanimatedContentHeightandanimatedHandleHeighthave been computed.OnSnapPointsChangeis called yet again with result[100]and previous value[100]. Since they are the same, andisAnimatedOnMountistrue(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
same issue here
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.
Still an issue.
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.
This is still an issue.
Experiencing the same issue.
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.
Not fixed, don't close. @gorhom please either fix issues faster or get rid of the stale bot.