Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49624
This change improves the iOS infra so that there is no need to modify the Swift AppDelegate or to create a Bridging Header.
## Problem
As of today, it is not possible to create a pure C++ TM and to register it through a Swift AppDelegate
## Solution
We can create a pod that can be imported in a Swift AppDelegate and that offer some pure Objective-C classes.
These classes contains a provider that can be instantiated in Swift.
The TurboModule manager delegate will ask the AppDelegate about the presence of some provider that can instantiate a pure C++ turbomodule with a given name.
The provider has an empty interface, but the implementation contains a function that can actually instantiate the TM. The function is implemented in an Objective-C++ class that imports the pure C++ turbomodule and creates it.
The TMManager extends the provider through a category to attaach the signature of the function that is implemented by the provider.
The last diff in this stack contains an exaple on how to implement this.
## Changelog:
[iOS][Added] - Wire codegen to the new TM provider to automatically register CXX modules.
Reviewed By: javache
Differential Revision: D70082999
fbshipit-source-id: 11d829450e1d17984d6f22ee5b8907073c59d008
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49611
This Change connects the pod created previously to the `RCTTuboModuleManager` so that it can ask the delegate about the CxxTurboModuleProviders.
We had to introduce a `RCTFullTurboModuleManagerDelegate` that implements both the old `TurboModuleManagerDelegate` and the new Swift compatible one.
## Problem
As of today, it is not possible to create a pure C++ TM and to register it through a Swift AppDelegate
## Solution
We can create a pod that can be imported in a Swift AppDelegate and that offer some pure Objective-C classes.
These classes contains a provider that can be instantiated in Swift.
The TurboModule manager delegate will ask the AppDelegate about the presence of some provider that can instantiate a pure C++ turbomodule with a given name.
The provider has an empty interface, but the implementation contains a function that can actually instantiate the TM. The function is implemented in an Objective-C++ class that imports the pure C++ turbomodule and creates it.
The TMManager extends the provider through a category to attaach the signature of the function that is implemented by the provider.
The last diff in this stack contains an exaple on how to implement this.
## Changelog:
[iOS][Added] - Added the React-SwiftCompatibleNativeModules pod
Reviewed By: javache
Differential Revision: D70012142
fbshipit-source-id: db96c4cd3cdd1062b12f11131b7c6c51ecd74bc7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49712
Just keeping AGP up to date to the latest patch version
Changelog:
[Android] [Changed] - Bump AGP to 8.8.2
Reviewed By: cipolleschi
Differential Revision: D70316244
fbshipit-source-id: 6e447bd04841d09717a1c6153b7e5c977a10787c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48315
# Changelog: [Internal]
> NOTE: Some CI jobs are expected to fail, because changes in Hermes D67353585 should be landed first, and then grafted to Static Hermes.
Use newly added serializer and record Trace Events for profiles.
Reviewed By: huntie
Differential Revision: D67353586
fbshipit-source-id: f3738418ec1d47ef4435f00120823845ea5e2fe5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49191
# Changelog: [Internal]
In this diff we are adding another serializer, that will receive local sampling profile (in tracing domain), and will record corresponding Trace Events with `PerformanceTracer`.
It encapsulates the logic of transforming list of samples to `"Profile"` and `"ProfileChunk"` trace events, which will be parsed by Chrome DevTools later.
Reviewed By: huntie
Differential Revision: D68439735
fbshipit-source-id: 0b3f2b3aff5b79a921e0350759e93f5b05e34d8e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49084
# Changelog: [Internal]
> NOTE: Some CI jobs are expected to fail, because changes in Hermes D67353585 should be landed first, and then grafted to Static Hermes.
Added public methods to `PerformanceTracer` instance for registering `Profile` and `ProfileChunk` Trace Events.
Also created data structs in `TraceEvent.h` to simplify serialization process for objects like call frames / samples / etc.
Reviewed By: huntie
Differential Revision: D68558805
fbshipit-source-id: f5eca0435c56828909f99ec0b47841d24ee907b6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49082
# Changelog: [Internal]
> NOTE: Some CI jobs are expected to fail, because changes in Hermes D67353585 should be landed first, and then grafted to Static Hermes.
In this diff we will:
- Call newly added API in Hermes from `HermesRuntimeTargetDelegate.cpp`
- Define format for local Sampling Profile that will be used in Tracing domain
- Implement formatter for Hermes Profile -> Tracign Profile
Reviewed By: bgirard
Differential Revision: D68414421
fbshipit-source-id: 05d76e9bcff46f88a2338490a9d858cb121f72cc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49436
# Changelog: [Internal]
We will record event loop ticks and register corresponding `"RunTask"` Trace Event with our Trace Event engine.
Since this is hot path, I've added some gating under macros that are being used for Fusebox initialization.
There are also plans to add a public method to `PerformanceTracer` to get tracing status, so we could avoid cost of serialization / saving timestamps if trace is not being recorded. I believe rubennorte had plans on this, we will add it on top of that.
> Q: Why not add this to TraceSection?
Long-term, we will have a solution that will be one layer above TraceSection and this `EventLoopTaskReporterRAII`, it is risky now to modify existing `TraceSection` and rely on event names and attempt to map them to Trace Events.
Reviewed By: rubennorte
Differential Revision: D69399955
fbshipit-source-id: b26ac0c376e7dcb5755f36a27bf00dcca6cbff60
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49395
# Changelog: [Internal]
Adding a new method to `RuntimeTarget` that will register it for Tracing.
In our case, it will schedule a callback on JS executor that will register JavaScript thread with `PerformanceTracer`.
Reviewed By: huntie
Differential Revision: D69530984
fbshipit-source-id: 58cffe9e9c4482b494cfcfd3405f7bffa40cdc56
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48836
# Changelog: [Internal]
When `Tracing.start` CDP method is received, here is what happens next:
- `TracingAgent`, which intercepts the event will propagate this status to `Instance` by calling `startTracing()` on `InstanceAgent`.
- `InstanceAgent` will propagate it to `Runtime` entities. The only difference, there is no concept of tracing for Runtime, it will only have an API for starting sampling profiler.
When `Tracing.end` CDP method is received, it is propagated in the same order.
There is also `collect*()` methods for collecting profiles.
This has multiple benefits:
- We can control when `Runtime` or `Instance` are recreated and can ask them to start recording trace profiles right away. This may be required when we would add support for Reload and Profile from Performance panel.
- We might leverage this setup in the future, once we add instrumentation for Network panel. `InstanceAgent` will get notified when tracing started and will correspondingly notify other part of the infrastructure that will be responsible for recording network calls.
- We remain being fully agnostic to the actual `Runtime`, see corresponding `RuntimeTargetDelegate` for `V8`. We don't have the capacity for implementing and maintaining sampling profiler capabilities for it, but this approach unblocks it from technical perspective, if someone would want to invest into this.
`InstanceProfile` is a superset of `RuntimeSamplingProfile`. In the future, `InstanceProfile` may also include things like `NetworkProfile`, or similar stuff.
The definition for `RuntimeSamplingProfile` will be added in D68414421 and relies on the availability of new API for sampling profiler in Hermes.
Reviewed By: huntie
Differential Revision: D68327630
fbshipit-source-id: f8446057f88d87b4394fb692c28b89f1b8ce4eea
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49714
Changelog: [internal]
This package was only needed for testing but it's actually not used.
Reviewed By: hoxyq
Differential Revision: D70318040
fbshipit-source-id: b57ec74932029368117520646972bfee83706017
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49693
Allow setting the ReactNativeInternalFeatureFlags from a Fantom test using the `fantom_internal_flags` pragma.
Changelog: [Internal]
Reviewed By: rubennorte
Differential Revision: D70242739
fbshipit-source-id: 17a69edbd58b93f8b8060192b9881e62febf9635
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49697
Changelog: [internal]
These classes cannot be instantiated directly, but having access to them allows users to do `instanceof` checks, e.g.:
```
if (ref.current instanceof Element) {
ref.current.getBoundingClientRect();
}
```
Reviewed By: yungsters
Differential Revision: D70244966
fbshipit-source-id: 3c1e3698b8851ef9ce3c2865e7435b000984c8f0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49696
Changelog: [internal]
This is just a change for convenience, as Flow is currently typing `textContent` in `Node` as `string` instead of as `string | null` as we were doing.
Our behavior was more correct, as `Document` extends `Node` and it returns `null` in that case, but to ensure a smooth migration we'll adopt the existing definition.
Reviewed By: huntie
Differential Revision: D70244963
fbshipit-source-id: ad8325d6e00c221e858e4e2d45085666ff0a0ce7
Summary:
Solves the iOS part of https://github.com/facebook/react-native/issues/47186.
`onContentSizeChanged` event is sent inside the `updateLayoutMetrics` method every time it's invoked. A change in layout metrics doesn't mean that the content size also changes, like changing the position of the input.
This PR adds a condition that the content size must have changed before sending the event.
|Before this change|After this change|
|-|-|
|<video src="https://github.com/user-attachments/assets/743e1502-e13e-474e-b4a6-ef6873bf9619">|<video src="https://github.com/user-attachments/assets/fe3d3ef5-3951-4ba2-b9a1-c41439ab455c">|
In the reproducer from the issue, `SafeAreaView` is used, which at first renders its content without any insets until its state is updated with the correct insets. Both of these layouts change the layout metrics of the text input, resulting in two events before this change and a single one after.
## Changelog:
[IOS] [FIXED] - Fixed TextInput's `onContentSizeChange` event being dispatched multiple times with the same size
Pull Request resolved: https://github.com/facebook/react-native/pull/49695
Test Plan: Tested on the reproducer from the issue
Reviewed By: NickGerleman
Differential Revision: D70247460
Pulled By: j-piasecki
fbshipit-source-id: 8a1e0d0f55b6b3f8a6d0bb176ed50e47e3b51035
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49699
Changelog: [internal]
Just a minor optimization in `ReactNativeElement`, to stop creating an unnecessary object in the prototype chain for the `super()` removal optimization.
Reviewed By: huntie
Differential Revision: D70250804
fbshipit-source-id: 1f8104f8e17f12264326cd715e07877a371f9dc5
Summary:
This PR implements a C API to switch JS Engines that can be used from Swift.
Here is an example:
```swift
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import UIKit
import RCTRuntime
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
override func createJSRuntimeFactory() -> JSRuntimeFactory {
jsrt_create_jsc_factory() // Easily switch engines here
}
}
```
## Changelog:
[IOS] [ADDED] - js runtime C API for Swift
Pull Request resolved: https://github.com/facebook/react-native/pull/49489
Test Plan: CI Green
Reviewed By: huntie
Differential Revision: D69976988
Pulled By: cipolleschi
fbshipit-source-id: 9333ec62ca99a28c3121f558bbff1ce0457779e3
Summary:
This change refactors the script to prebuild ios dependencies by:
- remove the manually maintained Package.swift
- add script to generate it starting from the configurations that we have
bypass-github-export-checks
## Changelog:
[INTERNAL] - Factor out script to generate Package.swift file
Reviewed By: cortinico
Differential Revision: D70175760
Pulled By: cipolleschi
fbshipit-source-id: a1b0fc6dcdc1860b04ab260697f259c297338f41
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49657
For some use-cases we still want to log using the internal fbsystrace API which allows backdating of events.
This feels a bit weird putting it in `ReactPerfettoLogger`, but maybe we should rename that to something like `TraceLogger` (like we have `TraceSection`).
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D70109680
fbshipit-source-id: 7757b81ec5032e3800446a88198c7da135afdd0e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49691
Changelog: [internal]
This adds a new getter for `document` in the `Root` class in Fantom tests to easily access the document instance for the root.
This isn't very useful at the moment, but will be very useful when we introduce `document.getElementById`, so we can access arbitrary nodes very easily.
Reviewed By: javache
Differential Revision: D69307130
fbshipit-source-id: 2650bc03e143ee9f0b29d0f284a2f9079ab9f765
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49690
Changelog: [internal]
We're shipping this soon and most tests already using DOM APIs to make assertions, so it's easier if we just "ship" in tests.
Reviewed By: javache, sammy-SC
Differential Revision: D69307129
fbshipit-source-id: 75d0be013703cff7bc2bad5cd16c26bc6471e547
Summary:
Migrate com.facebook.react.modules.network.ProgressRequestBody to Kotlin.
Note: To keep the logic the same as in Java, I had to make the params of RequestBodyUtil.createProgressRequest non-nullable again which were made nullable by mistake in https://github.com/facebook/react-native/pull/49584.
## Changelog:
[INTERNAL]- Migrate com.facebook.react.modules.network.ProgressRequestBody to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/49682
Test Plan:
```bash
yarn test-android
yarn android
```
Reviewed By: rshest
Differential Revision: D70239855
Pulled By: cortinico
fbshipit-source-id: 03c5e0bd5c66a4d5df5e4304d4479ec576d350fd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49687
Changelog: [internal]
Just a minor type rename to better reflect what this type will become soon.
Reviewed By: cortinico
Differential Revision: D70185597
fbshipit-source-id: d5a67eda44dc88dd32a5290f1d0b292ed7014006
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49633
Changelog: [internal]
This replaces the definition of `HostInstance` to use an interface instead of an object, to better represent the underlying type (an instance of `ReactFabricHostComponent`) and simplify the migration to the new DOM API.
Reviewed By: huntie
Differential Revision: D70023947
fbshipit-source-id: bf312abf02fec48b2b5afb41053593ce542f7324
Summary:
Reland of https://github.com/facebook/react-native/issues/49413 which was reverted due to an internal crash. I've attempted to do a solution to keep backwards compatibility but doesn't seem to work – keeping the original solution for now, perhaps something else can be cleaned up to avoid the breakage.
## Changelog:
[INTERNAL] - Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/49607
Test Plan:
```bash
yarn test-android
yarn android
```
Verified that the update changes do not cause a crash.
Test flow:
- login to BizApp using Instagram account
- on home screen scroll down to Insights section
- it should show without crashing
Reviewed By: arushikesarwani94
Differential Revision: D70200000
Pulled By: alanleedev
fbshipit-source-id: 89bc948c1b91d9419d4b6e1885d949c4a3c20986
Summary:
## Summary
> [!NOTE]
> This only modifies types, so shouldn't have an impact at runtime.
Some time ago we moved some type definitions from React to React Native
in #26437.
This continues making progress on that so values that are created by
React Native and passed to the React renderer (in this case public
instances) are actually defined in React Native and not in React.
This will allow us to modify the definition of some of these types
without having to make changes in the React repository (in the short
term, we want to refactor PublicInstance from an object to an interface,
and then modify that interface to add all the new DOM methods).
## How did you test this change?
Manually synced `ReactNativeTypes` on top of
https://github.com/facebook/react-native/pull/49602 and verified Flow
passes.
DiffTrain build for [9dd378ff1222335ff133bab2d61001fcc84a1c56](https://github.com/facebook/react/commit/9dd378ff1222335ff133bab2d61001fcc84a1c56)
Reviewed By: poteto
Differential Revision: D70091830
fbshipit-source-id: 2cc49d8ed89e8ee2531dbc4094ef9720fc3040ad
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49678
In this diff I'm undeprecating SynchronousEventReceiver and marking it as UnstableReactNativeAPI, to properly describe the status of this API.
changelog: [internal] internal
Reviewed By: mlord93
Differential Revision: D70193235
fbshipit-source-id: c4818c89eecef135e9e1f82d35e7f1e2d46b1637
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49683
Use of these types will trigger `[internal-type]` error in the next version of Flow. This diff cleans them up ahead of the time.
Changelog: [Internal]
Reviewed By: gkz
Differential Revision: D70202028
fbshipit-source-id: 97b7217040b63514f20888fb20c86596235a82a6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49632
changelog: [internal]
Add gating to experiment with removal of `_turboModuleManagerDelegateMutex`.
# Why remove _turboModuleManagerDelegateMutex?
- It is not consistently used in the class. Here is a case where access to _delegate is not protected by the mutex: https://fburl.com/code/9tay04fn
- From inspecting individual implementations of RCTTurboModuleManagerDelegates, it is not needed to synchronise access.
- It may lead to deadlocks under following conditions:
- **A)** JavaScript thread gets hold of the `_turboModuleManagerDelegateMutex` and then tries to dispatch a block on the main thread synchronously (calling `RCTUnsafeExecuteOnMainQueueSync`). For example, when a new native module is created lazily because JavaScript used it and the native module requires main thread setup.-
- **B)** The main thread tries to get hold of `_turboModuleManagerDelegateMutex` when it is creating a native module ([[RCTModuleRegistry moduleForName:lazilyLoadIfNecessary:]](https://fburl.com/code/lioi5zei)) from Obj-C.
Reviewed By: javache, cipolleschi
Differential Revision: D70087779
fbshipit-source-id: 1780b2f48537dd578260a96f8f498dbe11529689
Summary:
The class is still in Java and also lacks of some tests so adding them to make it safer to migrate or for future refactors.
## Changelog:
[INTERNAL] - Add `ProgressResponseBodyTest` test cases
Pull Request resolved: https://github.com/facebook/react-native/pull/48675
Test Plan:
```bash
yarn test-android
```
Reviewed By: alanleedev
Differential Revision: D68205423
Pulled By: rshest
fbshipit-source-id: edb1dcf4da34377b7b1dcfc68a6e08861421964b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49635
Changelog:
[General][Internal] - report proxy idle state in heartbeat events
The proxy is considered Idle if it didn't receive any messages for 10 seconds.
Reviewed By: robhogan
Differential Revision: D70078637
fbshipit-source-id: 5b8d9a3a6e3e2568e40b3ada0a41e76b277fe66d