Commit Graph

38536 Commits

Author SHA1 Message Date
Pieter De Baets 6e9a4627c4 Revert D68711137: fix(react-native): pass the protocol from bundle URL to HMR client on Android
Differential Revision:
D68711137

Original commit changeset: 230c1c91c818

Original Phabricator Diff: D68711137

fbshipit-source-id: 00cc23468596d8b75800d7dd388b2c51518d79e6
2025-01-27 14:41:14 -08:00
Nick Gerleman 9aae84a688 Remove some web debugging remnants (#48054)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48054

Web debugging should be fully removed as of recent, so lets remove some of the gunk that was powering it, and checks for that environment.

I did some string searches for the following:

* isAsyncDebugging
* debugRemotely
* isDebuggingRemotely
* isRemoteDebuggingAvailable
* WebSocketExecutor
* JavaJSExecutor
* ProxyJavaScriptExecutor
* RELOAD_APP_EXTRA_JS_PROXY
* getJSBundleURLForRemoteDebugging
* onReloadWithJSDebugger
* setRemoteJSDebugEnabled
* WebsocketJavaScriptExecutor
* createRemoteDebuggerBundleLoader

1. `expo-modules-core` exposes its own `isAsyncDebugging` by checking for `nativeCallSyncHook`, but does not depend on `DebugEnvironment`.
2. `expo-dev-menu` does read `isDebuggingRemotely` from `DevSettings`.
3. Realm does a check in Native using `objc_lookUpClass("RCTWebSocketExecutor")` but will gracefully handle `nil` if it does not exist
4. Some more usages (e.g. `onReloadWithJSDebugger`) in vendored packages of `expo-dev-launcher` for RN 0.74

I created an issue for Expo mentioning both here: https://github.com/expo/expo/issues/33371

Changelog:
[General][Breaking] - Remove some web debugging remnants

Reviewed By: huntie

Differential Revision: D66553934

fbshipit-source-id: deec382b1c8bda393fddb8682aa91b26afd9fbe3
2025-01-27 14:40:33 -08:00
zhongwuzw 3e2e8ec757 Bridge: Fixes HostTarget use after free when deallocated bridge (#48847)
Summary:
Fixes https://github.com/facebook/react-native/issues/48805 .

## Changelog:

[IOS] [FIXED] - Bridge: Fixes HostTarget use after free when deallocated bridge

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

Test Plan:
Test code:
```
  __weak RCTAlertManager *weakModule;
  autoreleasepool {
    RCTAlertManager *module = [RCTAlertManager new];
    RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:[self sourceURLForBridge:nil]
                                              moduleProvider:^{
      return @[ module ];
    }
                                               launchOptions:nil];
    weakModule = module;
    (void)bridge;
  }
```

Reviewed By: realsoelynn

Differential Revision: D68495576

Pulled By: huntie

fbshipit-source-id: c3086a429f24488ac286ff22d039b8f049ccbffd
2025-01-27 12:15:37 -08:00
Nick Gerleman 1593142648 Support parsing hwb() functions (#48913)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48913

This brings us to parity with normalize-color, and is mostly similar to hsl, with the notable exception there is not a separate alpha variant, and only modern function syntax is supported. Again, I took the math from normalize-color, and sanity tested it against reference function provided by Color Spec.

I'm going to let that cap off color function support for now, and leave the rest as TODO.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D68594471

fbshipit-source-id: 95702d576e068655d34e52a714d38e4fd718bbc9
2025-01-27 12:07:21 -08:00
Nick Gerleman 676359efd9 Breaking: Remove incorrect hwb() syntax support from normalize-color (#48912)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48912

The implementation of `hwb()` color functions added in https://github.com/facebook/react-native/pull/34600 is pretty flawed.

`hwb()` color functions do not allow comma delimited values. So most of the examples in the unit test here will fail to parse on web. Like `hsl()`, these should also allow numeric non-hue components (instead of just %), and angle values for hue (instead of just numbers), and this is also missing support for alpha values, though these are less dangerous compared to allowing and encouraging incorrect delimiters.

https://www.w3.org/TR/css-color-4/#the-hwb-notation

These were added for web compat, and the examples fail to parse on web, so I'm opting to just remove this incorrect support before implementing this more correctly in the Fabric CSS parser in next diff. I did not attempt to fix the other issues I discovered with the PR implementation in the last couple diffs, around mixing and matching syntax allowed in legacy/modern, along with allowing inconsistent delimiters.

Changelog:
[General][Breaking] - Remove incorrect hwb() syntax support from normalize-color

Reviewed By: lenaic

Differential Revision: D68591172

fbshipit-source-id: 36d670b096ae9fac4bc24938877ad083d4dd336a
2025-01-27 12:07:21 -08:00
Christoph Purrer a419315543 Use uint32_t for httpStatus (#48946)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48946

[Changelog] [Internal] - [jsinspector-modern] Use uint32_t for httpStatus

Reviewed By: hoxyq

Differential Revision: D68676415

fbshipit-source-id: 748a2167fa695151095b74cf901f13951f28b0fa
2025-01-27 11:51:13 -08:00
Alex Hunt 45cd63c259 Back out "Migrate Libraries/Utilities/*.js to use export syntax." (#48976)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48976

Changelog: [Internal] - Will reattempt

Differential Revision: D68713280

fbshipit-source-id: 069d7dfd9846ab6272865b83163e772a6b17936a
2025-01-27 11:18:56 -08:00
Tim Yung 50b75a74d1 Animated: Setup scheduleAnimatedCleanupInMicrotask Feature Flag (#48878)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48878

Creates a new `scheduleAnimatedCleanupInMicrotask` feature flag to experiment with deferring the `AnimatedProps` cleanup using the microtask queue.

This is different from the previous approach of deferring invocation of the completion callback, which impacted the timing of composite animations such as `Animated.parallel` and `Animated.sequence`, because we are deferring detaching the `AnimatedNode` graph instead. This will only impact the timing of completion callbacks as a result of invalidating `AnimatedProps` (either by passing in new `AnimatedValue` instances or unmounting the component).

This should minimally impact scheduling and have lower risk of user-visible behavior change because React already provides minimal guarantees around when updates are committed (and effects attached/detached).

This also enables us to significantly simplify the current convoluted dance we do to optimized around reference counting in the AnimatedNode graph.

Changelog:
[General][Changed] - When an Animated component is updated or unmounted, `AnimatedNode` instances will now detach in a microtask instead of synchronously in the commit phase of React. This will cause the completion callback of finished animations to execute after the commit phase instead of during it.

Reviewed By: rickhanlonii

Differential Revision: D68527096

fbshipit-source-id: 99346b8ddbf6a01725376c692b0351be679b9e89
2025-01-27 11:04:34 -08:00
Riccardo Cipolleschi e77fe5c471 Bump React Native monorepo packages (#48975)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48975

After cutting 0.78-stable, we need to bump the monorepo packages to `0.79.0-main`

## Changelog:
[Internal] - Bump monorepo packages to `0.79.0-main`

Reviewed By: cortinico, huntie

Differential Revision: D68715005

fbshipit-source-id: cb5abbf05e8638683687be8d61d66b3037111572
2025-01-27 11:01:34 -08:00
Samuel Susla 6acd541f94 disable failing Differentiator test (#48973)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48973

changelog: [internal]

This test is broken, let's disable it until it is fixed.

Reviewed By: javache

Differential Revision: D68709385

fbshipit-source-id: f61b287ad7ef921dd26fa290cc7a484d0b550091
2025-01-27 10:24:20 -08:00
Nicola Corti a08a6c9adc Remove unnecessary visiblity modifiers for internal classes (#48968)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48968

I've noticed we have a lot of `public` and `protected` modifiers for classes that are actually `internal`.
Those are unnecessary as the class itself is `internal` and there is no way to extend the visibility of single fields.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D68707255

fbshipit-source-id: 5b93d01dceba1b5031ac608e58ec898c1a1eaf51
2025-01-27 10:17:31 -08:00
Cedric van Putten ba894c908a fix(react-native): pass the protocol from bundle URL to HMR client on Android (#48970)
Summary:
We've noticed that the HMR on Android doesn't seem to be connecting when using a HTTPS-proxied Metro instance, where the proxy is hosted through Cloudflare. This is only an issue on Android - not iOS - and likely caused by the HMR Client not being set up properly on Android.

- On Android, we run `.setup('android', <bundleEntryPath>, <proxiedMetroHost>, <proxiedMetroPort>, <hmrEnabled>)` in the [**react/devsupport/DevSupportManagerBase.java**](https://github.com/facebook/react-native/blob/53d94c3abe3fcd2168b512652bc0169956bffa39/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java#L689-L691) file.
- On iOS, we run `[self.callableJSModules invokeModule:@"HMRClient" method:@"setup" withArgs:@[ RCTPlatformName, path, host, RCTNullIfNil(port), @(isHotLoadingEnabled), scheme ]];` in the [**React/CoreModules
/RCTDevSettings.mm**](https://github.com/facebook/react-native/blob/53d94c3abe3fcd2168b512652bc0169956bffa39/packages/react-native/React/CoreModules/RCTDevSettings.mm#L488-L491) file.

Notice how Android does not pass in the scheme/protocol of the bundle URL, while iOS actually does? Unfortunately, because the default protocol (`http`) mismatches on Android when using HTTPS proxies, we actually try to connect the HMR client over `http` instead of `https` - which is rejected by Cloudflare's infrastructure even before we can redirect or mitigate this issue.

This change adds scheme propagation to Android, exactly like we do on iOS for the HMR Client.

## Changelog:

[ANDROID] [FIXED] Pass the bundle URL protocol when setting up HMR client on Android

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

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

Test Plan: It's a little bit hard to test this out yourself, since you'd need a HTTPS-based proxy and reject HTTP connections for HTTPS/WSS Websocket requests.

Reviewed By: fabriziocucci

Differential Revision: D68711137

Pulled By: javache

fbshipit-source-id: 230c1c91c8189c0a109d20defe085966ac8f5721
2025-01-27 09:43:55 -08:00
Nicola Corti e05a2735cd Add Changelog for 0.74.7 (#48974)
Summary:
Changelog for 0.74.7

## Changelog:

[Internal] [Changed] -

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

Test Plan: N/A

Reviewed By: cipolleschi

Differential Revision: D68714820

Pulled By: cortinico

fbshipit-source-id: 42ee0e2cb83cf2ee16161468d1127fa2a8cc73bb
2025-01-27 09:37:04 -08:00
Håkon Knutzen 2a18d83521 Make RCTDeviceInfo._invalidated std::atomic<BOOL> (#48890)
Summary:
When running the tests associated with `RNTestPods` with `TSan` enabled, I get a data race:

```
WARNING: ThreadSanitizer: data race (pid=28047)
  Read of size 1 at 0x000144c30be9 by thread T32:
    #0 -[RCTDeviceInfo invalidate] <null> (RNTesterUnitTests:arm64+0x434bf8)
    https://github.com/facebook/react-native/issues/1 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ <null> (CoreFoundation:arm64+0x5e7fc)
    https://github.com/facebook/react-native/issues/2 decltype(std::declval<void () block_pointer __strong&>()()) std::__1::__invoke[abi:de180100]<void () block_pointer __strong&>(&&, decltype(std::declval<void () block_pointer __strong&>()())&&...) <null> (RNTesterUnitTests:arm64+0x2a19d4)
    https://github.com/facebook/react-native/issues/3 std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x2a16ec)
    https://github.com/facebook/react-native/issues/4 std::__1::__function::__value_func<void ()>::operator()[abi:de180100]() const <null> (RNTesterUnitTests:arm64+0x2455d4)
    https://github.com/facebook/react-native/issues/5 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x245404)
    https://github.com/facebook/react-native/issues/6 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x2c85b4)
    https://github.com/facebook/react-native/issues/7 -[RCTCxxBridge _tryAndHandleError:] <null> (RNTesterUnitTests:arm64+0x27c9e8)
    https://github.com/facebook/react-native/issues/8 __NSThreadPerformPerform <null> (Foundation:arm64+0x76c5e8)
    https://github.com/facebook/react-native/issues/9 __NSThread__start__ <null> (Foundation:arm64+0x76c27c)

  Previous write of size 1 at 0x000144c30be9 by thread T30:
    #0 -[RCTDeviceInfo invalidate] <null> (RNTesterUnitTests:arm64+0x434c1c)
    https://github.com/facebook/react-native/issues/1 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ <null> (CoreFoundation:arm64+0x5e7fc)
    https://github.com/facebook/react-native/issues/2 decltype(std::declval<void () block_pointer __strong&>()()) std::__1::__invoke[abi:de180100]<void () block_pointer __strong&>(&&, decltype(std::declval<void () block_pointer __strong&>()())&&...) <null> (RNTesterUnitTests:arm64+0x2a19d4)
    https://github.com/facebook/react-native/issues/3 std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x2a16ec)
    https://github.com/facebook/react-native/issues/4 std::__1::__function::__value_func<void ()>::operator()[abi:de180100]() const <null> (RNTesterUnitTests:arm64+0x2455d4)
    https://github.com/facebook/react-native/issues/5 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x245404)
    https://github.com/facebook/react-native/issues/6 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x2c85b4)
    https://github.com/facebook/react-native/issues/7 -[RCTCxxBridge _tryAndHandleError:] <null> (RNTesterUnitTests:arm64+0x27c9e8)
    https://github.com/facebook/react-native/issues/8 __NSThreadPerformPerform <null> (Foundation:arm64+0x76c5e8)
    https://github.com/facebook/react-native/issues/9 __NSThread__start__ <null> (Foundation:arm64+0x76c27c)

  Location is heap block of size 48 at 0x000144c30bd0 allocated by main thread:
    #0 calloc <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x53b90)
    https://github.com/facebook/react-native/issues/1 _malloc_type_calloc_outlined <null> (libsystem_malloc.dylib:arm64+0xf8dc)
    https://github.com/facebook/react-native/issues/2 -[RCTModuleData setUpInstanceAndBridge:] <null> (RNTesterUnitTests:arm64+0x32715c)
    https://github.com/facebook/react-native/issues/3 __25-[RCTModuleData instance]_block_invoke <null> (RNTesterUnitTests:arm64+0x32a288)
    https://github.com/facebook/react-native/issues/4 RCTUnsafeExecuteOnMainQueueSync <null> (RNTesterUnitTests:arm64+0x3d6e1c)
    https://github.com/facebook/react-native/issues/5 -[RCTModuleData instance] <null> (RNTesterUnitTests:arm64+0x329d78)
    https://github.com/facebook/react-native/issues/6 __49-[RCTCxxBridge _prepareModulesWithDispatchGroup:]_block_invoke <null> (RNTesterUnitTests:arm64+0x287e74)
    https://github.com/facebook/react-native/issues/7 __wrap_dispatch_group_async_block_invoke <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x7cffc)
    https://github.com/facebook/react-native/issues/8 _dispatch_client_callout <null> (libdispatch.dylib:arm64+0x3c04)
    https://github.com/facebook/react-native/issues/9 __70-[XCTestCase _shouldContinueAfterPerformingSetUpSequenceWithSelector:]_block_invoke.136 <null> (XCTestCore:arm64+0x2d068)

  Thread T32 (tid=4154385, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x3027c)
    https://github.com/facebook/react-native/issues/1 -[NSThread startAndReturnError:] <null> (Foundation:arm64+0x76bec4)
    https://github.com/facebook/react-native/issues/2 -[RCTBridge setUp] <null> (RNTesterUnitTests:arm64+0x23d638)
    https://github.com/facebook/react-native/issues/3 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x23addc)
    https://github.com/facebook/react-native/issues/4 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x23aa4c)
    https://github.com/facebook/react-native/issues/5 -[RCTImageLoaderTests testImageLoaderUsesImageDecoderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0xc578)
    https://github.com/facebook/react-native/issues/6 __invoking___ <null> (CoreFoundation:arm64+0x132cdc)

  Thread T30 (tid=4154383, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x3027c)
    https://github.com/facebook/react-native/issues/1 -[NSThread startAndReturnError:] <null> (Foundation:arm64+0x76bec4)
    https://github.com/facebook/react-native/issues/2 -[RCTBridge setUp] <null> (RNTesterUnitTests:arm64+0x23d638)
    https://github.com/facebook/react-native/issues/3 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x23addc)
    https://github.com/facebook/react-native/issues/4 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x23aa4c)
    https://github.com/facebook/react-native/issues/5 -[RCTImageLoaderTests testImageDecoding] <null> (RNTesterUnitTests:arm64+0xa8d0)
    https://github.com/facebook/react-native/issues/6 __invoking___ <null> (CoreFoundation:arm64+0x132cdc)
```

The proposed solution is making the `BOOL` ivar in question a `std::atomic<BOOL>` instead.

## Changelog:

[IOS][FIXED] Data race related to read/write of RCTDeviceInfo._invalidated.

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

Test Plan: Existing tests in `RNTesterPods` and manually running RNTester application.

Reviewed By: christophpurrer

Differential Revision: D68629011

Pulled By: javache

fbshipit-source-id: 229d0db4aa13253b96ce0a20c9795c17e344cfc1
2025-01-27 09:20:47 -08:00
Rubén Norte f282baa26a Implement CustomEvent (#48922)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48922

Changelog: [internal]

This is a basic subclass of Event that allows setting custom values (as opposed to `Event` that is meant to be used as a superclass).

Reviewed By: yungsters

Differential Revision: D67804060

fbshipit-source-id: 9e140cc436f8e230f37275a74df23efd4841071b
2025-01-27 07:48:50 -08:00
Rubén Norte 8445ebc248 Create module to handle event handler attributes (#48920)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48920

Changelog: [internal]

Implements a module with helpers to define event handler IDL attributes in classes extending `EventTarget`. E.g.:

```
import {getEventHandlerAttribute, setEventHandlerAttribute} from '../path/to/EventHandlerAttributes';

class EventTargetSubclass extends EventTarget {
  get oncustomevent(): EventListener | null {
    return getEventHandlerAttribute(this, 'customEvent');
  }
  set oncustomevent(listener: EventListener | null) {
    setEventHandlerAttribute(this, 'customEvent', listener);
  }
}

const eventTargetInstance = new EventTargetSubclass();

eventTargetInstance.oncustomevent = (event: Event) => {
  console.log('custom event received');
};
eventTargetInstance.dispatchEvent(new Event('customEvent'));
// Logs 'custom event received' to the console.

eventTargetInstance.oncustomevent = null;
eventTargetInstance.dispatchEvent(new Event('customEvent'));
// Does not log anything to the console.

```

Reviewed By: javache

Differential Revision: D67839560

fbshipit-source-id: f301d174fa9a4c010940b875cadfc31298947c26
2025-01-27 07:48:50 -08:00
Rubén Norte 9fbc02a031 Move all properties of EventTarget to symbols to avoid polluting the global scope (#48962)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48962

Changelog: [internal]

We moved away from private fields for `EventTarget` for performance, in favor of normal fields prefixed with underscore, but this would pollute the global scope when we make it extend `EventTarget`.

This refactors the implementation to use symbols for all properties to avoid that problem, leaving only `addEventListener` and `removeEventListener` as regular properties in the prototype.

Performance-wise this is neutral or a slight improvement according to the existing benchmark.

Reviewed By: javache

Differential Revision: D68672215

fbshipit-source-id: b329548efce6059ae2b9f33afa0719e057d3b8ba
2025-01-27 07:48:50 -08:00
Rubén Norte b28ab79f1b Make constants in Event more spec compliant (#48918)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48918

Changelog: [internal]

Makes the constants read-only and accessible through `Event.prototype` as well.

Reviewed By: yungsters

Differential Revision: D67830012

fbshipit-source-id: 730622a642f08f532cebd4c183d859ccb2ca0641
2025-01-27 07:48:50 -08:00
Rubén Norte e04e502f77 Further optimizations for event dispatching (#48426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48426

Changelog: [internal]

This improves the performance of DOM `Event` interface implementation by migrating away from private fields.

Reviewed By: yungsters

Differential Revision: D67751821

fbshipit-source-id: e58e5a9cbb04e7d91cbc676ec7d1b00fff357e2e
2025-01-27 07:48:50 -08:00
Rubén Norte 47e490f084 Make EventTarget compatible with the existing implementation of ReadOnlyNode (#48427)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48427

Changelog: [internal]

The `ReactNativeElement` class was refactored for performance reasons, and the current implementation does **NOT** call `super()`, and it inlines the parent constructor instead.

When it eventually extends `EventTarget`, things won't work as expected because the existing `EventTarget` implementation has constructor dependencies.

This refactors the current implementation of `EventTarget` to eliminate those constructor side-effects, and eliminates the constructor altogether.

This breaks encapsulation, but it has some positive side-effects on performance:
1. Creating `EventTarget` instances is faster because it has no constructor logic.
2. Improves memory by not creating maps to hold the event listeners if no event listeners are ever added to the target (which is very common).
3. Improves the overall runtime performance of the methods in the class by migrating away from private methods (which are known to be slow on the babel transpiled version we're currently using).

Extra: it also simplifies making window/the global scope implement the EventTarget interface :)

## Benchmark results

Before:

| Latency average (ns) | Latency median (ns) | Samples | Task name                                              | Throughput average (ops/s) | Throughput median (ops/s) |
| ---|--- |--- |--- |---|---|
| 8234.22 ± 0.27%      | 8132.00             | 121445  | dispatchEvent, no bubbling, no listeners               | 122323 ± 0.02%             | 122971                   |
| 9001.22 ± 0.41%      | 8883.00             | 111097  | dispatchEvent, no bubbling, single listener            | 111981 ± 0.02%             | 112575                   |
| 51777.94 ± 0.58%     | 51247.00            | 19314   | dispatchEvent, no bubbling, multiple listeners         | 19393 ± 0.04%              | 19513                    |
| 8256.65 ± 0.29%      | 8152.00             | 121115  | dispatchEvent, bubbling, no listeners                  | 122031 ± 0.02%             | 122669                   |
| 9064.32 ± 0.44%      | 8933.00             | 110323  | dispatchEvent, bubbling, single listener per target    | 111265 ± 0.02%             | 111944                   |
| 51879.66 ± 0.27%     | 51447.00            | 19276   | dispatchEvent, bubbling, multiple listeners per target | 19325 ± 0.04%              | 19437               |

After:

| Latency average (ns) | Latency median (ns) | Samples | Task name                                              | Throughput average (ops/s) | Throughput median (ops/s)|
| ---------------------|---------------------|---------|--------------------------------------------------------|----------------------------|--------------------------|
| 5664.62 ± 0.50%      | 5588.00             | 176535  | dispatchEvent, no bubbling, no listeners               | 178219 ± 0.02%             | 178955                   |
| 7232.86 ± 0.50%      | 7131.00             | 138258  | dispatchEvent, no bubbling, single listener            | 139540 ± 0.02%             | 140233                   |
| 50957.51 ± 0.71%     | 50336.00            | 19625   | dispatchEvent, no bubbling, multiple listeners         | 19751 ± 0.04%              | 19866                    |
| 5692.36 ± 0.50%      | 5618.00             | 175675  | dispatchEvent, bubbling, no listeners                  | 177315 ± 0.02%             | 177999                   |
| 7277.82 ± 0.38%      | 7181.00             | 137404  | dispatchEvent, bubbling, single listener per target    | 138560 ± 0.02%             | 139256                   |
| 50493.64 ± 0.28%     | 50105.00            | 19805   | dispatchEvent, bubbling, multiple listeners per target | 19855 ± 0.04%              | 19958                    |

Reviewed By: yungsters

Differential Revision: D67758408

fbshipit-source-id: f8da1788251c9e21377de5ab730875bcc7610361
2025-01-27 07:48:50 -08:00
Rubén Norte 07df02d14d Add regression test for EventTarget (#48431)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48431

Changelog: [internal]

Adds a regression test to make sure we implement the correct spec-compliant behavior for a possible bug in ~~the Web spec~~ __Chrome__: https://github.com/whatwg/dom/issues/1346

Edit: the bug is in the Chrome implementation, not in the spec.

Reviewed By: javache

Differential Revision: D67758702

fbshipit-source-id: ecaeacac3bce286e692880f05d70297ba0c2c736
2025-01-27 07:48:50 -08:00
Rubén Norte 3c50d87d05 Add benchmark for EventTarget (#48886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48886

Changelog: [internal]

Creates a benchmarks to measure the performance of `EventTarget`.

Reviewed By: javache

Differential Revision: D67750677

fbshipit-source-id: 7023d5f3bcdc5eec1f5f03298781800d2f9bfe16
2025-01-27 07:48:50 -08:00
Rubén Norte e5024a08d1 Implement Event and EventTarget (#48429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48429

Changelog: [internal]

This implements a (mostly) spec-compliant version of the [`Event`](https://dom.spec.whatwg.org/#interface-event) and [`EventTarget`](https://dom.spec.whatwg.org/#interface-eventtarget) Web interfaces.

It does not implement legacy methods in either of the interfaces, and ignores the parts of the spec that are related to Web-specific quirks (shadow roots, re-mapping of animation events with webkit prefixes, etc.).

IMPORTANT: This only creates the interfaces and does not expose them externally yet (no `Event` or `EventTarget` in the global scope).

Reviewed By: yungsters

Differential Revision: D67738145

fbshipit-source-id: c86db29821552cc1a1b6e1023cc3a21ae55febd5
2025-01-27 07:48:50 -08:00
Thomas Nardone fc98babe3e Nullsafe jcf/react/animated (#48932)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48932

Results of running nullsafe script with `--patch=apply_fixmes`, `--patch=mark_nullsafe`, with minimal manual fixes to get all checks passing.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68629827

fbshipit-source-id: f9d3e741c634743731bdc2870cdccbf73ab58cc1
2025-01-27 07:21:12 -08:00
Mateo Guzmán bbd1e0ff17 Fix FlatList dark mode examples (#48873)
Summary:
- Fix FlatList Nested and Multicolumn dark mode examples
- Convert MultiColumn example from class to functional component
- Fixing several FlowFixMe annotations for both examples

## Changelog:

[INTERNAL] - Fix FlatList dark mode examples

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

Test Plan:
<details>
<summary>Screenshots</summary>

| Before                           | After                          |
|------------------------------------|------------------------------------|
| ![Image 1](https://github.com/user-attachments/assets/c22cbbc1-26e0-4e6b-a21a-0e0a47a23fc2) | ![Image 2](https://github.com/user-attachments/assets/bea957e5-9633-4d1f-91ed-0f4eac58b723) |
| ![Image 3](https://github.com/user-attachments/assets/0d601cdc-a84d-4b06-9f15-ebf793414f53) | ![Image 4](https://github.com/user-attachments/assets/4b605fa5-98d9-4d62-9108-1f7c7148a445) |

</details>

Reviewed By: cortinico

Differential Revision: D68630288

Pulled By: Abbondanzo

fbshipit-source-id: 41c240e4f8c6e6eacf537d53ab4a06bb0b7ef0de
2025-01-27 07:05:50 -08:00
Matthew Horan c499ae1192 Fixes for Keyboard Observer, KeyboardAvoidingView on iOS (#48131)
Summary:
**Convert keyboard position to window coordinate space on iOS**
The keyboard frame passed to keyboardWillChangeFrame is in the screen's coordinate space [1]. It needs to be converted to the window's coordinate space to support Slide Over and Stage Manager.

[1] https://developer.apple.com/documentation/uikit/uikeyboardframeenduserinfokey?language=objc

|Before|After|
|---|---|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 18 58 31](https://github.com/user-attachments/assets/6af21fde-32f1-4b15-83be-09a6dbae8784)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 01 27](https://github.com/user-attachments/assets/c63c2bef-c1a6-4ad4-91cf-74629c26dbb0)|

**Improve detached keyboard detection on iOS**
The iOS keyboard may be in one of three states:
1) floating (previously supported with a width check)
2) split
3) or undocked.

In addition, when using Stage Manager, the keyboard may be wider than the window itself. This would cause the floating keyboard check to incorrectly set the bottom position to zero.

Instead, rely on the fact that the UIKeyboardWillHideNotification notification is sent when the keyboard is in any detached state.

This requires listening for UIKeyboardWillShowNotification instead of UIKeyboardWillChangeFrameNotification. This is fine, since the show notification is also sent when the keyboard resizes while open.

Combined with the coordinate system adjustments in the previous commit, this also fixes an issue with Stage Manager, since the keyboard may be attached yet wider than the application window.

|Before|After|
|---|---|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 18 58 40](https://github.com/user-attachments/assets/4e747ece-b084-49ad-a8d6-5dfe623ae597)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 01 41](https://github.com/user-attachments/assets/50391302-4c83-4aa3-a96b-6056bba891ec)|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 48 19](https://github.com/user-attachments/assets/576691b3-6b84-41cf-87f4-0cf52fc405d4)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 05 33](https://github.com/user-attachments/assets/4bb60ca6-beb3-471e-bc71-38a18fc9c0f1)|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 48 55](https://github.com/user-attachments/assets/baf456fb-aa61-455b-9c20-a01a6a979cb5)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 05 56](https://github.com/user-attachments/assets/0b7fe954-a72f-407a-bb41-0f47253c9448)|

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[iOS] [FIXED] - Keyboard events are converted to window coordinate space
[iOS] [FIXED] - Improve detached keyboard detection, support Stage Manager on iOS

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

Test Plan: See screenshots above.

Reviewed By: yungsters

Differential Revision: D67337314

Pulled By: cipolleschi

fbshipit-source-id: abe872ac8c83336f316917074f72cdb23a39caab
2025-01-27 06:57:02 -08:00
Riccardo Cipolleschi 4141560afc Call cocoapods passing the RCT_IGNORE_PODS_DEPRECATION flag (#48967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48967

This change updates the core-cli-utils package to call `pod install` by passing the `RCT_IGNORE_PODS_DEPRECATION` flag.

## Changelog:
[iOS][Changed] - Ignore deprecation warning when calling pod install through core-cli-utils

Reviewed By: cortinico

Differential Revision: D68704956

fbshipit-source-id: 5ce56e3ec8c5718f6403f8871bebf6aceeeb407b
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi cc1e8d1523 Move running codegen to core-cli-utils (#48965)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48965

Running codegen should not be a Cocoapods responsibilities, but it should be something that runs before Cocoapods to ensure that the code is already in the right place.

This change moves the invocation of Codegen to the react-native's core-cli-utils so that frameworks can integrate better with it.

It should also make it easier to migrate away from Cocoapods.

## Changelog:
[iOS][Changed] - Invoke Codegen as part of the Core-cli-utils package

Reviewed By: cortinico

Differential Revision: D68706136

fbshipit-source-id: 548c9ffad62bc561fcc948babaf75de5dad82f86
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi 2527d29a96 Update Gemfile (#48966)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48966

In our previous fix for concurrent-ruby, we have been a bit too strict. Version 1.3.4 is a valid and working version. The broken version is 1.3.5.

## Changelog:
[iOS][Changed] - Fix Gemfile versions

Reviewed By: cortinico

Differential Revision: D68706060

fbshipit-source-id: 8ab7a4df0eb83a82603729ff8460e64908ddc465
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi f15094ef88 Stop running Codegen on Pod install when a flag is passed (#48961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48961

One of Cocoapods responsibility is to run Codegen while creating the Xcode workspace. Moving away from Cocoapods, this is a step we need to move to a different place.

This change let us to disable running codegen at cocoapods time when we pass the `RCT_SKIP_CODEGEN=1` or when we pass the `RCT_IGNORE_PODS_DEPRECATION=1` flag calling pod install.

When calling `pod install` with `RCT_IGNORE_PODS_DEPRECATION` we are either:
* using one of the Scripts provided by Expo or by the Community CLI
*or*
* we are preparing the project using the legacy mode and, therefore, we want to keep running codegen.

## Changelog
[iOS][Changed] - Stop running codegen when running pod install

Reviewed By: cortinico

Differential Revision: D68704604

fbshipit-source-id: 252e90544886c3dbfd7eff38c344dd4784a0af38
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi e3def00d7a Warn users when calling pod install (#48960)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48960

We are moving away from Cocoapods toward alternative solution.

We are adding this deprecation message to help inform our users that this change is happening.

Part of the Cocoapods tasks will be moved to an alternative script that will be invoked by Expo and by the Community CLI. The warning message tells the users what to do as an alternative to `pod install`.

## Changelog:
[iOS][Deprecated] - deprecate calling `pod install` directly

Reviewed By: cortinico

Differential Revision: D68704127

fbshipit-source-id: df93008afc055254d0c0da09566c84af99248310
2025-01-27 06:52:35 -08:00
Iwo Plaza bdc23fa2b4 Migrate files in Libraries/Interaction to use export syntax (#48933)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48933

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling

## This diff
- Updates files in Libraries/Interaction to use `export` syntax
- Appends `.default` to requires of the changed files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Interaction` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68629953

fbshipit-source-id: 526b18d9b64c4b27b6e3198a9725075fa11e345a
2025-01-27 06:32:58 -08:00
Samuel Susla 0f0344984f ship useOptimisedViewPreallocationOnAndroid everywhere and remove gating (#48903)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48903

changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D68490542

fbshipit-source-id: f743e9c82328c5f06b431cffe77f9a28608535b9
2025-01-27 06:26:35 -08:00
Edmond Chui 46e86dca87 Update tests to support new didOpen delegate fn
Summary:
Changelog: [General][Fixed] Update tests to support new `didOpen` delegate fn

Add support for the new `didOpen` delegate function in tests.

To follow up separately: the borked tear down sequence when these two tests are ran together (they pass when ran individually)

```
buck2 test @//fbobjc/mode/buck2/ios-tests fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/jsinspector-modern:testsAppleMac -- ReactInstanceIntegrationTest RuntimeTargetDebuggerSessionObserverTest
```

Reviewed By: hoxyq

Differential Revision: D68632974

fbshipit-source-id: 59da6d9e2d09f2c7e219c1902dd6f9b8ddfee9dc
2025-01-27 05:53:15 -08:00
Mateo Guzmán 53d94c3abe Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin (#48945)
Summary:
Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin

## Changelog:

[INTERNAL] - Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin

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

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D68705783

Pulled By: arushikesarwani94

fbshipit-source-id: 9c2cc2927eae50d0dce91384bf945a8c795c0bbd
2025-01-27 04:48:22 -08:00
Samuel Susla 1257122a02 introduce Fantom.flushAllNativeEvents (#48943)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48943

changelog: [internal]

A new helper function on Fantom flushAllNativeEvents, which will flush all pending native events.

Reviewed By: javache

Differential Revision: D68566753

fbshipit-source-id: 6cb19416e39807b9b381ff068cea5c2458101174
2025-01-27 04:42:44 -08:00
Samuel Susla aa5760837c introduce Fantom.scrollTo (#48907)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48907

changelog: [internal]

Introduce new function `Fantom.scrollTo`, which will fake a scroll to particular position.
Calling the method will call onScroll event using codepath that iOS uses. It will also set C++ state so the new scroll position is observable from JavaScript.

Reviewed By: javache

Differential Revision: D68554703

fbshipit-source-id: 2fc71e96836a03ec343053ceed85764c4bc2f5c7
2025-01-25 14:58:28 -08:00
Samuel Susla 84b8e6a531 unify Fantom calling convention to Fantom.foo (#48924)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48924

changelog: [internal]

All other Fantom tests are using Fantom.foo style instead of `foo`. Let's unify codebase on this.

Reviewed By: christophpurrer

Differential Revision: D68552829

fbshipit-source-id: eeefc449b1f33161b3583dd68b08f83455d1a959
2025-01-25 14:58:28 -08:00
David Vacca e44b2fa973 Migrate ReactBridge to kotlin (#48904)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48904

Migrate ReactBridge to kotlin

changelog: [internal] internal

Reviewed By: tdn120, cortinico

Differential Revision: D68540709

fbshipit-source-id: 35a6d19f940dabdecbe7b7f835953d9f07f7222b
2025-01-24 16:17:58 -08:00
Pieter De Baets 73968dc778 Cleanup initEagerTurboModulesOnNativeModulesQueueAndroid flag (#48917)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48917

Cleaning up this flag which has already been rolled out

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68622852

fbshipit-source-id: 5767515d02ce9804976a1363532e1e626aeae0d8
2025-01-24 10:57:41 -08:00
Pieter De Baets 7f62ff6b02 Cleanup completeReactInstanceCreationOnBgThreadOnAndroid and useImmediateExecutorInAndroidBridgeless flags (#48916)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48916

Cleaning up this feature flag since we no longer require this gating. This was already fulled rulled out as default.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68621578

fbshipit-source-id: 3fd3ad007b8beb8e2525ffa7b4da372be1dbbd94
2025-01-24 10:57:41 -08:00
Tim Yung b186d8f9b8 Animated: Hoist Non-Lifecycle Logic from useAnimatedPropsLifecycle (#48877)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48877

This is a minor refactor to hoist logic that is not actually specific to the `AnimatedProps` lifecycle out of the hook named `useAnimatedPropsLifecycle`.

This will make it easier to iterate on the implementation of `useAnimatedPropsLifecycle` using a feature flag in a subsequent diff.

This has no behavior change.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D68516034

fbshipit-source-id: 2cd6d9b0f2a5c0ada10cf01c8c14ed5510fbf25a
2025-01-24 10:48:44 -08:00
Nicola Corti 54e0b69e7e Stable API - Make AnimatedNodeWithUpdateableConfig internal (#48900)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48900

I've verified that this interface is not used externally, so I'm making it internal.
https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Apvinis%2Freact-native---investigation+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+repo%3Amolangning%2Freversing-discord+com.facebook.react.animated.AnimatedNodeWithUpdateableConfig+

Changelog:
[Android] [Removed] - Stable API - Make `AnimatedNodeWithUpdateableConfig` internal as it was not used in OSS

Reviewed By: tdn120, mdvacca

Differential Revision: D68562055

fbshipit-source-id: 0f06c22dc096efabce9fb937f099775effbff3f6
2025-01-24 10:22:23 -08:00
David Vacca 2fa0494bc4 Internalize ReactNativeFeatureFlags generated accessor classes (#48909)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48909

Internalize ReactNativeFeatureFlags generated accessor classes

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D68579670

fbshipit-source-id: 63606793e2a63f1901c7de2cb40e68c27193259d
2025-01-24 10:15:58 -08:00
David Vacca c0ad6a4cd5 Internalize ReactNativeFeatureFlags Accessor interfaces & Classes (#48910)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48910

Internalize ReactNativeFeatureFlags Accessor interfaces & Classes

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D68579453

fbshipit-source-id: 9549221b47e93a9c8a3161c3914ece849f7f9a52
2025-01-24 10:15:58 -08:00
Nicola Corti c495a8ab1b Remove unused AndroidUnicodeUtils. (#48919)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48919

I suspect this class is unused and we should not be building it.
The same `AndroidUnicodeUtils.java` is provided by facebook/hermes instead.

Changelog:
[Internal] [Changed] -

Reviewed By: tdn120, mdvacca

Differential Revision: D68623307

fbshipit-source-id: 0a290d31e3b1103947a9dd3c46821958be9223e7
2025-01-24 10:03:04 -08:00
Iwo Plaza 52ffda7e55 Migrate Libraries/Utilities/*.js to use export syntax. (#48665)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48665

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling

## This diff
- Updates files in Libraries/Utilities to use `export` syntax
  - `export default` for qualified objects, many `export` statements for collections (determined by how it's imported)
- Appends `.default` to requires of the changed files.
- Updates Jest mocks of the `Platform` module, which happened to touch a lot of test files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Utilities` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68152910

fbshipit-source-id: 07f3a0957f1dbaf44f53974c6f28b273558406eb
2025-01-24 09:17:55 -08:00
Iwo Plaza 1be7e1a95f Migrate Libraries/Text, Libraries/Share and Libraries/Settings to use export syntax (#48901)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48901

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling.

## This diff
- Updates files in `Libraries/Text`, `Libraries/Share` and `Libraries/Settings` to use `export` syntax.
- Appends `.default` to requires of the changed files.
- Updates test files.
- Updates the public API snapshot *(intented breaking change)*

Changelog:
[General][Breaking] - Files inside `Libraries/Text`, `Libraries/Share` and `Libraries/Settings` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68562844

fbshipit-source-id: bd71a341e33d3629121aa61549139c4b1cd62c3f
2025-01-24 08:49:15 -08:00
Ruslan Lesiutin b578647980 Use custom tracks for measures (#48926)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48926

# Changelog: [Internal]

Leverage [`devtools` field](https://developer.chrome.com/docs/devtools/performance/extension#devtools_object) inside [`detail` object](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#detail) to make extension tracks work.

Right now we are only specifying track name, later we could use many more fields:
```
interface ExtensionTrackEntryPayload {
  dataType?: "track-entry"; // Defaults to "track-entry"
  color?: DevToolsColor;    // Defaults to "primary"
  track: string;            // Required: Name of the custom track
  trackGroup?: string;      // Optional: Group for organizing tracks
  properties?: [string, string][]; // Key-value pairs for detailed view
  tooltipText?: string;     // Short description for tooltip
}
```

In the next few diffs I will extend the spec of the local implementation for `performance.measure` and `performance.mark` to get this propagated correctly.

Reviewed By: huntie

Differential Revision: D68624603

fbshipit-source-id: 99a5d233ee1dbcd690ad8a6802ca993071f63f2c
2025-01-24 08:41:48 -08:00
Ruslan Lesiutin 2e5fa4e35d Migrate to Inspector trace (#48923)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48923

# Changelog: [Internal]

Starting from this diff, React Native will emit inspector traces, the ones that will have the same UI as if it was recorded in a browser.

We are going to fake it by sending "TracingStartedInPage" event. For a corresponding logic on Chrome DevTools Frontend side, see [this](https://github.com/ChromeDevTools/devtools-frontend/blob/192673131cf3e6e0bcdb4a97bd0bd39c75f1b3c2/front_end/models/trace/handlers/MetaHandler.ts#L68-L80) as a starting point.

Because of this, custom tracks are now grouped under "Timings" track, although with a better color scheme:
- We no longer need the logic for placing tracks under arbitrary thread ids to have them grouped.
- The real support for extension tracks (custom tracks for Performance panel) will be added in the next diff.

Reviewed By: huntie

Differential Revision: D68439734

fbshipit-source-id: 8e5c525a71578375904edc6d473308eb710b5867
2025-01-24 08:41:48 -08:00