fix(iOS) [0.74]: RCTRedBox not appearing in Bridgeless when metro is not running
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
Test Plan:
Build the app without metro running check if RedBox is shown
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 18,008,365 | -4,139 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 21,366,887 | -4,152 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: f7bbaffdc3aa4e7af0b4d5f62e594cc7edd4f837 Branch: main
@dmytrorykun I've extracted the code to a separate handleError method but I'm not sure if we should copy everything that's in RCTCxxBridge.mm handle error (there were hacks required to make old arch work). I've simplified the method, and everything seems to work as it should.
I have one issue with the JS raw stack as it's not attached when error is thrown: https://github.com/facebook/react-native/blob/6204ea36d321c9e27757d5f36ff7e74fa68c54d5/packages/react-native/React/Base/RCTJavaScriptLoader.mm#L106 should we ignore it or there is a way to retrieve it?
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 main branch. This way we'll be able to import it to our internal repo, and iterate on it faster. The goal is to land these changes before the 0.75-RC3.
@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 facebook/react-native@4adef35e97f31db466e536aa21d5eeec6ee34fc6.