Skip to content
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

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

Closed

Conversation

zhouzh1
Copy link
Contributor

@zhouzh1 zhouzh1 commented Jul 8, 2024

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 :)

@facebook-github-bot
Copy link
Contributor

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!

@zhouzh1 zhouzh1 changed the title fix: iOS crash occurring when navigating to a new app screen using the react-navigation methods fix: iOS crash occurring when navigating to a new app screen with a displaying modal Jul 8, 2024
@zhouzh1
Copy link
Contributor Author

zhouzh1 commented Jul 8, 2024

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 8, 2024
@facebook-github-bot
Copy link
Contributor

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 facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 8, 2024
@zhouzh1
Copy link
Contributor Author

zhouzh1 commented Jul 16, 2024

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

@mrand15
Copy link

mrand15 commented Aug 8, 2024

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.

@zhouzh1
Copy link
Contributor Author

zhouzh1 commented Aug 12, 2024

@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?

@cortinico cortinico requested a review from cipolleschi August 12, 2024 10:02
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this is a fix for the old architecture only. Can I ask you to work also on the New Architecture?

The twin file should be this one: RCTModalHostViewComponentView.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misclicked on 'Approve'.
We try not to accept fixes for the Old Architecture only. We would like at least to have the same fix in the New Arch or have a check that the New Arch does not suffer from the same issue.

@zhouzh1
Copy link
Contributor Author

zhouzh1 commented Aug 14, 2024

@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 zhouzh1 requested a review from cipolleschi August 14, 2024 06:34
@zhouzh1
Copy link
Contributor Author

zhouzh1 commented Aug 19, 2024

@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.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing! Which version of React Native are you using?

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 20, 2024
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 52888c0.

@react-native-bot
Copy link
Collaborator

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

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

@cipolleschi
Copy link
Contributor

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

@gkasireddy202
Copy link

gkasireddy202 commented Sep 26, 2024

@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 //
}
}

@cipolleschi
Copy link
Contributor

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

@gkasireddy202
Copy link

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

@cipolleschi
Copy link
Contributor

@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

@gkasireddy202
Copy link

@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.

#44612 (comment)

blakef pushed a commit that referenced this pull request Sep 30, 2024
…isplaying modal (#45313)

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](#38491) 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

Pull Request resolved: #45313

Test Plan: More issue details and the reproduction steps can be found in this [PR](#38491) :)

Reviewed By: christophpurrer

Differential Revision: D61537167

Pulled By: cipolleschi

fbshipit-source-id: 3c0474d794b4216ebc073dd6558d2b6ae27492d2
Copy link

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

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

cipolleschi pushed a commit that referenced this pull request Oct 7, 2024
…isplaying modal (#45313)

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](#38491) 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

Pull Request resolved: #45313

Test Plan: More issue details and the reproduction steps can be found in this [PR](#38491) :)

Reviewed By: christophpurrer

Differential Revision: D61537167

Pulled By: cipolleschi

fbshipit-source-id: 3c0474d794b4216ebc073dd6558d2b6ae27492d2
cortinico pushed a commit that referenced this pull request Jan 22, 2025
…isplaying modal (#45313)

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](#38491) 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

Pull Request resolved: #45313

Test Plan: More issue details and the reproduction steps can be found in this [PR](#38491) :)

Reviewed By: christophpurrer

Differential Revision: D61537167

Pulled By: cipolleschi

fbshipit-source-id: 3c0474d794b4216ebc073dd6558d2b6ae27492d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants