Commit Graph
153 Commits
Author SHA1 Message Date
Christoph Purrer f41364d11d Fix unused parameter warnings in StubWebSocketClient.h (#56527)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56527

Removed parameter names from unused parameters in StubWebSocketClient stub implementation to fix clang-diagnostic-unused-parameter warnings. This stub class implements IWebSocketClient interface with empty method bodies, so all parameters were unused.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D101110612

fbshipit-source-id: 859d7e630b6f0fd1836c5706a81f05ffd72471f7
2026-04-22 12:27:28 -07:00
Rubén Norte 5c55a61c1f Set hermes_build_mode constraint when building tester with coverage (#56541)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56541

The Fantom test runner spawns native `fantom-tester` binaries built in
either dev or opt mode based on each test's `fantom_mode` pragma. When
collecting C++ code coverage of the tester binary, however, the build
may switch to a coverage-instrumented build configuration that does not
define `REACT_NATIVE_DEBUG`.

That breaks dev-mode tests that rely on debug-only native APIs. For
example, `installHighResTimeStampMock` in
`private/react-native-fantom/tester/src/NativeFantom.cpp` is gated on
`#ifdef REACT_NATIVE_DEBUG` and throws "Mocking timers is not supported
in optimized builds" otherwise. Tests like `LongTasksAPI-itest.js` (no
`fantom_mode` pragma → defaults to dev) fail in CI coverage runs with
that error.

When invoking buck with coverage enabled, layer the `hermes_build_mode`
constraint on top of the build platform so `rn_build_mode()` (in
`tools/build_defs/oss/rn_defs.bzl`) picks up the right value and adds
`-DREACT_NATIVE_DEBUG` for dev tests.

Reviewed By: fkgozali

Differential Revision: D101832028

fbshipit-source-id: cfb5269dea846f41d9d1f9af1c5ff8bd5828085c
2026-04-21 11:15:04 -07:00
Rubén Norte dbd3255194 Build both coverage and non-coverage tester binaries in CI (#56538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56538

The Fantom Jest `globalSetup` builds the `fantom-tester` native binaries
upfront, using `globalConfig.collectCoverage` to decide whether to build
the `-coverage` flavor.

However, `runner/coverageUtils.js`'s `shouldCollectCoverage()` returns
`false` for some tests even when `globalConfig.collectCoverage` is true:

- All benchmarks (filename matches `*Benchmark-itest.*`)
- Tests with the `fantom_disable_coverage` pragma

In CI coverage runs, those tests resolve their tester binary path with
`enableCoverage=false` (e.g. `fantom-tester-statichermesstable-opt`),
but `globalSetup` only built the `-coverage` variants, so spawn fails
with `ENOENT` and the test fails with an empty stdout/stderr and exit
code `-2`.

When `enableCoverage` is true, also build the non-coverage tester
variants so coverage-opt-out tests can find their binary.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D101819861

fbshipit-source-id: e82f7c8c548c9477d214e9265c813bf9b54ab141
2026-04-21 09:24:25 -07:00
Rubén Norte 5f69a91186 Document FANTOM_FORCE_CI_MODE for full local runs (#56531)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56531

Add a section to the Fantom `__docs__/README.md` that recommends running the full suite locally with `FANTOM_FORCE_CI_MODE=1`. In CI mode, `globalSetup` pre-builds the entire `(hermesVariant × enableOptimized)` binary matrix once up-front and per-test buck2 invocations are skipped, which eliminates buck2 daemon contention from the worker pool — a common source of sporadic build failures when many workers race to build different binary variants at the same time.

CI environments (`SANDCASTLE`, `GITHUB_ACTIONS`) already auto-detect this mode; this just documents it for local use.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D101795648

fbshipit-source-id: 984bc8bfd034347b5aee0ff438b037e5eb9d41a8
2026-04-21 06:49:06 -07:00
Rubén Norte c1ffe9f2a0 Harden Metro bundle retry against file-watcher races (#56530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56530

Each Fantom test writes a unique `\-<test>.js` entrypoint into
`.out/js-builds/` and then asks Metro to bundle it. Metro's file watcher
(metro-file-map's `FallbackWatcher` on Linux, debounced 100 ms) does not
always observe the new entrypoint by the time the HTTP request arrives,
especially when multiple workers are writing entrypoints concurrently.
The previous retry logic was too narrow:

- Only HTTP 404 was treated as retryable. Metro returns 404 only when the
  entry file path itself can't be resolved; an unresolved transitive
  dep (e.g. `setUpDefaultReactNativeEnvironment`) returns HTTP 500 with
  `{type: 'UnableToResolveError'}` — we'd throw immediately on that.
- Only 3 attempts with a flat 500 ms wait (~1 s total), which is not
  enough on a busy host with 8 workers writing entrypoints at once.

This results in ~30 spurious "Failed to request bundle from Metro: Unable
to resolve module ..." failures per run.

Refactor `createBundle` into a focused `fetchBundleWithRetry` helper that:

- Parses Metro's JSON error envelope (`{type, message, ...}` from
  `formatBundlingError`) once per response and uses `type` to decide
  whether to retry. Retries on HTTP 404, on HTTP 500 with
  `UnableToResolveError` or `ResourceNotFoundError`, and on transient
  `fetch` network errors. All other failures (transform errors, syntax
  errors, real config issues) throw immediately so we don't waste seconds
  on them.
- Uses exponential backoff (100 ms → 200 → 400 → 800 → 1.6 s, capped at
  2 s) with up to 10 attempts (~11 s total worst case).
- Surfaces a clean error message (parsed from the JSON envelope) when
  retries are exhausted.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D101791796

fbshipit-source-id: 805ef9bc6e58fce7c1dc10d0cbbb7fdfa1fa24a5
2026-04-21 06:03:40 -07:00
Rubén Norte 0f9b8e4a62 Cap maxWorkers and bump heap to bound Fantom Metro memory (#56529)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56529

Fantom runs every test through a single shared Metro server (started in
`globalSetup`). Jest's default `maxWorkers` is `numCpus - 1`, so on a
high-core box (e.g. 176 CPUs) ~175 workers fire bundle requests at Metro
concurrently. Each in-flight request makes Metro materialize a full
dependency `Graph` (transformed modules, source maps, inverse-deps,
file-watcher subscription), which is hundreds of MB.

The per-test `DELETE` eviction added in D101652820 only releases that
memory after the bundle response completes, so the simultaneous in-flight
set still blows past the previous Node `--max-old-space-size=8192` ceiling
in `scripts/fantom.sh` — the Metro process aborts with
`FATAL ERROR: Ineffective mark-compacts near heap limit` after just a
handful of test suites.

Two coordinated changes that balance throughput and safety:

- `scripts/fantom.sh`: bump the Node heap from 8 GB to 16 GB so we have
  headroom over the observed steady-state peak.
- `private/react-native-fantom/config/jest.config.js`: cap `maxWorkers`
  at `min(numCpus - 1, 16)`. With 8 workers the heap peaked at ~3 GB
  (~400 MB / worker), so 16 workers fits comfortably under a 16 GB cap
  with ~40% headroom.

This is intentionally a balance rather than a hard worker cap — bumping
the heap alone would still leave 100+ in-flight graphs racing GC, and
capping workers alone leaves throughput on the table on big machines.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D101791795

fbshipit-source-id: 035c7235c32303f7b7f1eb05698b2a5cba90edc9
2026-04-21 06:01:11 -07:00
Rubén Norte fd082b938b Re-throw errors from tasks and microtasks synchronously (#56513)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56513

Changelog: [internal]

Fantom previously did not propagate errors thrown inside `runTask` callbacks
(or microtasks queued by them) to Jest, so failing assertions inside tasks
were silently swallowed and only logged via `console.error`. Tests had to
work around this with manual `try`/`catch` blocks and a couple of
`it.skip`s with TODOs.

This installs a Fantom-specific global error handler (via `ErrorUtils.setGlobalHandler`)
that captures the first error reported during the current work loop into
`pendingError`. After `flushMessageQueue()` returns, `runWorkLoop()`
re-throws the captured error so it becomes observable as a Jest failure.

Only the first error in a work loop is re-thrown (subsequent ones are
typically follow-on noise), and `pendingError` is cleared at the start of
each work loop so errors captured during module setup do not spuriously
fail later loops. The post-loop `runLogBoxCheck()` continues to take
precedence, since LogBox diagnostics are more actionable.

With this in place:
- The 'should throw when running a task inside another task' test can use
  `expect(...).toThrow(...)` directly instead of manual try/catch.
- The two previously-skipped tests for re-throwing errors from tasks and
  microtasks are now enabled.

NOTE: this will cause some tests to start failing, but they're legit failures

Reviewed By: javache

Differential Revision: D101647822

fbshipit-source-id: b9cba056d46cc94a4f6dad5e3665266df62a0211
2026-04-21 03:29:54 -07:00
Pieter De Baets 3fb1fea57e Evict Metro bundle graphs after each Fantom test to prevent OOM (#56514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56514

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D101652820

fbshipit-source-id: f7608fbf92a8fd2928434e74ad03bfc01b318d20
2026-04-20 10:56:52 -07:00
Rubén Norte def621f674 Move CI validation for debugCpp and profileCpp to EnvironmentOptions (#56464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56464

Changelog: [internal]

Moved the CI validation checks for `debugCpp` and `profileCpp` from the `run()` function in `tester.js` to `validateEnvironmentVariables()` in `EnvironmentOptions.js`, alongside the existing CI/OSS validation for memory instrumentation.

This centralizes all environment option validation in one place, so invalid configurations are caught early during environment setup rather than at tester execution time.

Reviewed By: javache

Differential Revision: D101159820

fbshipit-source-id: 1e488db6e9de3eb3bac840c4931bb1536f8b5efb
2026-04-16 06:23:35 -07:00
Rubén Norte c482b936b2 Skip reporting benchmark results in test mode (#56435)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56435

Avoid printing the result summary table when benchmarks are executed in
test mode. In test mode, benchmarks run only a single iteration with no
warmup, so the timing results are not meaningful for comparison.

The per-suite results table (console.table) was already skipped in test
mode, but the benchmark result was still reported to the runner, which
could cause the cross-variant comparison table to be printed with
meaningless data. This change skips the reportBenchmarkResult call
entirely when running in test mode.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D100795458

fbshipit-source-id: 910f0aa5615ea07fd19b3703a2774e13b4531743
2026-04-15 02:39:57 -07:00
Bartlomiej Bloniarz e4f0509973 Add pushAnimationMutations to the AnimationBackend (#56401)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56401

Add `pushAnimationMutations(Callback)` to the AnimationBackend as a targeted alternative to `trigger()`.

The existing `trigger()` method has two problems:

1. **Blast radius**: It calls `onAnimationFrame()` which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) calls `trigger()` in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily.

2. **Broken timestamp on iOS**: `trigger()` uses `std::chrono::steady_clock` which on iOS maps to a different kernel clock than what `CADisplayLink` uses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps.

`pushAnimationMutations(Callback)` fixes both issues:
- Executes only the provided callback, not all registered ones
- Uses `AnimationChoreographer::now()` which delegates to `HighResTimeStamp`, providing a timestamp from the same clock as the vsync path on each platform

Also refactors `onAnimationFrame` to use `unpackMutations`/`applySurfaceUpdates` helpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks.

## Changelog:
[General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates

Reviewed By: zeyap

Differential Revision: D100164749

fbshipit-source-id: 53d36ed316614baa835707a45361ae8f3b828d26
2026-04-13 10:22:05 -07:00
Rubén Norte 7efb4b564e Run benchmarks in test mode by default instead of excluding them (#56418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56418

Changelog: [internal]

D92150163 excluded benchmark tests by default when running `yarn fantom` without `--benchmarks`. This was incorrect because it means benchmarks could silently break without being caught.

This changes the behavior so:
1. By default (without `--benchmarks`), benchmarks run in test mode (single iteration for correctness only), ensuring they do not break.
2. With `--benchmarks`, benchmarks run in full benchmark mode (multiple iterations for performance measurement).

Also renames `FANTOM_FORCE_TEST_MODE` to `FANTOM_RUN_BENCHMARKS` and `forceTestModeForBenchmarks` to `runBenchmarks` to better reflect the intent (opt-in to full benchmarks rather than opt-in to test mode).

Reviewed By: sammy-SC

Differential Revision: D100464314

fbshipit-source-id: 822cc5a25f0cdddf035616fdddf8619d27ef436a
2026-04-13 04:31:04 -07:00
Rubén Norte 4bdfaf222b Fix stateful regex bug in benchmark detection (#56423)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56423

Changelog: [Internal]

The `FANTOM_BENCHMARK_FILENAME_RE` and `FANTOM_BENCHMARK_SUITE_RE` regexes used the `g` (global) flag, which makes `.test()` stateful — it preserves `lastIndex` between calls. When `getFantomTestConfigs` is called for multiple test files in the same process, the stale `lastIndex` from a previous successful match causes `.test()` to miss the match on the next file, returning `false`. This results in benchmark files intermittently getting the default dev config (`isJsOptimized: false`, `dev: true`), causing them to fail at runtime with "Benchmarks should not be run in development mode".

Removes the `g` flag from both regexes since they are used with `.test()` across different strings and should be stateless.

___

overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: react_native_iroc

Differential Revision: D100603612

fbshipit-source-id: 4eded9b0a59a2343ad44c0c1c2855466e3981b7a
2026-04-13 04:31:04 -07:00
Rubén Norte f0f6240d1e Expose Event, EventTarget and CustomEvent as globals (#56416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56416

Registers Event, EventTarget and CustomEvent as global polyfills in `setUpDOM.js`. These are standard Web APIs that DOM nodes need access to.

Removes the Event/EventTarget polyfills from the Fantom test setup since they are now provided globally by setUpDOM.js.

Changelog: [internal]

Marking as internal for now, until we ship to stable, even though this isn't gated. We shouldn't communicate this yet.

Reviewed By: javache

Differential Revision: D100462548

fbshipit-source-id: 3e30be760d4f524ca823ebf1320d9a607abeabf9
2026-04-13 03:55:39 -07:00
Zeya Peng 0e65df9152 move ViewTransition APIs not for react reconciler to its own TurboModule (#56257)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56257

## Changelog:

[General] [Changed] - move ViewTransition APIs not for react reconciler to its own TurboModule

Move `unstable_getViewTransitionInstance` which is not consumed by react reconciler out of UIManagerBinding into a standalone NativeViewTransition CxxTurboModule, following the NativeDOM pattern. This avoids bloating UIManager with ViewTransition-specific APIs.

Reviewed By: christophpurrer

Differential Revision: D98360009

fbshipit-source-id: 191d0c8cc39fbe1cff87e12ad9a99d5e125b0250
2026-04-01 16:24:13 -07:00
Sam Zhou 82bffce573 Cleanup legacy flow types in react-native (#56300)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56300

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D99004126

fbshipit-source-id: dfedc13c867cb768777e2ba65256a2c40ffb1d08
2026-03-31 19:25:25 -07:00
nbondanca 57268c5ba0 Update ktfmt component on FBS:master
Reviewed By: cortinico

Differential Revision: D96922887

fbshipit-source-id: 357f51f07c3bff9e517e0e7466dc5dfe4028a98a
2026-03-22 19:41:32 -07:00
Zeya Peng d8297f7103 Turn on enableViewTransitionForPersistenceMode
Summary:
## Changelog:

[Internal] [Changed] - Turn on enableViewTransitionForPersistenceMode

Reviewed By: christophpurrer

Differential Revision: D97479631

fbshipit-source-id: 78803db6f7b7742c63a65251a9df3ee777e71f56
2026-03-20 15:39:48 -07:00
Nick Gerleman 3483dfa460 Round debug float output to 4 decimal places (#55879)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55879

Float values in debug layout metrics output (used by Fantom test assertions) are
subject to floating-point precision differences across platforms and compilers
(e.g., `66.6667` vs `66.66666412353516`), causing flaky test comparisons.

This changes `toString(const double&)` in `DebugStringConvertible.cpp` to format
floats with 4 decimal places using `snprintf("%.4f")` and strip trailing zeros,
replacing `double-conversion`'s `ToShortest()`. This is debug-only code (guarded
by `#if RN_DEBUG_STRING_CONVERTIBLE`) so the precision change is safe for all
consumers.

The `double-conversion` dependency is also removed from the BUCK file since it is
no longer used.

Output examples:
- `0.0` → `"0"`
- `100.0` → `"100"`
- `66.66666412353516` → `"66.6667"`
- `1.5` → `"1.5"`
- `33.333333` → `"33.3333"`

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D95041966

fbshipit-source-id: 4cce0c9ade73137d6a3d1fffd43905a1cf6d76ac
2026-03-06 01:30:33 -08:00
Marco Wang 53cd9cec15 transformTypeParamBound codemod 9/9 (#55948)
Summary:
X-link: https://github.com/facebook/metro/pull/1665

Pull Request resolved: https://github.com/facebook/react-native/pull/55948

js1 flow-runner codemod flow/transformTypeParamBound --format-files=false xplat/js

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D95429551

fbshipit-source-id: 6f5694fed74364c6f1c58e28376c86eae6201366
2026-03-05 21:26:42 -08:00
Andrew Datsenko 43278f94d2 Add toMatchInlineSnapshot support (#55892)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55892

Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation,
matching Jest's inline snapshot behavior. On first run, snapshot values are
written directly into the test source file as template literal arguments.
On subsequent runs, values are compared and the test fails on mismatch
unless the `-u` flag is passed to force an update.

The implementation spans the two-process Fantom architecture:

**Runtime (Hermes VM):**
- `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares
  received values against existing inline snapshots, captures stack traces
  for new/mismatched snapshots, and tracks results per test.
- `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class
  that serializes values with `prettyFormat` and delegates to snapshot context.
- `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`.

**Runner (Node.js):**
- `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack
  traces back to original source locations via source map symbolication.
  New `saveInlineSnapshotsToSource` directly rewrites the test source file
  by finding each `toMatchInlineSnapshot(...)` call and replacing its
  argument with the formatted template literal. This avoids jest-snapshot's
  `saveInlineSnapshots` which requires Babel and Prettier 2.x.
- `runner.js`: Generates source maps when inline snapshots need updating,
  collects pending snapshots across test configs, and writes them after
  all configs complete.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D95077617

fbshipit-source-id: 6a25c8ce966ed71ecd8977c13c25de5907311c6e
2026-03-05 11:14:41 -08:00
Zeya Peng 15e52e3f71 Add c++ AnimatedModule to DefaultTurboModules (#55729)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55729

This is added so that one can easily enables c++ AnimatedModule in open source.

If an app doesn't use `RCTAnimatedModuleProvider`(ios) or `AnimatedCxxReactPackage`(android), it can fallback to this default AnimatedModule when it has both c++animated and shared backend enabled
- shared backend removes the need to pass down start/stop callbacks to NativeAnimatedNodesManagerProvider, so we can cleanly initialize it as static default
  -  RCTAnimatedModuleProvider uses the version of AnimatedModule that still relies on a dedicated CADisplayLink for start/stop
  - AnimatedCxxReactPackage also bundles internal ViewEventModule (for NativeViewEvents) that shares `NativeAnimatedNodesManagerProvider` with AnimatedModule, but NativeViewEvents is not needed for open source
    - Alternatively we could also expose `NativeAnimatedNodesManagerProvider` via UIManager so other turbomodules can also use it. However I don't think it makes sense to double down on another animation API on UIManager given we have shared backend.
- This assumes DefaultTurboModules is always the fallback module provider. So it'll not override when app already uses RCTAnimatedModuleProvider or AnimatedCxxReactPackage

## Changelog:

[General] [Added] - Add c++ AnimatedModule to DefaultTurboModules

Reviewed By: NickGerleman

Differential Revision: D94244698

fbshipit-source-id: 09e905eb4bad7d03cdf87d5b47352060b0e6212f
2026-03-04 10:34:53 -08:00
Samuel Susla 9ebb3259f0 Add getDefinedEventHandlers API (#55861)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55861

Add `Fantom.getDefinedEventHandlers(element)` which returns the names of event handlers registered on a component. It Reads committed memoizedProps from the React fiber, so it works for any component type — including component-specific events like ScrollView's onScroll.

The alternative we considered was reading the ViewEvents bitmap from `BaseViewProps` in the ShadowNode (C++). That approach only covers View-specific touch/pointer events and onLayout; it misses component-specific events dispatched imperatively (e.g. ScrollView's onScroll), requiring a separate codepath per component type.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D94936370

fbshipit-source-id: f48b6e37a9e7cf252f396db69e1a43ecca82db96
2026-03-03 23:53:36 -08:00
Samuel Susla 21e6aa3aa5 Fix Fantom getRenderedOutput not reflecting removed props (#55891)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55891

`RenderOutput::renderView` merged old cached props with new debug props
via `mergeDynamicProps`. Since `getDebugProps()` omits default-valued
props, removed props were never cleared from the cache. Also,
`renderedViews_.insert()` never overwrote existing entries.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D95055704

fbshipit-source-id: 6cdcbde0473a1d03785f49a9eac79be18395a0bf
2026-03-03 13:12:23 -08:00
Andrew Datsenko e1c296869d add cpp coverage (#54637)
Summary:
Changelog: [Internal]

Pull Request resolved: https://github.com/facebook/react-native/pull/54637

Add c++ code-coverage mode for Fantom and set up custom output path for it.

Reviewed By: sammy-SC

Differential Revision: D87548065

fbshipit-source-id: 5462582ca467051f7e9a155fd82bfb7045380097
2026-03-03 09:28:25 -08:00
Andrew Datsenko c4a982920d Add LLVM coverage conversion to LCOV format (#55860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55860

Changelog: [Internal]

This diff adds the ability to convert LLVM coverage JSON output to LCOV format for C++ code coverage in react-native-fantom.

Key additions:
- `convertLLVMCoverage.js`: Converts LLVM coverage data (segments, branches, functions) to LCOV format lines
- `types.flow.js`: Flow type definitions for LLVM coverage data structures
- Test utilities and fixtures for validating the conversion with real coverage data from various C++ files (AppSettings.cpp, Class.h, DevSettingsModule.h, NativeFantom.cpp/h, RawPropsKey.cpp)

This enables reporting C++ code coverage from Fantom tests in a standard format that can be consumed by coverage tools.

Reviewed By: sammy-SC

Differential Revision: D90135000

fbshipit-source-id: 3b22250c4b1665748b6ccb4feb79cc1c20ec7fa6
2026-03-03 09:28:25 -08:00
Nicola Corti 055fb7a819 Add missing viewtransition subdirectory to Fantom tester CMakeLists (#55887)
Summary:
The ViewTransitionModule commit (f81f73e5a0) added `react_renderer_viewtransition` as a dependency of `react_renderer_scheduler`, but did not update the Fantom tester's `CMakeLists.txt` to include the `react/renderer/viewtransition` subdirectory. This causes the Fantom tester build to fail with:

```
/usr/bin/ld: cannot find -lreact_renderer_viewtransition: No such file or directory
```

This adds `add_react_common_subdir(react/renderer/viewtransition)` to the Fantom tester CMakeLists.

Changelog: [Internal]

Pull Request resolved: https://github.com/facebook/react-native/pull/55887

Test Plan: - `run_fantom_tests` CI should pass with this fix.

Reviewed By: cipolleschi

Differential Revision: D95066938

Pulled By: cortinico

fbshipit-source-id: aeda33365d9967fa7a3e07ac57c4a86863f20243
2026-03-03 09:22:51 -08:00
Nick Lefever b2efda00a8 Improve bundling error message formatting (#55794)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55794

Format the error messages coming from bundling to mainting the formatting and make these easier to read.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D94611951

fbshipit-source-id: cbb8b2d1ff517b5487d4b799b1e2e3476629f84c
2026-03-01 17:49:19 -08:00
Samuel Susla 1eca581446 Add C++ sampling profiler support with FANTOM_PROFILE_CPP (#55735)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55735

changelog: [internal]

Add support for profiling C++ code in Fantom tests using Linux `perf`.

When `FANTOM_PROFILE_CPP=1` is set, the fantom_tester binary is wrapped with `perf record` to capture sampling profiler data with DWARF call graphs.

Usage:
```
FANTOM_PROFILE_CPP=1 yarn fantom --benchmarks --testPathPattern="View-benchmark"
```

Output is saved to `.out/cpp-traces/perf-<timestamp>.data` and can be analyzed with:
```
perf report -i .out/cpp-traces/perf-<timestamp>.data
```

Reviewed By: rubennorte

Differential Revision: D92155573

fbshipit-source-id: bde3ffcd11468e4ad88bec4b547726bed7cbde41
2026-02-27 04:03:13 -08:00
Alex Hunt 703fe8b222 Add module mock for DefaultToolLauncher and apply in tests (#55728)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55728

Fixes unwanted side effect launches of the debugger shell in tests (likely introduced in D88161573!).

Also adds error guard on `DefaultAppLauncher` to ensure that the implementation is always mocked.

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D94230761

fbshipit-source-id: 966f6f09c38aa55594091bd7d34a5c78dc6eee93
2026-02-26 12:12:16 -08:00
Nick Lefever 017bf1a7f0 Fix asan/tsan env options handling (#55753)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55753

The warning "ASAN and TSAN modes cannot be used together" was incorrectly displayed when only ASAN was enabled. This happened because the condition checked only `enableASAN` instead of `enableASAN && enableTSAN`. Updated the conditional logic to properly check that both flags are enabled before showing the conflict warning.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D94393117

fbshipit-source-id: f7a96de11230710e8d54c17d4c89edb569ebaa07
2026-02-25 13:19:50 -08:00
Samuel Susla 89df2e3a75 Fix Buck2 --out permission errors on macOS for claude code (#55736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55736

changelog: [internal]

On macOS with EdenFS backed directories, Buck2's --out flag fails with "Operation not permitted" error.

This fix works around the issue by:
1. Building to a temp directory outside the repo (os.tmpdir())
2. Removing extended attributes with `xattr -rc` on macOS

Reviewed By: cipolleschi

Differential Revision: D92078500

fbshipit-source-id: 437734c068e4bf20a4f8e570e1184565810154d3
2026-02-25 05:16:09 -08:00
Samuel Susla 677330a6d6 Exclude benchmark tests by default, add --benchmarks flag (#55725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55725

changelog: [internal]

By default, `yarn fantom` now excludes benchmark tests (`*-benchmark-itest.js` files) to speed up regular test runs.

Benchmark tests are typically slower and used for performance analysis rather than correctness testing. Excluding them by default improves the developer experience for everyday test runs.

To run benchmark tests, use the new `--benchmarks` flag:
```
yarn fantom --benchmarks
```

Reviewed By: andrewdacenko

Differential Revision: D92150163

fbshipit-source-id: 4c40ef1ba542c4856221373d8239ba603e8f6620
2026-02-25 03:17:00 -08:00
Samuel Susla 1707d30025 stop standalone Devtools from starting in Fantom (#55713)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55713

changelog: [internal]

when running Fantom on Mac, I frequently see this error. This is DevTools standalone app crashing. Let's disable DevTools standalone app, it is not needed with tests anyway.

 {F1985865132}

Reviewed By: huntie

Differential Revision: D94092247

fbshipit-source-id: 440e4482102b2f4152eb63c04023b01867250213
2026-02-24 09:39:47 -08:00
Bartlomiej Bloniarz b38428c9bc Fix js sync on animation end in Animation Backend (#55566)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55566

In Animation Backend, we allow animation frameowrks to request a js-thread sync of the current animation state. It is used by c++ Animated, and is meant to serve as a way to push animation changes to react through RSNRU, after the animation finsishes. This way we ensure that subsequent rerenders of the component don't bring back the old style value.

This approach is currently broken when the animation performs any main-thread commits, as in this case the `runtimeShadowNodeReference_` is not copied to new node revisions, so the js-thread sync commit cannot use RSNRU properly. The bug was not visible, because we don't clean up the registry in that case, we only do it for react commits.

This PR fixes the issue for the case when `updateRuntimeShadowNodeReferencesOnCommitThread` is enabled, as this fixes the RSNRU propagation, so we can clean-up the registry. If the flag is disabled, we don't cleanup the registry, as we want the next react commit to make sure the animation state is not overwritten.

# Changelog

[General][Added] - test for the Animation Backend js sync
[General][Changed] - TesterAnimationChoreographer changes the thread_local RSNRU flag when running animation update, to better simulate the real application use-case
[General][Changed] - AnimationBackend now cleans-up the AnimatedPropsRegistry after the js sync when `updateRuntimeShadowNodeReferencesOnCommitThread` is enabled

Reviewed By: zeyap

Differential Revision: D93414839

fbshipit-source-id: 1c2566d117c2da563ae35e95cefc5ea08313fc7d
2026-02-19 02:20:47 -08:00
Jack Pope ba4ed28cb0 Add host instance pointer and text node feature flags (#55614)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55614

- enableFragmentRefsInstanceHandles
  - Enables a pointer on each element back to the FragmentInstances that control it. Needed to implement the common IntersectionObserver pattern of reusing IntersectionObservers across multiple callbacks. See more in https://github.com/facebook/react/pull/34935
- enableFragmentRefsTextNodes
  - This should be a noop on RN as unlike dom, text nodes are considered host components and already handled. Text without a `<Text/>` wrapper throws an error.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D93479122

fbshipit-source-id: 639369893c8aafc1d2bf0ffbdf4bf09fe6dca45c
2026-02-18 09:53:41 -08:00
Zeya Peng 4cfb2ee468 enable -DRN_USE_ANIMATION_BACKEND by default (#55266)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55266

## Changelog:

[General] [Changed] - enable -DRN_USE_ANIMATION_BACKEND by default

Reviewed By: cipolleschi

Differential Revision: D91056420

fbshipit-source-id: bd8ef6b63a593540688c1af6a25274d047f43f9b
2026-01-23 07:49:20 -08:00
Bartlomiej Bloniarz 2a4a54ae6c Use timestamp from Animation Backend in Animated (#55206)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55206

To avoid timestamp representation bugs with different platforms passing the timestamp as a simple double, we now use `std::chrono::duration<double, std::milli>` to represent timestamps.

# Changelog
[General] [Added] - `AnimationTimestamp` to `UIManagerAnimationBackend`
[General] [Changed] - updated `AnimationBackend` usages to use `AnimationTimestamp`

Reviewed By: zeyap

Differential Revision: D90505538

fbshipit-source-id: 98761ac0060612e9ed9a57c9952656cae70c30f1
2026-01-20 05:26:20 -08:00
Bartlomiej Bloniarz f8564b47fd Move AnimationBackend initialization from Animated (#55103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55103

This diff decouples AnimationBackend from Animated. Now the backend is intialized in the Scheduler, from where it's passed to UIManager. Animation frontends (such as Animated) can then obtain a reference to the backend, and use it to schedule animation frame updates.

# Changelog
[General] [Changed] - Moved AnimationBackend initiailzation to `Scheduler`
[General] [Added] - `AnimationChoreographer` interface with an implementation for fantom tests

Reviewed By: zeyap

Differential Revision: D89663251

fbshipit-source-id: 428a83d78ef92a89095989fe3121c578cf8d3983
2026-01-20 02:28:23 -08:00
Jakub Piasecki 1c63877fec Explicitly enable debugger when building Hermes for Fantom (#55202)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55202

Changelog: [Internal]

After changing Hermes V1 to be the default engine, Fantom tests started failing. This was due to a combination of changes, one of them being the change of default value for `HERMES_ENABLE_DEBUGGER`. In case of legacy Hermes it was enabled by default, while for Hermes V1 it's disabled by default.

Fantom didn't explicitly set this flag, but the debug build of RN (which Fantom performs) requires it to be enabled. This diff explicitly sets this flag to true for Fantom builds.

Reviewed By: cipolleschi, cortinico

Differential Revision: D90849881

fbshipit-source-id: 17f8393872eacef26f927f50aaf364644d9b94d7
2026-01-16 06:42:34 -08:00
Jakub Piasecki 58f9141aec Propagate Hermes V1 opt-in to Fantom (#55157)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55157

Changelog: [Internal]

At the moment, Fantom doesn't propagate the Hermes V1 opt-in to the React Native build, which causes the code that should be gated by compile-time flags to be compiled. Since Hermes V1 differs in some cases, the headers there are missing.

This diff adds the opt-in propagation, so the code can be correctly compiled out.

Reviewed By: cortinico

Differential Revision: D90674696

fbshipit-source-id: d2adb131af4588e745c023703a893d0ecaaaee01
2026-01-16 06:42:34 -08:00
Marco Wang 92c32780f1 Transform $ReadOnlyArray to ReadonlyArray 18/n (#55152)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55152

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.

drop-conflicts

Command:

`js1 flow-runner codemod flow/transformUtilityType --legacy-type='$ReadOnlyArray'`

Reviewed By: SamChou19815

Differential Revision: D90424826

fbshipit-source-id: 207e1abebb50671e8eb2a7f79ecfeaf4569b5b3e
2026-01-13 21:59:05 -08:00
Nicola Corti ebf117ca95 Account for REACT_NATIVE_DOWNLOADS_DIR inside fantom (#55148)
Summary:
Currently Fantom is completely ignoring the `REACT_NATIVE_DOWNLOADS_DIR` env variable that other scripts in the repo are instead honoring. This fixes it.

## Changelog:

[INTERNAL] -

Pull Request resolved: https://github.com/facebook/react-native/pull/55148

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D90594286

Pulled By: cortinico

fbshipit-source-id: 872a26fc15a2acbe3c0e26035407159c20a9a285
2026-01-13 10:34:10 -08:00
Pieter De Baets bc8970ec9e Fix Hermes opt mode for local mac runs (#55138)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55138

Some tests were failing locally on Mac, since //arvr/mode/mac-arm/opt doesn't correctly undefine REACT_NATIVE_DEBUG. Use `//xplat/mode/hermes/opt` as a short-cut since that directly defines rn_build_mode.

Changelog: [Internal]

Reviewed By: zeyap

Differential Revision: D90536112

fbshipit-source-id: 55aeb78970c9d210206a6d86cd3e57d55b0a6396
2026-01-13 06:40:10 -08:00
Marco Wang 41efc3b588 Transform $ReadOnly to Readonly 38/n (#55067)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55067

Differential Revision: D90146229

fbshipit-source-id: 62733ba51fd0c318140b7a76b499b1a7ac1f7853
2026-01-06 20:23:03 -08:00
Marco Wang 894a1f16ef Transform mixed to unknown in xplat/js (#54954)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54954

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.
drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D89581744

fbshipit-source-id: 58a6c246629bbe4fb5c0af447dc002c48e10c342
2025-12-22 12:25:44 -08:00
Marco Wang f41f3bf41f Transform all Flow legacy utility types ($NonMaybeType) to TypeScript-style types in xplat/js (#54935)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54935

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.

drop-conflicts

Reviewed By: gkz

Differential Revision: D89494075

fbshipit-source-id: 1bc3e0039dfb5bf04f1860d5098e024fb8491647
2025-12-19 01:35:12 -08:00
Jakub Piasecki 076e6a1d53 Use prebuilt Hermes by default when building Android (#54707)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54707

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D87929652

fbshipit-source-id: 439eef5eea9b9203cf2a7b5a8eae38d83e192bd5
2025-12-15 08:13:16 -08:00
Andrew Datsenko eb13ebaaf4 enable render debug strings to opt mode (#54581)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54581

Changelog: [Internal]
This helps us test with opt mode enabled as its the only one available for coverage.

Reviewed By: javache

Differential Revision: D87346884

fbshipit-source-id: 76dcb0848c3d4019739120339dd5b16dd25ef02d
2025-11-23 12:01:55 -08:00
Gang Zhao 11f6ffd139 Add DEFAULT_OSS_HERMES_VARIANT and change DEFAULT_HERMES_VARIANT to use SH internally (#54543)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54543

Changelog: [Internal]

We are switching to SH as default, so internally, we need to switch
DEFAULT_HERMES_VARIANT to use SH stable. To keep the tests working in
OSS, we add DEFAULT_OSS_HERMES_VARIANT to use legacy Hermes.

Reviewed By: cipolleschi

Differential Revision: D87082037

fbshipit-source-id: f2fa00d6922816881201d736aeb6591745127d4c
2025-11-17 11:52:11 -08:00