-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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) [0.74]: RCTRedBox not appearing in Bridgeless when metro is not running #43147
Conversation
d32f1a9
to
3026f13
Compare
Base commit: f7bbaff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like error handling is not implemented in RCTInstance. To solve this properly please implement a separate method called handleError
that would be basically this:
https://github.com/facebook/react-native/blob/main/packages/react-native/React/CxxBridge/RCTCxxBridge.mm#L1068
Note that the _loading
ivar does not exist in RCTInstance. You should assume it true
.
@dmytrorykun I've extracted the code to a separate I have one issue with the JS raw stack as it's not attached when error is thrown:
|
3026f13
to
84c72b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few questions!
@@ -339,6 +341,10 @@ - (void)_start | |||
if (RCTGetUseNativeViewConfigsInBridgelessMode()) { | |||
installLegacyUIManagerConstantsProviderBinding(runtime); | |||
} | |||
|
|||
RCTExecuteOnMainQueue(^{ | |||
RCTRegisterReloadCommandListener(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this reload change is necessary!
But, if it is, I have a request: Can we create a custom implementation of RCTReloadListener that retains RCTInstance weakly?
Bridgeless mode adheres to this principle:
Nothing outside of the RCTHost should own a reference to RCTInstance.
In practice, this line is fine: RCTRegisterReloadCommandListener holds on to RCTReloadListeners weakly.
But, I think bridgeless mode should not depend on this guarantee:
- Weak retention of listeners is an implementation detail of RCTRegisterReloadCommandListener. If someone changes it in the future, this bridgeless principle could be violated.
- Bridgeless classes should be responsible for enforcing bridgeless principles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed to make Reload
button work in Redbox. I understand your concerns, I've tweaked the code to listen to notification through the notification center so now we don't need to worry about retaining this instance. WDYT about this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@okwasniewski, the current solution definitely addresses the instance retention issue.
But, I don't think it's a good idea to rely on a global event emission to communicate between RCTRedBox and RCTInstance. Many apps/environments actually run multiple react instances at the same time. Global event emission makes that configuration on iOS more difficult. (We don't have a need for this right now, but it's always nice to extend react native in ways that don't preclude, or make this more difficult). And also, more generally: if we can avoid reliance on global things, we probably should.
Was there any problem with creating a custom RCTReloadListener? Perhaps you noticed an issue, or have a concern, that hadn't crossed my mind.
- (void)didReceiveReloadCommand { | ||
[self _loadJSBundle:[self->_bridgeModuleDecorator.bundleManager bundleURL]]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@okwasniewski, why did you end up registering the RCTInstance as a reload command listener here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When clicking Reload on the redbox nothing was happening
03cf0dc
to
b41ab3b
Compare
Hey @okwasniewski , we are generally happy with the changes in this PR. But we would like to polish some details. Could you please resubmit this PR for the |
11f9f0d
to
1be613b
Compare
1be613b
to
08eefac
Compare
@dmytrorykun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hey @dmytrorykun, @RSNara I'm going to be on PTO next week so I'm afraid I won't manage to implement custom implementation of RCTReloadListener are you guys okay with iterating on it internally? |
@dmytrorykun merged this pull request in 4adef35. |
…not running (#43147) Summary: When testing out `0.74.0-rc0` I found that when the metro is not running we are not displaying RedBox which bumps users to start the packager and reload the app. It also fixes the case where users try to reload by clicking the "Reload" button on RedBox. ## Before https://github.com/facebook/react-native/assets/52801365/086c557f-ea1f-4a97-b4c7-df8a945cc7a0 ## After https://github.com/facebook/react-native/assets/52801365/9f8421b3-5e83-466f-8cdb-38f97981275d ## Changelog: [IOS] [FIXED] - RCTRedBox not appearing in Bridgeless when metro is not running Pull Request resolved: #43147 Test Plan: Build the app without metro running check if RedBox is shown Reviewed By: javache Differential Revision: D54632056 Pulled By: dmytrorykun fbshipit-source-id: fb6742898d3bd82545bfffd9175208e1a5984cb6
Summary:
When testing out
0.74.0-rc0
I found that when the metro is not running we are not displaying RedBox which bumps users to start the packager and reload the app. It also fixes the case where users try to reload by clicking the "Reload" button on RedBox.Before
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-02-22.at.13.50.06.mp4
After
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-02-22.at.13.45.42.mp4
Changelog:
[IOS] [FIXED] - RCTRedBox not appearing in Bridgeless when metro is not running
Test Plan:
Build the app without metro running check if RedBox is shown