react-native icon indicating copy to clipboard operation
react-native copied to clipboard

fix: iOS crash occurring when navigating to a new app screen with a displaying modal

Open zhouzh1 opened this issue 1 year ago • 3 comments

Summary:

Our app is using the react-native v0.74.2 with the react-navigation lib for screen navigation, we're facing an issue in the built iOS app that when we try to navigate to a new app screen with the react-navigation's reset or replace method and meanwhile there's a react native modal displaying, then the iOS app always crashes.

I saw there is already a relevant PR and discussion targeting this issue, but I still think it would be better if this kind of crash can be suppressed in the framework level, currently I guess it's common in the iOS apps based on react native.

Changelog:

[IOS] [FIXED] - app crash happening when navigate to a new app screen with a displaying modal

Test Plan:

More issue details and the reproduction steps can be found in this PR :)

zhouzh1 avatar Jul 08 '24 11:07 zhouzh1

Hi @zhouzh1!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Jul 08 '24 11:07 facebook-github-bot

@mojodna @jsierles @augustl could you help take a review? Thanks.

zhouzh1 avatar Jul 08 '24 11:07 zhouzh1

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Jul 08 '24 12:07 facebook-github-bot

Anyone can help take a look or provide some insights about if this change is safe or not?

zhouzh1 avatar Jul 16 '24 07:07 zhouzh1

This issue is causing multiple crashes for us in production every day. Would appreciate if a fix like this could be merged. We use reset/replace actions when following deep links. No good way to know if the user has a modal open when we do so.

Tested applying the suggested fix manually and it seems to work without issue.

mrand15 avatar Aug 08 '24 23:08 mrand15

@mrand15 Glad to hear that it's working for you, I already applied this fix in our production app for a long while, seems that this issue has been resolved and this change didn't introduce other new issues. @cortinico Could you help take a look please?

zhouzh1 avatar Aug 12 '24 07:08 zhouzh1

@cipolleschi Sorry that our app hasn't started to apply the new React native architecture, so I am not sure if it's suffering from this issue as well, but I took a look at the above RCTModalHostViewComponentView file that you posted, I guess it's no problem, because in this file, the _shouldPresent variable replaces the _visible variable in the old architecture, and there is already such a process similar to what this fix PR does.

zhouzh1 avatar Aug 14 '24 06:08 zhouzh1

@cipolleschi Could you help take a look again? We're going to upgrade the react native in our project, if this fix makes sense, then we may don't need the extra patch file for react native.

zhouzh1 avatar Aug 19 '24 02:08 zhouzh1

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Aug 20 '24 12:08 facebook-github-bot

@cipolleschi merged this pull request in facebook/react-native@52888c0c1e722a799f233c2f502e01b9dd4a7174.

facebook-github-bot avatar Aug 20 '24 17:08 facebook-github-bot

This pull request was successfully merged by Zhi Zhou in 52888c0c1e722a799f233c2f502e01b9dd4a7174

When will my fix make it into a release? | How to file a pick request?

react-native-bot avatar Aug 20 '24 17:08 react-native-bot

@zhouzh1 which version are you using? can you create a pick request for the versions that needs the fix?

cipolleschi avatar Aug 20 '24 17:08 cipolleschi

@cipolleschi - My project has upgraded to react-native:0.73.7 3 months back.I raised the issue #44612 . Can I add this line [self setVisible: NO]; below the code for a temporary fix or Can I pick a request to react-native:0.73.7 to fix issue #44612 ? node_modules>react-native>React>Views>RCTModalHostView.m We will upgrade my project to the latest react-native version once the client approves the newest version.

(void)dismissModalViewController { if (_isPresented) { [_delegate dismissModalHostView:self withViewController:_modalViewController animated:[self hasAnimationType]]; _isPresented = NO; [self setVisible: NO] // Add this line // } }

gkasireddy202 avatar Sep 26 '24 06:09 gkasireddy202

yeah, 0.73 is still in the support window. I created the cherry pick request: https://github.com/reactwg/react-native-releases/issues/531 We need the same pick for other versions too, let me create them.

cipolleschi avatar Sep 26 '24 13:09 cipolleschi

@cipolleschi - Thanks for your update. https://github.com/reactwg/react-native-releases/issues/531 release fix will resolve my issue #44612 ?

gkasireddy202 avatar Sep 26 '24 13:09 gkasireddy202

@gkasireddy202 I don't know... I understood you were asking to pick the fix because you tested it and it fixed it... 😅

Can you try to:

  1. add that line in your project
  2. try to trigger the crash
  3. report back whether it worked or not

cipolleschi avatar Sep 26 '24 13:09 cipolleschi

@cipolleschi - I added that line to my project and tested it. I triggered the crash. This is the issue that I faced in react-native:0.73.7.

https://github.com/facebook/react-native/issues/44612#issuecomment-2360716821

gkasireddy202 avatar Sep 26 '24 13:09 gkasireddy202

This pull request was successfully merged by Zhi Zhou in 8ec672204d5dee2b967cac08adf03c082e36ad79.

When will my fix make it into a release? | How to file a pick request?

github-actions[bot] avatar Sep 30 '24 14:09 github-actions[bot]