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 Unable to find module for UIManager issue #26861

Closed

Conversation

kevinvangelder
Copy link
Contributor

Summary

A race condition sometimes causes redbox errors when reloading the app after previously opening the Chrome debugger. In the project I was working on, we were regularly getting Unable to find module for UIManager and I was able to track it down to _moduleDataByName sometimes being empty or nil. This change safely early-exits when that is the case and the app loads successfully. Related issues:
#24549
#23235

Changelog

[iOS] [Fixed] - Race condition causing redbox errors when reloading app after using Chrome debugger

Test Plan

As this is a difficult-to-reproduce race condition, I'm not entirely certain what the test plan should be. I created this change as a patch to React Native in the closed-source project I've been working on and it works flawlessly, however I haven't been able to reproduce the issue in a clean project. This is a fairly safe change as the early exit only ever occurs if the variable is empty and it seems to be resilient enough to load the module again after the race condition has been defeated, but I'm open to suggestions on potential options to test this.

@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 Oct 14, 2019
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Oct 14, 2019
@mmmulani
Copy link
Contributor

rather than change the module loading logic, I would change uiManager's getter here: https://github.com/facebook/react-native/blob/master/React/Modules/RCTUIManager.m#L1616

that seems to make more sense as it looks like the dealloc is throwing the error

@kevinvangelder
Copy link
Contributor Author

Is having an early exit when _moduleDataByName is nil a bad thing? We can certainly also address other weaknesses, but I doubt there is any situation where we would want to receive a redbox error instead of having it gracefully handled.

@mmmulani
Copy link
Contributor

Is having an early exit when _moduleDataByName is nil a bad thing?

yes. you're essentially checking to see if RCTUIManager has been invalidated and if so skip some checks. But we can instead harden when the RCTUIManager is accessed off RCTCxxBridge

We can certainly also address other weaknesses, but I doubt there is any situation where we would want to receive a redbox error instead of having it gracefully handled.

yea I definitely agree that we do not want to show a redbox in this case but I think that we should solve the problem a different way.

@kevinvangelder
Copy link
Contributor Author

@mmmulani Okay. Unfortunately I have no C++ experience, so I'm not sure what the alternative solution would look like. If it's a simple change would you be willing to open a PR and I'll close this one in favor of it?

@spacesuitdiver
Copy link

spacesuitdiver commented Oct 29, 2019

image

Just helping document the issue, on the project I use it happens every time in the scenario @kevinvangelder described.

@kevinvangelder
Copy link
Contributor Author

I'm curious if @mhorowitz has any thoughts for us.

@satbirkira
Copy link

Any update on this?

@github-actions
Copy link

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 22, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants