react-native: ios: cannot dismiss Modal
Please provide all the information requested. Issues that do not follow this format are likely to stall.
Description
When modal is dismissed the whole screen turns black. see video
React Native version:
System:
OS: macOS 11.6
CPU: (8) x64 Apple M1
Binaries:
Node: 14.15.4 - /usr/local/bin/node
npm: 7.6.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /opt/homebrew/bin/watchman
IDEs:
Android Studio: Not Found
Xcode: 13.0/13A233 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_302 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: ~0.66.0 => 0.66.0
react-native-macos: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- use this code with react native 0.66 on iOS
RCTModalHostViewController is what’s blocking the screen
.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 29
- Comments: 68 (1 by maintainers)
Another update – Here’s what I ended up doing:
This seemed to work, though I’m not sure why wrapping it with a View with flex: 1 is needed 🤔
I also then noticed that if I have multiple modals on the same page, this issue is only fixed for the first one (likely because of the
flex: 1
). So I updated the code to beThat way the modals are only rendered when visible, and there’s only 1 modal on a page at a time.
This has solved my issue for now, but I wish I didn’t have to do all this. Really hoping this issue is looked into.
Hello, Version 2.2.3 of react-reanimated seems to fix the issue on our side. Regards
Oh god, I’m so happy. I can confirm that my issues are gone as well, both modal dismiss and “zombie” screens… Thanks for letting us know @littleski! ❤️
A temporary workaround (that worked for me) without having to downgrade anything, i.e. it works with the following:
is to disable the autoinstall of Reanimated (during compilation) in your Podfile per their own documentation here
Remember to
pod install
after changing the PodfileThis allowed my setup to compile and run normally without experiencing the zombie
UITransitionView
after dismissing a modal.side note
$0.02: I’m not convinced that the problem lies strictly within
react-native-reanimated
itself, but is manifest when some magic combination ofreact-native
,react-native-screens
,@react-navigation/*
, andreact-native-reanimated
alter the native view hierarchy (UIKit) or inject event blocks that cause some async problems/race condition.Additionally, a cursory search (google/SO) for
UITransitionView
has hits for “stuck” views going back 5+ years.The latest versions of RN and Reanimated may have just “tickled” an old UIKit bug… 🤷
A workaround that I dislike but that seems to fix the issue for me is to mount/unmount the modal instead of using the
visible
prop 😢Having the same issue with Modals. After a modal is closed, the rest of the app becomes unresponsive and needs to be closed and reopened.
You guys can try by going to the file Pods/Development Pods/React-Core/Default/Views/RCTModalHostView and inside the method dismissModalViewController,
add the following lines: dispatch_async(dispatch_get_main_queue(), ^{ [_delegate dismissModalHostView:self withViewController:_modalViewController animated:[self hasAnimationType]]; _isPresented = NO; });
well, passing
coverScreen={false}
prop forreact-native-modal
seems to be a workaround for this as well, thanks for the helpHave the same issue using @react-navigation/stack. When we navigate to next stack screen and then go back, a transparent “view” blocks any interaction.
Having the same problem.
issue still exists with react-native:
0.66.3
and react-native-reanimated:2.2.3
it works after dropping some animation code I was usingany ideas why this is happening.
edited
I have a similar issue. My screen didn’t turn black, but the entire app becomes unresponsive. Upgraded from RN 0.64.2 to 0.66, literally no other packages changed. Unable to reproduce on Android. iOS only.
I tried out the Modal component as part of the React Native standard library, also react-native-modal and react-native-paper’s modal - they all had this same behaviour. I believe they are all wrapped versions of Modal from RN?
Thanks! I had to change them from
flex: 1
toflex: 0
since I already had aflex: 1
child component (with aflex: 1
parent component) that was intended to fill the whole screen and not share the space with any modalsEDIT: Modals that appear in succession seem to be broken with
2.3.0-beta.2
+ RN0.66.0
, even when using this solution (as well as when not using it): any modal that appears immediately after another does not appear.EDIT2: I ended up just completely deleting this library from my
0.66.0
app as @supervons said, and everything seems to work as intended (in iOS, at least). I don’t think this library has any noticeably useful purpose for my app whatsoever: just adds more possibilities for bugs.I just encountered this on an upgrade from
0.64.1
->0.66.0
(iOS 11 - 15 simulator). Traced it down to a 3rd party component that is using a transparentModal
under the hood.In this case it’s even more insidious since the modal is set as
transparent
; Once displayed the modal’s view never dismisses, and it swallows all touch events on the entire screen rendering the app effectively frozen.An experimental attempt to pass through a
pointerEvents: 'box-none'
prop had no effect as a workaround.However, When in the simulator AND debugging (w/chrome; flipper is not enabled in my project) is active, the Modal dismisses properly.
Yep, facing the same issue. I am on react-native version
0.65.1
Just bumped into this while reading
react-navigation
documentation 😅 Although this is for drawer navigator, I’m assuming it applies to others as well. So it makes sense why it works with Chrome debugger…(cc: @dotansimha @NoerNova)
react-native-reanimated@2.2.3
worked for me with React Native 0.66 🎉 Previously only the 2.3.x beta supported RN 0.66 but2.3.0-beta.2
/2.3.0-beta.3
do not work on iOS currently.@Dmitry-GH I’m not super familiar with the internals of Reanimated, but I believe it provides (at least) 2 main features for developers:
With that, library and component authors can leverage the Reanimated lib to make things visually smooth and performant when there are complex UI transformations/layering/gesture effects, etc…
The potential downside to disabling the compiled code might be visual/performance issues in certain situations. They emphasize animations in response to gestures.
(Speculation) I would imagine that most of the mainstream dependent libraries conditionally depend on reanimated so disabling it will probably fall-back to regular RN behavior.
Not sure what happens if you’ve coded against Reanimated’s API directly…no op perhaps…
Anyway, I’m not all that familiar with the implementation.
They have a good description of what purpose Reanimated serves over here
I think this issue occurs when upgrading
react-native-reanimated
to 2.3.0-beta.2 which is (as of now) the only version that works on RN 0.66. When I downgraded from RN 0.66.0 to 0.65.1, the modal issue was still there. It disappeared only after downgradingreact-native-reanimated
.I will be attempting to reproduce this in a clean project and reporting it to the Reanimated repo.Edit: it has been reported already, my bad.Screen freezing on a couple of situations for me,
BTW. all stuff works fine with opening debugging mode (Debug with Chrome) 🧐
Same here. Upgraded to RN66 and since than we had freezing with
react-native-modal
,react-native-screens
andreact-navigation@6
. If I turn onDebug in Chrome DevTools
on the app - everything seems to work perfectly fine 🤔 I guess it might be related to Flipper?With
react-native-modal
-> happens with all modals Withreact-navigation
/react-native-screens
-> happens with Stack navigator that has FlatList (that loads additional data using pagination, after loading more items and going back -> screen freezes, seems like there are twoRNSScreen
in view, one is a zombie view that contains aScrollView
)Same here!
react-native-reanimated@2.2.3
fixes the issues!I can confirm that updating to
react-native-reanimated@2.2.3
fixes this issue.I tried the workaround but unfortunately, when you don’t install Reanimated and you use Animated component it doesn’t work. I use
BottomTabBar
fromreact-navigation
(I have v4) and there isCrossFadeIcon
component which createsAnimated.View
.When I applied the workaround, my app crashes on the start due to some
InnerNativeModule
variable inside reanimated library being undefined.I had similar issue, but I’m using
react-native-modal
. After dismissing, theModal
also changed totransparent
and only found it thanks to Xcode’s “Debug View Hierarchy”… Also I was upgrading from0.64.0
to0.66.0
.I’m having this issue in both debug and release, though. Happens on iOS 15 Simulator (debug), iPhone 12 mini (release) and iPhone 6S (release).
I didn’t try debugging with Chrome because it causes my app to instantly crash and I have to reinstall it to even disable debugger 😅 But it’s possible it’s some kind of race condition, as Chrome decreases performance (I think).
@effektsvk yeah, i checked with the debug view hierarchy and it’s exactly
RCTModalHostViewController
on top of everything, i already have 2.3.0-beta3 that include the workaround but seems not had not effect.Same issue , i removed
react-native-reanimated
, everything works.I can confirm this is exactly the issue we’re having. And if Flipper is not the active debugger it works fine,
Yes, I’m having this as well, I wasn’t sure if it was related, because the
RNSScreen
comes fromreact-native-screens
but the behavior is very similar.I was trying to debug it in Xcode and it seems that there is logic which destroys that
RNSScreen
view when screen is inactive, but according to my debugging, it looks like the screen is inTransitioningOrBelowTop
state right after I click the back button. I also confirmed that the “zombie view” is the one I was backing from. I could also create multiple zombie views by dispatching navigation actions (I’m using react-navigation@4 with Redux state) and every time I navigated back it created a new dead screen.(cc: @dotansimha)
Same issue happened with me after upgrading to RN 0.66, react-native-picker-select library (which uses Modal under the hood) freezes the whole app.
Yes, because reanimated 2.2.2 won’t work with RN 0.66. That’s why in my solution I’v downgraded them both.
confirming this on RN 0.65.1
Chrome debugging doesn’t work for me, so I’m unable to check, unfortunately. I’m unable to get into the app when the debugger is enabled, I need to reinstall the app to use it again.