Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48477
Over the years of copying and moving and renaming types through CodegenSchema, this type ended up in the Command params, although the Command parser doesn't allow it.
I made this change to a fixture:
{F1974104959}
and got this error
```
FAIL xplat/js/react-native-github/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js
● RN Codegen Flow Parser › can generate fixture COMMANDS_DEFINED_WITH_ALL_TYPES
Unsupported param type for method "scrollTo", param "speed". Found UnionTypeAnnotation
127 | default:
128 | (type: empty);
> 129 | throw new Error(
| ^
130 | `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
131 | );
132 | }
```
Also, a default value for enum an argument of a Command doesn't make sense anyways.
Commands should probably have support for enums and string literal unions, but that's out of scope here.
Still need to add to this vec\concat on www: https://www.internalfb.com/code/www/[ebfa58f888a6064e17879934d447f59bcc2b6951]/flib/intern/sandcastle/react_native/ota_steps/SandcastleOTACompatibilityCheckReportingStep.php?lines=62
Changelog: [internal]
Reviewed By: cipolleschi
Differential Revision: D67806808
fbshipit-source-id: f0f31cca30abbf61f569933ea7c49cf6bfd18a3f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48485
[Changelog] [Internal] - Make SurfaceManager const correct
This marks methods which don't modify member props as `const` and others as non `const`.
The current API signature is misleading as `const` methods do alter `mutable` members
Reviewed By: rshest
Differential Revision: D67820439
fbshipit-source-id: 6a991bd7ccbd464c2390e33e0c29b136892d65e0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48486
[Changelog] [Internal] - Add RuntimeSchedulerKey constant for RuntimeScheduler lookup
Similar to https://github.com/facebook/react-native/pull/48127 this adds a contant to avoid typos when inserting or retrieving the RuntimeScheduler
Reviewed By: rshest
Differential Revision: D67822346
fbshipit-source-id: af982c6d4b875ffde06aae8e953c4892754a074b
Summary:
**iOS** does offer a native property for **UITextField** called `inputAssistantItem`. According to the [documentation](https://developer.apple.com/documentation/uikit/uitextinputassistantitem), we can hide the **"shortcuts"** by setting the `leadingBarButtonGroups` and `trailingBarButtonGroups` properties to empty arrays.
I propose adding a new property for **TextInput** in **React Native**, which would set these native properties to empty arrays. This new property could be called `disableInputAssistant` or `disableKeyboardShortcuts` and would be a `boolean`.
Developers can manage this behavior (the redo & undo buttons and suggestions pop-up hiding) after applying these native props.
https://github.com/react-native-community/discussions-and-proposals/discussions/830
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[IOS] [ADDED] - [TextInput] Integrate a new property - `disableKeyboardShortcuts`. It can disable the keyboard shortcuts on iPads.
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [ADDED] - [TextInput] Integrate a new property - `disableKeyboardShortcuts`. It can disable the keyboard shortcuts on iPads.
Pull Request resolved: https://github.com/facebook/react-native/pull/47671
Test Plan:
Manual
1. Open TextInput examples.
2. Scroll down and reach the "Keyboard shortcuts" section.
3. Test each case.
Note: **TextInput** behaves the same as now when the new prop is not passed or is `false`.
https://github.com/user-attachments/assets/5e814516-9e6c-4495-9d46-8175425c4456
Reviewed By: javache
Differential Revision: D67451609
Pulled By: cipolleschi
fbshipit-source-id: 59ba3a5cc1644ed176420f82dc98232d88341c6e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48450
Changelog: [internal]
This implements a basic benchmark to compare `ReactFabricHostComponent` and `ReactNativeElement` (legacy and DOM implementations for native component instances).
Reviewed By: rshest
Differential Revision: D66698546
fbshipit-source-id: dd4bde833e5c9eb32c79a52d06f3c360fb012e23
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48451
Changelog: [internal]
Modifies the execution of benchmarks in CI to run benchmarks in test mode when they don't define a `verify` method.
If a benchmark uses `verify`, the test is meant to make sure that the benchmark doesn't regress in CI. If it doesn't, then running the benchmark on CI doesn't provide much value. In that case, we run a single iteration of each test case just to make sure things don't break over time.
Reviewed By: rshest
Differential Revision: D67637754
fbshipit-source-id: 33b78a9c809386cf2e040314b0427de6a53da3e3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48452
Changelog: [internal]
Implements a basic API to run benchmarks with Fantom (using `tinybench` under the hood):
```
import {benchmark} from 'react-native/fantom';
benchmark
.suite('Suite name', {
// options
})
.add(
'Test name',
() => {
// code to benchmark
},
{
beforeAll: () => {},
beforeEach: () => {},
afterEach: () => {},
afterAll: () => {},
},
)
.verify(results => {
// check results and throw an error if the expectations fail
});
```
Features:
* Print benchmark results in the console as a table.
* It opts into optimized builds automatically
* Verifies that optimized build is used (unless manually opting out of the check via `disableOptimizedBuildCheck`).
* Supports verification of results (making expectations and making the test fail if the benchmark doesn't meet some expectations).
Reviewed By: rshest
Differential Revision: D66926183
fbshipit-source-id: 61cfa7689ea7684eb870fbbc815b8d236a1871e6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48454
Changelog: [internal]
This implements a native module for Fantom to provide information about the CPU time used by the current process. This will be used by Fantom as the clock to run benchmarks more accurately.
It provides 2 implementations:
1. One based on `clock_gettime` with `CLOCK_THREAD_CPUTIME_ID` that's available on Linux. This provides the CPU time for the current process with decent precision (tens of nanoseconds).
2. A fallback implementation that uses a monotonic clock (not actually CPU time).
We can add a MacOS equivalent in a following diff.
Reviewed By: rshest
Differential Revision: D67596312
fbshipit-source-id: dd712c0171aa998ddbb6fed9187b3c467cd5417d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48504
Following D67857739, fixes accidental change where the removed `ReactNativeFeatureFlags` flag read was not replaced with `true`. This temporarily disabled Fusebox on `main`, where not configured via other build flags.
{F1974195736}
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D67857739
fbshipit-source-id: 2a6fb2e6733035245e7ad959c7d3c650a9fde994
Summary:
Currently the `AppStateModule` doesn't have any unit tests in the Android implementation. This should make it safer for future changes or refactors.
## Changelog:
[INTERNAL] - Add `AppStateModule` Android unit tests
Pull Request resolved: https://github.com/facebook/react-native/pull/48492
Test Plan:
```bash
yarn test-android
```
Reviewed By: cipolleschi
Differential Revision: D67857498
Pulled By: cortinico
fbshipit-source-id: f90ced1cf02ac12a3438495b425ce7931decf19a
Summary:
As a prerequisite of enabling running unit tests on CI again, this PR suggests changes needed to the Ruby unit tests.
I've added comments on the code below, justifying changes where I deem a justification might be needed.
For use internally, I suggest accessing the folly_config and boost_config directly via the `Helpers` class instead of the `get_folly_config` and `get_boost_config` because these global functions are defined in `react_native_pods` which would be result in circular requires. An alternative would be to move these global functions to a separate file.
## Changelog:
[INTERNAL] [FIXED] - Fix Ruby unit tests.
Pull Request resolved: https://github.com/facebook/react-native/pull/48498
Test Plan:
- `cd packages/react-native`
- `./scripts/run_ruby_tests.sh`
Reviewed By: rshest
Differential Revision: D67852809
Pulled By: cipolleschi
fbshipit-source-id: 54d8bd708a9e3fd9aef3569ac89ec6ddcd244437
Summary:
This PR updates podspecs and resolve the following Xcode warnings:
```
Run script build phase '[CP-User] [RN]Check rncore' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase.
```
```
Run script build phase '[CP-User] [RN]Check FBReactNativeSpec' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase.
```
Enabling the `always_out_of_date` flag will uncheck "Based on dependency analysis" in a script phase.
## Changelog:
[INTERNAL] [FIXED] - Resolve run script build phase warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/48495
Test Plan:
1. Run `bundle exec pod install` in the RNTester folder
2. Open the Xcode workspace
3. Check "Based on dependency analysis" is unchecked in the '[CP-User] [RN]Check rncore' script phase and the '[CP-User] [RN]Check FBReactNativeSpec' script phase
Reviewed By: cipolleschi
Differential Revision: D67835376
Pulled By: rshest
fbshipit-source-id: 11eec80d8172bc0129bfdcf7c79b5edf40427fab
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48490
## Changelog:
[Internal] -
This makes the `RootViewTest` and `JSPointerDispatcher` tests to use mockito-kotlin instead of the Java Mockito, which is the legacy of the conversion of the corresponding tests from Java.
Which:
* is the right thing to do, as we have more Kotlin-idiomatic tests
* helps with some Kotlin conversion with classes under test down the line, as Kotlin Mockito handles things like nullability etc properly
Reviewed By: javache
Differential Revision: D67824679
fbshipit-source-id: 055e9c7c4a33164ce6f4b9a5c47f16051d2a132f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48439
Changelog: [internal]
This is in preparation for implementing `getRootNode` and `ownerDocument` properly in the DOM APIs.
Reviewed By: rshest
Differential Revision: D67137215
fbshipit-source-id: bda6b1f843f219e03df533797fa9e4adbaa54c60
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48438
Changelog: [internal]
Just adding tests to make sure we cover the cases where the root is unmounted.
Reviewed By: rshest
Differential Revision: D67752010
fbshipit-source-id: 3cc17cd25878013a26dc407640be00e8dc251eea
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48434
Changelog: [internal]
We were starting to repeat this logic too much in tests, so extracting so we can reuse it.
Reviewed By: rshest
Differential Revision: D67520443
fbshipit-source-id: 64e4e5b35f83dc45e41bb0efae9685aeaf0cf2e2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48436
Changelog: [internal]
Changing the defaults to use something that resembles a real device (in this case the iPhone 14 which is a very common device).
Reviewed By: christophpurrer
Differential Revision: D67759914
fbshipit-source-id: 87fe3be19196ece62c412e5076c601be746a4f22
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48435
Cleans up the runtime `fuseboxEnabledDebug` feature flag. The modern CDP backend has been enabled by default in open source since 0.76.
- Updates `ReactInstanceIntegrationTest` to preserve testing under both backend modes (legacy Hermes debugger vs Fusebox).
- Preserves ability to override `ReactNativeFeatureFlags` in tests via `InspectorFlagOverridesGuard` — we anticipate that future CDP features will continue to read from the `ReactNativeFeatureFlags` system (`fuseboxEnabled` was/is a special case).
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D67759600
fbshipit-source-id: 5878dd879bae435e59c48823a9b9faf85561b028
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48440
Changelog: [internal]
Modifies the Fantom runner to read 2 new environment variables to help with debugging:
- `FANTOM_PRINT_OUTPUT`: prints the output of the CLI to the output of the test.
- `FANTOM_LOG_COMMANDS`: logs the buck commands executed by the runner, so they can be re-run outside the runner for debugging, etc.
Reviewed By: rshest
Differential Revision: D67682750
fbshipit-source-id: aff48c4f47078db1be53e0ee105089fbc921768f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48372
Changelog: [internal]
Implements log streaming in Fantom tests. This allows us to see the logs emitted from tests as they're logged, so we don't need to wait until the test completes to flush all of them at the same time.
Reviewed By: rshest
Differential Revision: D67600609
fbshipit-source-id: efb3125e13fd9aec1800a5f1ddaf0d93dcb29218
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48371
Changelog: [internal]
Adds a new favor for `runCommand` and `runBuck2` that works asynchronously and support parsing their output in real time.
Reviewed By: javache
Differential Revision: D67600614
fbshipit-source-id: 99dd2ce9bff11036829f214bf19208b10c9c1b25
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48369
Changelog: [internal]
This improves logs in Fantom by preserving the original log levels. It's also in preparation for adding support for log streaming in tests.
Reviewed By: javache
Differential Revision: D67600616
fbshipit-source-id: 1c4997d5e836a78327f33092527543fe025c90c6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48367
Changelog: [internal]
We removed the calls to `AppRegistry` in Fantom, so this filter isn't necessary anymore (just a no-op).
Reviewed By: rshest
Differential Revision: D67600610
fbshipit-source-id: d985cc5f0ee1728ac72c567bc091a6c2877f2659
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48391
Changelog: [internal]
When we enabled log streaming in Fantom, we saw a lot of logs that we were previously not forwarding (console.error, console.warn) in existing tests.
This removes all the warnings and errors from those tests.
Reviewed By: rshest
Differential Revision: D67602299
fbshipit-source-id: 111f373eafd8707f2746ff727894f1fa4283b83f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48432
Changelog: [internal]
This moves the native module definition for Fantom to the `react-native` package so we can migrate the module to use the codegen.
Also implements the migration.
Reviewed By: christophpurrer
Differential Revision: D67759729
fbshipit-source-id: d79d078908b05fc4b6f5f26f0144ab7e3485cb83
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48368
Changelog: [internal]
Just a minor rename to align with the existing convention.
Reviewed By: javache
Differential Revision: D67549203
fbshipit-source-id: faa9e34cdce7c59e2c6b3f7e697c90df103699d0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48465
Removes the `packages/hermes-inspector-msggen` workspace. Since https://github.com/facebook/react-native/pull/39300, this is no longer referenced in React Native, and is now part of the Hermes repo.
Changelog: [Internal]
Reviewed By: cortinico, hoxyq
Differential Revision: D67791612
fbshipit-source-id: 73da135b264d8df632fefe87cc4e3101075ae98c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48430
Changelog: [internal]
This expectation currently prints a very generic message that is hard to parse, so this change improves it a bit to account for more cases. E.g.:
* Before: "Expected <function> to throw"
* After: "Expected <function> to throw with message 'foo', but threw with message 'bar'"
Reviewed By: rshest
Differential Revision: D67738146
fbshipit-source-id: 690f15971cec0e8a7b038eeacc9302c9f3edc323
Summary:
Fixes https://github.com/facebook/react-native/issues/38537
Setting `WindowManager.LayoutParams.FLAG_SECURE` in the window flags is not respected in the Android Modal component, causing security issues with screenshots or screen recordings as the content in the modal is visible. The flag works correctly in the rest of the components, see the videos in the linked issue.
This PR addresses that by checking whether this flag is set in the current activity and then setting it in the dialog when creating a new one in the `ReactModalHostView`.
## Changelog:
[ANDROID][FIXED] - `FLAG_SECURE` not respected in Modal dialog
Pull Request resolved: https://github.com/facebook/react-native/pull/48317
Test Plan:
To test this, you need a physical device as with the emulator the flags don't seem to be respected either.
The easiest way to test this in code is by setting the flags in the main activity. You can do so by adding this code snippet:
<details>
<summary>onCreate in RNTesterApplication.kt</summary>
```kt
override fun onCreate() {
ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik)
super.onCreate()
...
registerActivityLifecycleCallbacks(
object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
activity.window.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
}
)
}
```
</details>
Then, you can render a simple modal component:
<details>
<summary>RNTesterPlayground.js</summary>
```tsx
function Playground() {
const [modalVisible, setModalVisible] = React.useState(false);
return (
<>
<Modal
visible={modalVisible}
testID="playground-modal">
<Text testID="inner-text-test-id">Hello World!</Text>
<Button title="Close Modal" onPress={() => setModalVisible(false)} />
</Modal>
<Button
title="Open Modal"
onPress={() => {
setModalVisible(true);
}}
/>
</>
);
}
```
</details>
You can then try to record the screen or take screenshots. You will notice that before opening the modal, you won't be able to see anything in the recording, but when opening the modal, the content is visible.
I've tried my best to record the before and after the fix, but as the screen recordings will mostly show a black screen, you have to forward a bit in both videos to see the difference.
<details>
<summary>Before the fix (notice the blank screen and then content visible)</summary>
https://github.com/user-attachments/assets/fc5bbe26-d238-425b-90d3-0e43c89ccaac
</details>
<details>
<summary>After the fix (notice all the screen recording is a black screen)</summary>
https://github.com/user-attachments/assets/0d6991a0-974b-45c5-8f4a-bf4718c284e6
</details>
Reviewed By: cipolleschi
Differential Revision: D67368741
Pulled By: alanleedev
fbshipit-source-id: 9f31063a9208a6df257da424bf3096bf15a5ddcb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48414
Was looking into https://github.com/facebook/react-native/issues/48078 which was brought to my attention due to my recent refactorings of iOS Views, especially around how overflow: hidden works. This bug was not brought on by my changes but seems to be a lingering Fabric bug (iirc this bool was not changed when I refactored things)
Anyway, dotted/dashed borders did not work with overflow: hidden. The reason why is we use core animation borders in this case which is incorrect as CA cannot do these types of borders. So I added a check to make sure that the borders are solid as well if we want to use CA to draw them.
Changelog: [iOS] [Fixed] - Dashed & dotted borders now work with overflow: hidden
Reviewed By: mdvacca
Differential Revision: D67720492
fbshipit-source-id: 5aecc15f2d7cbd71952d78d6972f6fc6b7a93ea8