Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53410
Changelog: [Internal]
Adding babel-istanbul-plugin to instrument bundle code with coverage reporting.
Metro will transform source code only when coverage flag is set up globally in jest.
Coverage map is then provided by runner as part of test result.
Reviewed By: sammy-SC
Differential Revision: D80716433
fbshipit-source-id: 3831f227f8793f874f0d2366759bb6916e747c72
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53300
# Changelog:
[Internal] -
This adds two new modes to Fantom, allowing to run the native (C++) side with enabling either:
* Address sanitizer, which would detect memory overwrites
* Thread sanitizer, which can detect potential threading issues, such as race conditions
This are opt-in for now.
Currently, both modes already detect different errors, which have a high chance to be real issues and have to be fixed.
Reviewed By: lenaic
Differential Revision: D80339524
fbshipit-source-id: 784ddb9f0af79a04b074e107e4955724d54d5685
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53221
# Changelog:
[Internal] -
This changes the benchmark test results comparison print the results slightly differently, in particular it now uses the slowest result as a baseline and prints how much faster the other ones are (as opposed to printing "slower" previously).
This arguably brings a more positive vibe when looking into the benchmark results :)
Reviewed By: andrewdacenko
Differential Revision: D80082134
fbshipit-source-id: 7dc9c7c520afe08270d4f5da9031db02261690ba
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53215
Changelog: [internal]
This adds a new environment variable to Fantom that allows debugging the JS code in tests.
Usage:
```
FANTOM_DEBUG_JS=1 yarn fantom <test>
```
**Does NOT work in OSS yet**. We need to include a third-party library to send HTTP and WebSocket requests and implement a wrapper on top of it.
Reviewed By: christophpurrer
Differential Revision: D79883372
fbshipit-source-id: d077c373a036033344e61d58274d5cd14028bda4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53202
Changelog: [internal]
Just a minor refactor to follow the convention of prefixing Fantom-related globals and environment variables.
Reviewed By: rshest
Differential Revision: D79804007
fbshipit-source-id: 0c9a57c1b08ae18ae03cd66d1a6ef9690e0dea42
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53204
Changelog: [internal]
This changes the logic to find an available port for Metro on Fantom to do this outside Metro. Before, we'd set `0` as the port for Metro to find an available port, but in a following change we'll need to know the port before calling into Metro. This allows that.
Reviewed By: rshest
Differential Revision: D79804005
fbshipit-source-id: 5c2e2f4acbba3a79771586799b65653d46b8fe72
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53161
Changelog: [internal]
This fixes a bug in the retry logic in Fantom when requesting bundles from Metro, where we cache the error from a previous attempt and use it to determine we didn't succeed after the attemps.
Reviewed By: rshest
Differential Revision: D79881488
fbshipit-source-id: 566b2d700db2f9653b9ea9acd577d7eb03770b76
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53143
# Changelog:
[Internal] -
This refactors the way Fantom benchmark test results are passed to the top level, making it type safe and more maintainable.
Reviewed By: andrewdacenko
Differential Revision: D79812707
fbshipit-source-id: d8bfef7e1b0c11b277a08f5e4c810f8c1efd7f89
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53097
# Changelog:
[Internal] -
This makes the benchmark results comparison printout, added in https://github.com/facebook/react-native/pull/52925, be done in a tabular form, so it's easier to read and copy/paste around.
Reviewed By: lenaic
Differential Revision: D79728695
fbshipit-source-id: 4dfc999ad4a9a8c2d67efdfce11aff75383cf645
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53071
Changelog: [internal]
The current API to take JS heap snapshots has some problems:
1. Ergonomics: it requires you to input the filepath where you want to store the snapshot. This isn't aligned with the behavior we have for JS traces where the output path is provided to you.
2. It doesn't work in optimized builds, as it requires a specific option in Hermes.
For 1), this replaces `Fantom.saveJSMemoryHeapSnapshot(filePath)` with `Fantom.takeJSMemoryHeapSnapshot()` that outputs the snapshot in a predefined path and prints it to the console.
For 2), this adds a new environment variable to force building Hermes with memory instrumentation (`FANTOM_ENABLE_JS_MEMORY_INSTRUMENTATION`). This is exposed as an option and not set by default because it has a performance overhead at runtime that we don't want to pay (especially in benchmarks).
This option only works when using Buck in development, because we want to generate this new binary type on demand when necessary, instead of making it part of the prebuilts we do before running tests in OSS and CI.
Reviewed By: lenaic
Differential Revision: D79642314
fbshipit-source-id: a2980616a495bd6dca29c0709a9581db6fb3f2cc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53069
Changelog: [internal]
This changes the names of the JS traces from Fantom from using a unix timestamp in the file name to using the ISO date:
- From: `View-itest.js-1754406329686.cpuprofile`
- To: `View-itest.js-2025-08-05T15:05:29.686Z.cpuprofile`
Reviewed By: rshest
Differential Revision: D79646760
fbshipit-source-id: d8a654724c1abc2d3e285ee658c2d390d3241d82
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53091
# Changelog:
[Internal] -
This fixes some excessive printing from the benchmarking results, which happened even if there was no benchmarks ran.
Reviewed By: rubennorte
Differential Revision: D79719026
fbshipit-source-id: 0e75d97ae9c762cab25007bfab5ca8a6dc43e148
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52925
# Changelog:
[Internal] -
This adds an extra "ranking" report when running Fantom benchmark vs different React Feature flag configurations.
It can be very useful when implementing some particular optimization, to streamline the before/after comparison wit this optimization enabled/disabled.
Reviewed By: andrewdacenko
Differential Revision: D79269601
fbshipit-source-id: f29e761e313d6857e5b3ac65faf2a387a84be9df
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52827
Changelog: [internal]
This adds **support for creating Hermes/JS sampling profiler traces in Fantom**, which is especially useful when running benchmarks.
Usage:
```
FANTOM_PROFILE_JS=1 yarn fantom Animated-benchmark
```
Output:
{F1980642216}
After this, the trace is fully symbolicated.
Can be opened directly in Google Chrome:
{F1980642229}
Or in the built-in viewer in VSCode:
{F1980642242} {F1980642240} {F1980642241}
When collapsing frames in the Flame Chart viewer in VSCode, we can quickly identify opportunities for optimizations.
This also supports multi-config environments. In that case, trace file names are created using a short representation of the configuration.
User guide for benchmarks in Fantom, including how to use this, will be done in a future diff.
NOTE: This still doesn't work in OSS because we don't support optimized mode there. In dev mode, there's a segmentation fault coming from this line: `hermesRuntime->sampledTraceToStreamInDevToolsFormat(fileStream)`
Reviewed By: sammy-SC
Differential Revision: D78905646
fbshipit-source-id: 382ddd5034db601309bd118cedde2fe0d57fde98
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53034
Changelog: [internal]
This is just a refactor to make sure that the constants we pass from the Fantom runner to its runtime are correct by using Flow to typecheck it.
Reviewed By: andrewdacenko
Differential Revision: D79565574
fbshipit-source-id: cbbab9cdec5ef5b3c82b929b8939c76c0ef41823
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52829
Changelog: [internal]
Just a small refactor to move the definitions of output paths to a specific module. We'll add more to this in a latter diff.
Reviewed By: sammy-SC
Differential Revision: D78905645
fbshipit-source-id: 011e6cec13396301dad8e76400b6f2b9e13568f0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52786
Changelog: [internal]
It takes around 300ms to generate each source map file, and we really only need them if tests throw errors. Requesting source maps also increases contention to access the Metro server from each test worker.
This refactors the code so we only generate them in that case, which could save up to 20s in test execution time.
Reviewed By: rshest
Differential Revision: D78807672
fbshipit-source-id: af9f0f0377ddcf05014b5aca0b28db938dfb4ce2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52777
Changelog: [internal]
This significantly speeds up test execution in Fantom (around 2x in OSS and 6x at Meta) by starting a Metro server before all tests runs and reusing it across all tests to build test bundles, instead of spinning up a new Metro instance every time we run each test.
The architecture change (also considering the previous change in buck prebuilds) looks like this:
{F1980689532}
This is how is impacts execution times (compared to the baseline):
* OSS
* Before: 62s {F1980564286}
* After: 30s (**2x faster**) {F1980564265}
Reviewed By: andrewdacenko
Differential Revision: D78741903
fbshipit-source-id: b209f88925e49cc2a2067e8df9b7fa9a29b4c8d2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52758
Changelog: [internal]
This is a change to how Fantom tests run in Meta infra via Buck.
After this, the biggest opportunity will be optimizing how we generate bundles with Metro.
Reviewed By: christophpurrer
Differential Revision: D78672863
fbshipit-source-id: 1152907f3ba60e7d2e48bcc588f3c07aef7bb393
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53010
Changelog: [internal]
Exposing this value so we can disable some tests in some scenarios in a following this.
Reviewed By: cipolleschi
Differential Revision: D79510481
fbshipit-source-id: 632d9a008943ed40c24878b5561065b6ede1d689
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52894
Adds the following boolean pragma modes for more granular control:
```
fantom_native_opt true|false
fantom_js_opt true|false
fantom_js_bytecode true|false
```
Previously these were all set together with `fantom_mode`. These modes are mutually exclusive with `fantom_mode`.
Changelog: [Internal]
Reviewed By: rubennorte
Differential Revision: D79151687
fbshipit-source-id: 59c3f20bccb570c0293ffd037609946a1a9bbb8f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52861
Changelog: [internal]
We added this mode recently to support all local Hermes variants, but this doubles the number of build type combinations which regresses test execution time and give us little benefit, so we're removing it.
Reviewed By: rshest
Differential Revision: D79080370
fbshipit-source-id: e1b536427acb98ec01edfd44829e2fef9be9b18d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52863
Changelog: [internal]
We're seeing some issues in stress runs for Fantom tests in optimized mode, failing when compiling the bytecode with Hermes. The specific error in the Hermes compiler isn't clear, but this started failing when we changed the folders for output. It's possible that it's due to race conditions in stress runs, where multiple workers are attempting to compile in the same locations.
This forces every output in every runner to be in a different file to prevent these possible collisions.
Reviewed By: rshest
Differential Revision: D79084242
fbshipit-source-id: b4540e2e6c5378c7fc8630ac2fea674e0ef78a14
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52826
Changelog: [internal]
This is just an intermediate change to simplify how we format Fantom configs, so we can extend it to use other formatting formats (e.g.: short format to use in file names).
Reviewed By: lenaic
Differential Revision: D78924771
fbshipit-source-id: 4886a800a6836dc6a66539b1df079adb6c9c52e1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52788
Changelog: [internal]
Minor change to just create a single output directory for generated JS code in Fantom per Jest run.
Reviewed By: lenaic
Differential Revision: D78808564
fbshipit-source-id: 70e1a60dfcdcc3fc6ee5f08ced1e9c8f8cab2782
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52767
Changelog: [Internal]
Currently tests that depend on hermes dev bytecode will fail because in OSS this case was not handled. We need to skip them for now before we integrate hermes compiler properly.
Reviewed By: christophpurrer, rubennorte
Differential Revision: D78750791
fbshipit-source-id: 5b55bc9acbd6ee5aad874ad57607325cb1373c2e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52779
Changelog: [internal]
Adds validation for Fantom environment variables at runtime, to catch typos or variables that no longer have an effect.
Reviewed By: rshest
Differential Revision: D78803045
fbshipit-source-id: efb28a4f3fd6a4be35fb525d91fb093a1e88f7e4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52766
Changelog: [internal]
Just a minor refactor so adding more logic that should work both at Meta and in OSS is easier in the next diff
Reviewed By: christophpurrer
Differential Revision: D78741904
fbshipit-source-id: 3abda5d5b7be157bf381e26dad2fd4b064a0f556
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52776
Changelog: [internal]
`FANTOM_FORCE_CI_MODE` is just an explicit way to indicate that we're on CI, so we'd run benchmarks in test mode, for example.
`FANTOM_DEBUG_CPP` is just an alias for `FANTOM_ENABLE_CPP_DEBUGGING` which is unnecessarily long.
Reviewed By: rshest
Differential Revision: D78801918
fbshipit-source-id: 8e60bdd911067c6b0b92be7e90553fd5209c9ca9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52759
Changelog: [internal]
This introduces a new environment variable for Fantom to disable benchmarks (`FANTOM_FORCE_TEST_MODE`), without having to run in CI mode.
Reviewed By: rshest
Differential Revision: D78672864
fbshipit-source-id: ef445bd8b36703594658529da2436c75d5b87179
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52601
Changelog: [internal]
Fixes a bug in Fantom when throwing a value that's not an instance of `Error` in a test.
Reviewed By: javache
Differential Revision: D78332756
fbshipit-source-id: 350479dcb7bcea399070c6851aca76a1d1cc2629
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52473
Shared utils that were located in the root of `scripts/` are now colocated closer to their dependencies or moved to `scripts/shared/` — simplifying the root directory layout.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D77873875
fbshipit-source-id: e04dba41a1ef811d32793931033fdfa93afad0cd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52222
Changelog: [Internal]
Introduce environment option to force usage of OSS fantom test runner.
If env is not set - check for BUCK file in tester which is checked in for FB but not for OSS.
Reviewed By: rubennorte
Differential Revision: D77160761
fbshipit-source-id: 1701ff140ff2be1bbeacfb4305e9f89089cacb42
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52105
Changelog: [internal]
I just learnt there's a Hermes variant that we don't support (staging) so this adds support for it.
Reviewed By: christophpurrer
Differential Revision: D76897715
fbshipit-source-id: 3113edde3c785d71ad4a57dd435f16e13ab46976