Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43098
Changelog: [Internal]
Wraps Hermes's `CDPHandler::getState()` API in an engine-agnostic abstraction (`RuntimeAgentDelegate::getExportedState`).
An Agent's lifetime ends when its Target is destroyed, but it can occasionally be useful to persist some state for the "next" Target+Agent of the same type (in the same session) to read.
`RuntimeAgentDelegate` is polymorphic and can't just write arbitrary data to SessionState. Instead, it can now *export* a state object that we'll store and pass to the next `RuntimeTargetDelegate::createAgentDelegate` call.
Reviewed By: huntie
Differential Revision: D53919696
fbshipit-source-id: a8e9b921bc8fc2d195c5dddea9537e6ead3d0358
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43054
Changelog: [iOS][Android][Added] Experimental macro to autolink C++ turbomodules
This implementation is inspired by RCT_EXPORT_MODULE on iOS. We keep a global data structure that maps module names to a lambda that returns the C++ turbomodule. This will come with a hit to startup time. the only way to avoid that is a solution that does static analysis of the list of C++ turbomodules being linked to the library.
Reviewed By: fkgozali
Differential Revision: D53602544
fbshipit-source-id: 8ea49fa576dc718f44b1595b68ab7c606c2db605
Summary:
Changelog: [Internal]
Ports RN's Hermes CDP integration tests to `TYPED_TEST` so we can easily run them against a different Hermes engine adapter in another diff.
bypass-github-export-checks
Reviewed By: huntie
Differential Revision: D53810359
fbshipit-source-id: fb9717bbdc1346ed26b9c8796c13bac641bc5a60
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43091
Fix typo in unit test
Changelog:
[Internal] [Changed] - Fix typo in unit test
Reviewed By: mdvacca
Differential Revision: D53918471
fbshipit-source-id: 0453c01fab1dc04397058577ea61b50994124cf0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43090
I'm removing test_windows from CircleCI as the job is often flaky for various reasons.
The cost of maintainaining it is so high at the moment, and it brings little to no value to our developers.
We'll re-evaluate what to do with it once we move to GHA.
Changelog:
[Internal] [Changed] - Remove test_windows from CircleCI
Reviewed By: cipolleschi
Differential Revision: D53918601
fbshipit-source-id: b76c92f1eb3d2302595773dff9f8bbc292c0bfcf
Summary:
Changelog: [Internal]
Hermes:
Adds the missing `validateExecutionContext` call to `Runtime.evaluate`.
React Native:
Adds an integration test case to cover the expected behaviour around targeting `Runtime.evaluate` by execution context.
bypass-github-export-checks
Reviewed By: huntie
Differential Revision: D53776532
fbshipit-source-id: 66676383ba5b373fdbf2deb8c75f22791b07e300
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43075
There is a `\` in the new_architecture.rb file that should not be there.
## Changelog:
[Internal] - remove unnecessary character
Reviewed By: cortinico
Differential Revision: D53886548
fbshipit-source-id: a614368bed9f467b80c3384e4adc4be2cbcaba2d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43081
When Hermes i used, it is hermes that provides JSI to React Native and not React-jsi.
This is required to fix the ODR violatons.
Dynamic frameworks requires that all the dependencies are declared explicitly, and missing the `hermes-engine` dependency was breaking the dependency graph.
## Changelog
[Internal] - Make JSIInspector depends o hermes-engine
Reviewed By: motiz88
Differential Revision: D53901016
fbshipit-source-id: a511719647e6203d082696fd572593fd851a1dde
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43065
Changelog: [Internal]
Implements support for [`Runtime.addBinding`](https://cdpstatus.reactnative.dev/devtools-protocol/tot/Runtime#method-addBinding) in the new RN CDP backend.
This implementation is mostly complete and matches Chrome's behaviour, but does not include the ability to target bindings by execution context (the optional `executionContextId` and `executionContextName` params) - that will come in a separate diff for ease of review/landing.
Incidentally, this diff also introduces the `JsiIntegrationPortableTest::expectMessageFromPage` helper, which allows us to "asynchronously" extract the contents of an expected message. For consistency and clarity, we refactor all the other `EXPECT_CALL(this->fromPage(), onMessage(JsonEq(...)))` assertions to use it as well.
Reviewed By: huntie
Differential Revision: D53266709
fbshipit-source-id: 046326acdf5dacc18e179e43589cdd2d012f353a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43064
Changelog: [Internal]
Aligns React Native's CDP backend with V8's behaviour of assigning a sequential ID (here unique within a given PageTarget) to each execution context.
Reviewed By: huntie
Differential Revision: D53776531
fbshipit-source-id: 950599c323f416e8180e42281d94ae9c00f15fb0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43063
Changelog: [Internal]
Moves the responsibility for managing CDP execution contexts out of the Runtime and into the Instance.
This includes the responsibilities to:
1. Assign execution context IDs/names
2. Emit events when execution contexts are created/destroyed
3. Route CDP messages to the correct Runtime
**Re 1:** We currently assign a *constant* execution context ID, which diverges from V8's implementation but is in line with what Hermes has done so far. I'll follow up separately to assign (locally) unique IDs, since this diff is long enough already.
**Re 3:** Right now, the message routing responsibility is mostly theoretical: only one Runtime exists at a time and "routing" can be done by RuntimeAgent simply deciding whether or not to act on a message (since it receives all messages by default and knows its own `ExecutionContextDescription`). True multi-Runtime / multi-context support is firmly a future concern, and we can revisit this ( = probably hoist more logic into Instance) when we get there.
In the `ExecutionContextNotifications` integration test we can see that a few minor bugs in the current Hermes-based implementation are fixed, and also that execution context management is now engine-agnostic (so we can use `JsiIntegrationPortableTest` instead of `JsiIntegrationHermesTest`).
Reviewed By: huntie
Differential Revision: D53759776
fbshipit-source-id: 50ac126789c95b25f845780df2c3346ec345d5d5
Summary:
While looking at another issue, I realized that in some cases the script was adding the same flags twice and it was leaving the RCT_NEW_ARCH_ENABLED behind.
## Changelog:
[iOS][Fixed] - Pass the right flags to libraries
Pull Request resolved: https://github.com/facebook/react-native/pull/43071
Test Plan: Fixed Unit tests
Reviewed By: huntie
Differential Revision: D53860576
Pulled By: cipolleschi
fbshipit-source-id: 1f6f4852df8d316293b93d7c5fbef09a249893a5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43060
When inestigating the reason why [`react-native-view-shot`]() ws not working, we realized that there are many libraries that follows this pattern:
```objc
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (UIView *view = viewRegistry[reactTag]) {
//do something with the View
}
}];
```
The problem is that, with the New Architecture, that view registry is usually empty, because the components are registered and tracked in another place.
This make many libraries stop working when used with the New Architecture.
This change introduces a class that behaves like a dictionary but that forward the calls to retrieve the view to the right place, in order to get the view that is needed.
Noticably, this approach allow us also to remove some shenanigans we were applying to make sure that the interop layer could access the views wrapped in it, so the current solution is more general and should work in multiple situations.
## Changelog
[iOS][Fixed] - Make sure that `addUIBlock` provides a Dictionary-look-alike object that returns the right views when queried.
Reviewed By: sammy-SC
Differential Revision: D53826203
fbshipit-source-id: 08d359676d69777b88fa9b18dc141187ac42dbce
Summary:
This is a preliminary change which converts RCTConvert to an objectiveC++ file. This is required by the next diffs in the stack.
## Changelog
[iOS][Changed] - Make RCTConvert an Objective-C++ (`.mm`) file in prep for DisplayP3 changes
Reviewed By: javache
Differential Revision: D53520228
fbshipit-source-id: cf45c42955401b4e14fe68221129077817b2598e
Summary:
The test_ios_rntester-Hermes which runs in github actions was created to make sure that recent commits on Hermes/main won't be breaking React Native
However, we discovered that the job was using a cached version of hermes and it was't really downloading the latest hermes every time.
With this change, the cocoapods cache will be invalidated whenever there is a commit on hermes/main, forcing the job to reinstall the dependencies when that happens.
bypass-github-export-checks
## Changelog:
[internal] - Fixed GH Action job to properly refetch newest version on Hermes when it changes.
Pull Request resolved: https://github.com/facebook/react-native/pull/43067
Test Plan:
Github Actions must be green and the action should show that a new version of Hermes is downloaded.
The commit is downloaded here:
{F1457505882}
And it is used here, notice the last hash:
{F1457505989}
Reviewed By: motiz88
Differential Revision: D53853963
Pulled By: cipolleschi
fbshipit-source-id: 7a65dd72a21b6da12b826273d1c92bb90b678652
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43053
- Relocate under `scripts/e2e/` (also move util used only by this cript).
- Type as Flow (to catch trivial errors). Some cleanup of `log()` calls as errors.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D53813023
fbshipit-source-id: 05caf415ec0bf3739a6f7fec3afd385a195f42e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43001
More understandable name: ~"React Native init, for E2E testing". Also relocates Verdaccio config and storage location under `scripts/e2e/` (resolving TODO comment).
The intent is for the `scripts/e2e/` dir to also group the existing E2E testing-related scripts — although I will stop here for the current release-related work.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D53609332
fbshipit-source-id: fb2f6502a18c4a4ac2368b46af1e3ee42edbadd6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42899
Updates the `test-e2e-local` script to bootstrap `/tmp/RNTestProject/` using the currently checked out repository as the source of truth for all monorepo packages (previously we only did this for the `react-native` package).
This enables release testers to validate a release **before** physically publishing new dependency versions via `yarn bump-all-updated-packages`.
We are able to reuse the `scripts/template/initialize.js` script that is currently used for E2E validation in CI. This sets up a local Verdaccio server during project install.
NOTE: The time taken for `Build packages` + Verdaccio isn't ideal, I may explore a way to reuse the published package state in a future diff. Until then, this extra time (~1 min) will still be much less pain than the `bump-all-updated-packages` + commit process loop.
Changelog:
[Internal] - Update test-e2e-local to use source monorepo packages for RNTestProject
Reviewed By: lunaleaps
Differential Revision: D53484510
fbshipit-source-id: 600a8a3257a4947d7738ab9d908d6549c38545e6
Summary:
This PR makes `__gitignore` file universal for Apple OOT platforms.
## Changelog:
[GENERAL] [CHANGED] - Make template's .gitignore file universal for OOT platforms
Pull Request resolved: https://github.com/facebook/react-native/pull/42963
Test Plan: CI Green
Reviewed By: NickGerleman
Differential Revision: D53674632
Pulled By: yungsters
fbshipit-source-id: cb510d9bd2ee6f1c39b77a842e7947b67def552a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43039
Changelog: [Internal] - `publish-npm.js` is a [script we call in our CI](https://www.internalfb.com/code/fbsource/[c0b8566ac0d66c2c0282eeb597bfb54bedf757c6]/xplat/js/react-native-github/.circleci/configurations/jobs.yml?lines=1243) to publish the react-native package and others.
Currently, the script leverages `exit/process.exit` to terminate early in a couple of places which makes the code hard to test because our tests don't truly early exit when `exit/process.exit` is called.
This change removes any explicit `exit` calls and instead leverages the uncaught error to terminate the process and set the non-zero exit code. This makes our tests more accurate to the real control flow of the script.
I've also updated the tests to better capture what we're actually testing by mocking at a higher level.
Reviewed By: cipolleschi
Differential Revision: D53792754
fbshipit-source-id: 9293bb9a95430c50052db36c0e6f6c1ba348107f
Summary:
This PR fixes PerfMonitor option not showing on iOS when running bridgeless. The `initialize` method is not called in bridgeless which causes this option to not be added. I've converted this approach to work for both bridgeless and non-bridgeless.
bypass-github-export-checks
## Changelog:
[IOS] [FIXED] - Perf Monitor option not showing in Bridgeless
Pull Request resolved: https://github.com/facebook/react-native/pull/42891
Test Plan: Run RNTester, open Perf monitor
Reviewed By: RSNara
Differential Revision: D53518507
Pulled By: cipolleschi
fbshipit-source-id: c16d41006c5a3f96d53d4f76fd317941a1eb839f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42941
I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).
```
npm ERR! This command does not support workspaces.
```
It turns out this is no longer supported from npm 9.x: https://github.com/npm/cli/issues/6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.
**Changes**
- Remove `npm set registry http://localhost:4873` call.
- This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D53609308
fbshipit-source-id: 77d3666b42963cd61f6d3fd0be00cdc19bbb1ec8
Summary:
When analyzing the `hitTest:withEvent` function, I realized that we were not forwarding the touches to the legacy view.
The previous algorithm was returning the InteropLegacyWrapper view itself when the touches were happening in the legacy view, preventing the handlers attached to the legacy view to fire.
With this change, if the legacy view receives a touch, it can handle it.
## Changelog
[iOS][Fixed] - Make sure to forward touches to the wrapped component in the InteropLayer.
Reviewed By: sammy-SC
Differential Revision: D53806218
fbshipit-source-id: 87b0aa6e900935092e6f5e1533b871c1d224b718
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43018
Assuming that if View is a ViewGroup, its ViewManager is a ViewGroupManager is incorrect. Custom ViewManagers may use ViewGroups internally to represent complex views exposed to JS.
Type-check the ViewManager instead to avoid the crash seen in T178300877
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D53586565
fbshipit-source-id: 49408098cebc7f76d8be0e585187ba9b6ca52049
Summary:
This was introduced to support MapBuffer-based view managers (D33735245), but that experiment has been removed from the codebase (D53072714).
This indirection is preventing a proper fix for a crash we're seeing with RemoveDeleteTree (T178300877)
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D53586567
fbshipit-source-id: d391ca56b23fc3dd57429c5ad8a7a405e97a81f2
Summary:
Changelog: [Internal]
Fixes a small omission in D53756996 that will come into play in future diffs.
bypass-github-export-checks
Reviewed By: robhogan
Differential Revision: D53771004
fbshipit-source-id: 4c94db37ef51793420e126a81c5d6c0543493ec7
Summary:
Changelog: [Internal]
Along with all the places using it like the `_debugSource` on Fiber.
This still lets them be passed into `createElement` (and JSX dev
runtime) since those can still be used in existing already compiled code
and we don't want that to start spreading to DOM attributes.
We used to have a DEV mode that compiles the source location of JSX into
the compiled output. This was nice because we could get the actual call
site of the JSX (instead of just somewhere in the component). It had a
bunch of issues though:
- It only works with JSX.
- The way this source location is compiled is different in all the
pipelines along the way. It relies on this transform being first and the
source location we want to extract but it doesn't get preserved along
source maps and don't have a way to be connected to the source hosted by
the source maps. Ideally it should just use the mechanism other source
maps use.
- Since it's expensive it only works in DEV so if it's used for
component stacks it would vary between dev and prod.
- It only captures the callsite of the JSX and not the stack between the
component and that callsite. In the happy case it's in the component but
not always.
Instead, we have another zero-cost trick to extract the call site of
each component lazily only if it's needed. This ensures that component
stacks are the same in DEV and PROD. At the cost of worse line number
information.
The better way to get the JSX call site would be to get it from `new
Error()` or `console.createTask()` inside the JSX runtime which can
capture the whole stack in a consistent way with other source mappings.
We might explore that in the future.
This removes source location info from React DevTools and React Native
Inspector. The "jump to source code" feature or inspection can be made
lazy instead by invoking the lazy component stack frame generation. That
way it can be made to work in prod too. The filtering based on file path
is a bit trickier.
When redesigned this UI should ideally also account for more than one
stack frame.
With this change the DEV only Babel transforms are effectively
deprecated since they're not necessary for anything.
DiffTrain build for commit https://github.com/facebook/react/commit/37d901e2b81e12d40df7012c6f8681b8272d2555.
Reviewed By: kassens
Differential Revision: D53543159
Pulled By: tyao1
fbshipit-source-id: 8e5509a16ea8d3234881e2305149326fb31e3845
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43012
Changelog: [iOS][Added]
This implements the functionality to give access to the jsi::Runtime in iOS in bridgeless. In bridge, this value is a private selector on RCTBridge that is exposed via category. We build this into the backwards compatible RCTBridgeProxy here.
This should work out of the box in bridgeless if you are already retrieveing the pointer via the bridge. However, we recommend users to eventually migrate towards C++ TurboModule or the RuntimeExecutor if possible. This will be removed in the future.
Reviewed By: RSNara
Differential Revision: D53646413
fbshipit-source-id: a5584f22d433a580d537b8780a3bcd503680acb8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43013
Changelog: [Android][Added]
This is a pre-deprecated API to give access to the jsi::Runtime in Android in bridgeless. In bridge, this value is exposed via the ReactContext, but is not implemented in the BridgelessReactContext. We do that here.
This should work out of the box in bridgeless if you are already retrieveing the pointer via ReactContext. However, we recommend users to eventually migrate towards C++ TurboModule or the RuntimeExecutor if possible. This will be removed in the future.
Reviewed By: RSNara
Differential Revision: D53645247
fbshipit-source-id: b98657560c43a625bdf947d19d186952c9b44364