-
-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v4] | [v2] BottomSheetModal failing to present on iOS #1560
Comments
Same happening to us, affecting at least 15 users so far. Bottom sheet 4.5.1 |
Same here, animateOnMount to false does fix the issue but really low number of users affected. |
Thanks @SrAnthony and @LouisKraemer good to hear that you are also experiencing the same issue for your users. I haven't been able to deepdive into the animation implementation but hopefully @gorhom can give some insight or potential avenue's we can explore for a fix |
Same here, we are also using expo sdk 49. It also happens on android |
Same issue here, more and more users are starting to complain about this - also unable to reproduce for us on simulator or our testing devices. This is happening for our users on both v4 and v5. |
Some of our users are affected as well. Reanimated recently added support for this setting -> https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility/ |
wow great spot @hatem-72 , did you manage to create a patch for this lib? |
For the moment, I've only disabled the opening animation for users with reduced motion : import { useReducedMotion } from 'react-native-reanimated';
import { BottomSheetModal } from '@gorhom/bottom-sheet';
// ...
function MyComponent() {
const reducedMotion = useReducedMotion();
return <BottomSheetModal
// ...
animateOnMount={!reducedMotion}
>
// ...
</BottomSheetModal>
} |
@hatem-72 great find! reached out to 2 users who were having this issue and they both had it enabled. |
Can we buy @hatem-72 a coffee? |
Thanks @hatem-72 for the fix. I have another bug, I can't dismiss the bottom modal 2 times. If I dismiss, open it again, I can't dismiss it. I found a workaround by overriding ref :
|
@karbone4 I am unable to reproduce your bug. It works for me |
Hello everyone! Setting diff --git a/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts b/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
index 9b3fcb1..0111380 100644
--- a/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
+++ b/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
@@ -49,5 +49,5 @@ export function isReducedMotion() {
? // @ts-ignore Fallback if `window` is undefined.
!window.matchMedia('(prefers-reduced-motion: no-preference)').matches
: false
- : (global as localGlobal)._REANIMATED_IS_REDUCED_MOTION ?? false;
+ : false;
} |
Also observed on a device running Android 10 with reduce motion option enabled |
Also hitting this issue, rather than disabling the reduce motion detection for Reanimated globally we went with conditionally supplying our own animation config only when required. There are still some minor quirks when dismissing the sheet, but it does at least open and work correctly: const reduceMotionEnabled = useReducedMotion();
const overrideConfig = useBottomSheetSpringConfigs({
damping: 500,
stiffness: 1000,
mass: 3,
overshootClamping: true,
restDisplacementThreshold: 10,
restSpeedThreshold: 10,
reduceMotion: ReduceMotion.Never,
});
return (
<BottomSheetModal
/*
There's a bug in BottomSheet which means that sheets will fail to open when reduce motion is enabled. Manually
providing an animation config with `reduceMotion: ReduceMotion.Never` fixes this, but it does introduce a bit
of jank when dismissing the sheet. This is a tradeoff we're willing to make for the sake of sheets at least
working when reduce motion is enabled.
@see https://github.com/gorhom/react-native-bottom-sheet/issues/1560
*/
animationConfigs={reduceMotionEnabled ? overrideConfig : undefined}
// other config here...
/>
); The animation config was lifted from react-native-bottom-sheet/src/constants.ts Lines 68 to 75 in 65b5dc0
|
In fact, I think this problem is fundamentally a problem with the changes in Reanimated that were made when the BottomSheet version was upgraded, although BottomSheet itself handles reduceOption in a way. Simple problem solving can be done in the other comment1 and comment2 posted above. So I posted my opinion and the cause I identified on Reanimated.(software-mansion/react-native-reanimated#5314 (comment)) |
As I see, reduced motion is also enabled if low power mode is active and device battery is <= 10%. Almost all screenshots from our user reports shows that their device battery are <= 10%. Apple mentions this here, under Low Power Mode title. So it may be a wider issue than we think, not related with accessibility settings only. |
Thank you very much. This is the root cause of my case |
Although I tested setting reducedMotion to false, it's not a viable solution because the problem still appears from time to time. I think it's a fundamental problem with how Reanimated and BottomSheet works as @Gyogle states. |
Inspired by the above answer, main difference being the import of import { useBottomSheetSpringConfigs } from "@gorhom/bottom-sheet"
import { ANIMATION_CONFIGS } from "@gorhom/bottom-sheet/src/constants"
import { Platform } from "react-native"
import { ReduceMotion, WithTimingConfig, useReducedMotion } from "react-native-reanimated"
/**
* https://github.com/gorhom/react-native-bottom-sheet/issues/1560
*
* Usage:
* ```
* const animationConfigs = useBottomSheetAnimationConfigsReducedMotionWorkaround()
* <BottomSheetModal animationConfigs={animationConfigs} ...>
* ```
*
* @returns
*/
export function useBottomSheetAnimationConfigsReducedMotionWorkaround():
| WithTimingConfig
| undefined {
const reducedMotion = useReducedMotion()
const iOSAnimationConfigWithoutReducedMotion = useBottomSheetSpringConfigs({
...ANIMATION_CONFIGS,
reduceMotion: ReduceMotion.Never,
})
if (Platform.OS !== "ios" || !reducedMotion) return undefined
return iOSAnimationConfigWithoutReducedMotion
} |
@gorhom would the above be worth a v4 patch release? |
Tried the fix by @levibuzolic / @mattijsf. That works most of the time but got some weird issues when having multiple BottomSheets. Also tried disabling motion, that was very weird. Currently using the reanimated patch by @leymytel, that seems to be working fine. @gorhom It would be really great if you can look into this. |
In my case, one of our users had the "Reduce Motion" option enabled and that caused the modals to not open. It was solved as follows
@hatem-72 Thanks!! |
@leymytel this patch includes animation for users who have enabled motion reduction, I think not everyone will be happy with this behavior |
This issue will cause a lot of users to be completely unable to use the Apps that uses this library. If you have time, can you please have a look? @gorhom 💗 |
The change from @hatem-72 should be included in the main code base of the bottom sheet. |
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 stale |
With last release it was solved. I've checked on my iOS app and it works as expected. This issue should be closed @walterholohan @gorhom |
This problem is still relevant. On version 4.6.3 it is much less common, but still exists "react-native": "0.73.4", |
I fixed this in my app and wanted to share all I learned (some of this may be repeating what was said above): BACKGROUND
MY WORKAROUND (THEORY) MY WORKAROUND'S CODE const [bottomSheetBumpKey, setBottomSheetBumpKey] = useState<number>(0);
const reduceMotionEnabled = useReducedMotion();
return (<BottomSheetModalProvider>
<BottomSheetModal
index={0}
ref={bottomSheetModalRef}
snapPoints={bottomModalSnapPoints}
backgroundComponent={null} // This is required to make the modal dark
// HACKS! (needed as of v4.6.3)
// 1. On android: when the user (or battery saver) enables "Reduced Motion" or "Reduced Animation", it makes the bottom sheet flicker / never appear.
// -- video: https://www.loom.com/share/d131efdd0b8e4e12b30afb7dd605a7e7
// -- details: https://github.com/gorhom/react-native-bottom-sheet/issues/1560#issuecomment-1774254176
// -- workaround: manually disable animations in this case (animateOnMount=false)
// 2. On android: when animations are disabled (animateOnMount=false), the bottom sheet ref can only dismiss the UI once.
// -- workaround: change the key when we dismiss (if animateOnMount=false), forcing a rerender + a new ref
// NOTE: there was an *attempt* to fix this in Bottom Sheet v4.6.3, but it's buggy and causes crashes - next version should fix?
key={`bottom-sheet-modal-${bottomSheetBumpKey}`}
animateOnMount={!reduceMotionEnabled}
onDismiss={() => {
if (reduceMotionEnabled) {
setBottomSheetBumpKey((existing) => existing + 1);
}
}}>
<MyCoolComponent/>
)}
</BottomSheetModal>
</BottomSheetModalProvider>); |
Can confirm, issue is no longer present in release 4.6.3, together with |
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 stale |
For me it is working fine with React Native old architecture. When I adapt new architecture and using 2 layers more of export const MainComponent = () => {
const bottomSheetRef = useRef(null)
return (
<>
<Button onPress={() => { bottomSheetRef.current?.present() }}> // <-- the present function is invoked but nothing happens
Show sheet
</Button>
<ExampleSheet ref={bottomSheetRef} snapPoints={['50%']}>
</>
)
}
export const ExampleSheet = forwardRef((props, ref) => {
return (
<>
...
<BaseSheet ref={ref} {...props}>
</>
)
})
export const BaseSheet = forwardRef((props, ref) => {
return (
<>
...
<BaseSheet ref={ref} {...props}>
</>
)
}) |
What is the current status on this issue at the moment? I am still using the following patch which feels outdated. diff --git a/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts b/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
index a2bcdee..9afa9e1 100644
--- a/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
+++ b/node_modules/react-native-reanimated/src/reanimated2/PlatformChecker.ts
@@ -51,5 +51,5 @@ export function isReducedMotion() {
? // @ts-ignore Fallback if `window` is undefined.
!window.matchMedia('(prefers-reduced-motion: no-preference)').matches
: false
- : !!(global as localGlobal)._REANIMATED_IS_REDUCED_MOTION;
+ : false;
} |
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 stale |
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 issue was closed because it has been stalled for 5 days with no activity. |
Not stale |
@DimaShumanskiy |
Bug
We just recently updated RN to 0.72.5 and react-native-reanimated to 3.5.4 and released it to production over the weekend. And then we started to get reports from our users that the modals were failing to appear. I will attach some videos below but we were unable to reproduce it on a simulator or a real device however we have ~150,000 MAU so after 24 hours we had over 10 users who were affected.
We had users on iOS 16.x and iOS 17.x who were affected
To unblock our users I had to set animateOnMount to false which makes me believe the issue is with the opening animation of the modal and reanimated
Environment info
Steps To Reproduce
Link Activity
and you can see the modal briefly flashesReferral Code
and again the modal flashes and closesRPReplay_Final1696360061.mov
Reproducible sample code
The text was updated successfully, but these errors were encountered: