Skip to content

Extract RCTRedBoxController from RCTRedBox.mm (#56509) - #56509

Closed
motiz88 wants to merge 3 commits into
react:mainfrom
motiz88:export-D101484586
Closed

Extract RCTRedBoxController from RCTRedBox.mm (#56509)#56509
motiz88 wants to merge 3 commits into
react:mainfrom
motiz88:export-D101484586

Conversation

@motiz88

@motiz88motiz88 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary:

Moves the RCTRedBoxController class, previously inlined in RCTRedBox.mm, into its own implementation and header files (RCTRedBoxController.mm, RCTRedBoxController+Internal.h). An upcoming diff will fork these files for the experimental RedBox 2.0.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D101484586

@meta-clameta-claBot 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 Apr 20, 2026
@meta-codesync

Copy link
Copy Markdown

@motiz88 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101484586.

motiz88and others added 3 commits April 21, 2026 08:08
Summary:
Here, we add a mechanism to override React Native feature flag default values via a Buck command line argument, without modifying source files.
A `genrule` in the featureflags BUCK target always interposes on `ReactNativeFeatureFlagsDefaults.h` before compilation. When `react_native.feature_flag_defaults` is set to a JSON object via `--config`, a Python script rewrites the return values in the matching method bodies. When unset, the header passes through unmodified.
The Python script matches each override against the full method signature shape (`<returnType> <flagName>() override { ... return <value>; }`) with lenient whitespace, and fails the build if any requested flag name is not found in the header.
Usage:
```
buck2 build --config 'react_native.feature_flag_defaults={"enableViewCulling":true}' //target
buck2 build --config 'react_native.feature_flag_defaults={"enableViewCulling":true,"preparedTextCacheSize":500}' //target
```
This modifies defaults only — app-level providers still take priority.
Changelog: [Internal]
Differential Revision: D101484355
Summary:
Add `redBoxV2IOS` and `redBoxV2Android` common feature flags (default false), gating RedBox 2.0 independently on each platform.
Changelog: [Internal]
Differential Revision: D98115369
Summary:
Pull Request resolved: react#56509
Moves the `RCTRedBoxController` class, previously inlined in `RCTRedBox.mm`, into its own implementation and header files (`RCTRedBoxController.mm`, `RCTRedBoxController+Internal.h`). An upcoming diff will fork these files for the experimental RedBox 2.0.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D101484586
@meta-codesyncmeta-codesyncBot changed the title Extract RCTRedBoxController from RCTRedBox.mmExtract RCTRedBoxController from RCTRedBox.mm (#56509)Apr 21, 2026
@facebook-github-toolsfacebook-github-toolsBot added the Merged This PR has been merged. label Apr 21, 2026
@meta-codesync

Copy link
Copy Markdown

This pull request has been merged in 084456e.

motiz88 added a commit that referenced this pull request Apr 23, 2026
* Add per-platform redBoxV2 feature flags
Cherry-pick of d6ed561 with feature flag files regenerated
for the 0.83-stable branch.
* Extract RCTRedBoxController from RCTRedBox.mm (#56509)
Summary:
Pull Request resolved: #56509
Moves the `RCTRedBoxController` class, previously inlined in `RCTRedBox.mm`, into its own implementation and header files (`RCTRedBoxController.mm`, `RCTRedBoxController+Internal.h`). An upcoming diff will fork these files for the experimental RedBox 2.0.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D101484586
fbshipit-source-id: 0b0c80caa790ee5286c48adfce5c22d22bef47b6
* Add LogBox-styled error overlay (#56550)
Summary:
Pull Request resolved: #56550
Replace the legacy red-on-black RedBox design with a LogBox-inspired design for RedBox 2.0: charcoal background, salmon header bar, structured call stack, 3-button footer, full-screen view with no animated transition. Gated behind `redBoxV2IOS`.
This diff is just for the low-hanging fruit - setting up the split implementation and borrowing the broad visual style of LogBox. Further up this stack we will port more functionality and improve on this baseline.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D98115368
fbshipit-source-id: 7c14137c94c812f42b6af0c376762e068cfcdaaa
* Add shared C++ error parser and ANSI renderer (#56553)
Summary:
Pull Request resolved: #56553
Add a platform-independent C++ library (`ReactCommon/react/debug/redbox/`) for error message parsing and ANSI escape sequence rendering, shared by both iOS and Android.
`RedBoxErrorParser` — C++ port of `parseLogBoxException`. Classifies Metro errors, Babel transform errors, bundle loading errors, and code frame errors into a structured `ParsedError`.
`AnsiParser` — converts ANSI SGR sequences into styled spans with foreground/background colors using the Afterglow theme.
Uses `facebook::react::unstable_redbox` namespace to exclude from C++ API snapshots.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D101357709
fbshipit-source-id: d2ecf9d12897e00f9590e1bec57ecf5d5895fcd5
* Show syntax-highlighted code frames (#56551)
Summary:
Pull Request resolved: #56551
TSIA
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D98113191
fbshipit-source-id: 00b640de69a5a3e48dae624dd24c25a1da3c7548
* Mark all errors as retryable (#56552)
Summary:
Pull Request resolved: #56552
Adds `isRetryable` and `isCompileError` to C++ `ParsedError` and its iOS wrapper, for use in RedBox 2.0. **Currently all errors are assumed to be retryable under RedBox 2.0.**
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D101357708
fbshipit-source-id: 6a83b5944e5451a7818c66a321bf8d45a1951970
* Auto-reload on retryable errors (#56549)
Summary:
Pull Request resolved: #56549
Adds an automatic reload countdown to the RedBox 2.0 overlay for errors marked as retryable by the error parser. (Currently all of them, see D101357708.)
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D98107027
fbshipit-source-id: 9f39491e4ecf5086a76b7f6446c34231a5d4eb0d
* Attempt to clear RedBox by automatically reloading on Metro file change (#56554)
Summary:
Pull Request resolved: #56554
While RedBox is displayed, open a native WebSocket to Metro's `/hot` endpoint. On file change, automatically reload — bridging the gap for bundle loading errors where the JS HMR client is unavailable.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D98350597
fbshipit-source-id: 9d11d99226483d937be45d75be008b0f9f25572b
* Fix truncated filenames in call stack frames (#56565)
Summary:
Pull Request resolved: #56565
Stack frame file paths in RedBox 2.0 were displaying as truncated jsc-safe-url fragments (e.g. `dev=true` instead of `index.bundle`). This happened because `lastPathComponent` treats the `//&` path-encoded query as additional path segments.
Here, we port the `jsc-safe-url` npm package to shared C++ (matching the JS implementation line-for-line, including the RFC 3986 appendix B regex) and use it to normalize stack frame URLs before extracting filenames. Query strings are also stripped after normalization.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D101796395
fbshipit-source-id: 38d5a8ccb111e78f847be4a551e359dd075e6a0f
* Guard tvOS-unavailable APIs in RCTRedBox2Controller (#56568)
Summary:
Pull Request resolved: #56568
`separatorStyle` and `UITableViewCellSeparatorStyleNone` are unavailable on tvOS, causing the airwave-tvos-appletvos build to fail. Wrap them with `#if !TARGET_OS_TV`, matching the existing pattern in `RCTRedBoxController.mm`.
Changelog: [Internal]
Reviewed By: motiz88
Differential Revision: D102001404
fbshipit-source-id: 383e1cc64070000c258b71a60aa4b4ef6453206e
* Fix C++ syntax in Objective-C header breaking React module build (#56569)
Summary:
Pull Request resolved: #56569
`RCTRedBox2Controller+Internal.h` used a C++ `using` type alias, which fails when compiled as plain Objective-C. This header is currently included in the `React-Core` umbrella header (via the `CoreModulesHeaders` subspec), so it gets compiled in a pure-ObjC context and breaks the RNTester iOS CI build.
Here, we replace the `using` with an equivalent `typedef`.
NOTE: The underlying issue is that this `+Internal.h` header should not be in the umbrella header at all. I will follow up to make the RedBox 2.0 internal headers private at the CocoaPods level.
Changelog: [Internal]
___
overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: react_native
landed-with-radar-review
Reviewed By: sbuggay
Differential Revision: D102005814
fbshipit-source-id: d0a5727ee47ea5148a371074bc74e42e503c20f8
---------
Co-authored-by: Terry Kwon <kastopia@meta.com>
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @motiz88 in e356fd0

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

fabriziocucci added a commit that referenced this pull request May 1, 2026
Summary:
Pull Request resolved: #56640
Cherry-pick of 13 commits from `main` (and 1 from `0.83-stable`) adding the experimental RedBox 2.0 implementation for iOS to `0.85-stable`, plus supporting build fixes.
Changes included:
- Add per-platform `redBoxV2IOS` / `redBoxV2Android` feature flags
- Extract `RCTRedBoxController` from `RCTRedBox.mm` (#56509)
- Add LogBox-styled error overlay (#56550)
- Add shared C++ error parser and ANSI renderer (#56553)
- Show syntax-highlighted code frames (#56551)
- Mark all errors as retryable (#56552)
- Auto-reload on retryable errors (#56549)
- Attempt to clear RedBox by automatically reloading on Metro file change (#56554)
- Fix truncated filenames in call stack frames (#56565)
- Guard tvOS-unavailable APIs in `RCTRedBox2Controller` (#56568)
- Fix C++ syntax in Objective-C header breaking React module build (#56569)
- Add `redbox` subspec to `React-debug` pod (#56584) — from `0.83-stable`, needed for static library builds
- Fix React-CoreModules missing `React-featureflags` header path under `use_frameworks!` (#56591)
All RedBox 2.0 features gated behind the `redBoxV2IOS` feature flag (disabled by default).
Changelog: [Internal]
Test Plan:
- CI
- Feature is behind `redBoxV2IOS` flag, disabled by default
Co-authored-by: Moti Zilberman <moti@meta.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.fb-exportedMergedThis PR has been merged.meta-exportedp: FacebookPartner: FacebookPartner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@motiz88@react-native-bot